站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 4.1.0

VcsUtilities (NetBeans VCS API) - NetBeans API Javadoc 4.1.0

 

org.netbeans.modules.vcscore.util
Class VcsUtilities

java.lang.Object
  extended byorg.netbeans.modules.vcscore.util.VcsUtilities

public class VcsUtilities
extends Object

Miscelaneous stuff.


Constructor Summary
VcsUtilities()
           
 
Method Summary
static Map addEnvVars(Map envVars, Hashtable vars, String varEnvPrefix)
          Add environment variables from the variables table.
static Map addEnvVars(Map envVars, Hashtable vars, String varEnvPrefix, String varEnvRemovePrefix)
          Add environment variables from the variables table and remove any variables denoted with a remove prefix from the environment.
static boolean areQuotedStringsContainedInSet(String quotedStr, Set set)
          Find out, whether all string from the field of quoted strings are contained in a set of strings.
static String array2string(String[] sa)
           
static String array2stringNl(String[] sa)
          Converts the array of strings into a string containing the elements separated by new line.
static String arrayToQuotedString(String[] sa, boolean unixShell, String quotation)
           
static String arrayToQuotedStrings(String[] sa)
          Get the comma-separated quoted strings from an array of strings.
static String arrayToSpaceSeparatedString(String[] sa)
           
static String arrayToString(String[] sa)
           
static void centerWindow(Window w)
           
static int charCount(String str, char c)
          Returns the number of characters in the specified string.
static String computeRegularExpressionFromIgnoreList(List ignoreList)
           
static FileObject[] convertFileObjects(FileObject[] originals)
          Performs the conversion from the Fileobjects retrieved from nodes to the real underlying versioning filesystem's fileobjects.
static File createTMP()
          Creates a temporary directory.
static String createUniqueName(String name, Collection names)
          Create a unique name, that does not occure in the collections of names.
static Object decodeValue(String value)
          Creates serialized object, which was encoded in HEX format
static boolean deleteRecursive(File dir)
           
static String encodeValue(Object value)
          Encodes Object into String encoded in HEX format
static Frame getAncestor(JComponent c, Dialog[] dialog_ptr)
          Get the top level ancestor of a component which is a Frame or Dialog.
static String getBundleString(String str)
          Get a string from a resource bundle.
static String getBundleString(String[] resourceBundles, String str)
          Get a string where some of it's parts can be loaded from one or more resource bundles.
static String getBundleString(String[] resourceBundles, String str, String suffix)
          Get a string where some of it's parts can be loaded from one or more resource bundles.
static String getDirNamePart(String path)
           
static String[] getEnvString(Map envVars)
           
static String getFileNamePart(String path)
           
static FileObject getMainFileObject(FileObject fo)
          Get the main FileObject that resides on MasterFS for the given FileObject that can be on some delegate FS.
static int getPairIndex(String str, int from, char p1, char p2)
          Get the pair index of a given character.
static String[] getQuotedArguments(String str)
          Converts a String of quoted values delimited by spaces or any other white characters to an array of String values.
static String[] getQuotedStrings(String str)
          Converts a String of quoted values delimited by commas to an array of String values.
static String[] getQuotedStringsWithPairedCharacters(String str, char p1, char p2)
          Converts a String of quoted values delimited by commas to an array of String values.
static ClassLoader getSFSClassLoader()
          Get the class loader, that loads classes from SystemFileSystem.
static Map getSystemEnvVars()
          Get just the system environment variables.
static boolean isSetContainedInQuotedStrings(String quotedStr, Set set)
          Find out, whether all members of a set of strings are contained in the field of quoted strings.
static boolean matchQuotedStringToSet(String quotedStr, Set set)
          Find out, whether some string from the field of quoted strings is contained in a set of strings.
static int max3(int v1, int v2, int v3)
           
static int max7(int v1, int v2, int v3, int v4, int v5, int v6, int v7)
           
static String[] mergeArrays(String[] sa1, String[] sa2)
           
static int numChars(String str, char c)
          Count the number of occurences of a character in the specified String.
static void removeEnterFromKeymap(JTextComponent component)
           
static void removeKeys(HashMap table, HashMap toRemove)
          Removes all keys from the first Hashtable which are defined in the second one.
static String replaceBackslashDollars(String s)
           
static String toSpaceSeparatedString(Vector v)
           
static boolean withinRange(int min, int val, int max)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VcsUtilities

public VcsUtilities()
Method Detail

max3

public static int max3(int v1,
                       int v2,
                       int v3)

max7

public static int max7(int v1,
                       int v2,
                       int v3,
                       int v4,
                       int v5,
                       int v6,
                       int v7)

withinRange

public static boolean withinRange(int min,
                                  int val,
                                  int max)

getPairIndex

public static int getPairIndex(String str,
                               int from,
                               char p1,
                               char p2)
Get the pair index of a given character.

i.e. getPairIndex("(a-(b+c)+d)", 1, '(', ')') gives 10 -- the position of the last ')' <\p>

Parameters:
str - the String to search
from - the initial position
p1 - the pair character
p2 - the character to search
Returns:
the pair position of p2 in the string with respect to occurences of p1

charCount

public static int charCount(String str,
                            char c)
Returns the number of characters in the specified string.

Parameters:
str - the string
c - the character

arrayToString

public static String arrayToString(String[] sa)

array2string

public static String array2string(String[] sa)

array2stringNl

public static String array2stringNl(String[] sa)
Converts the array of strings into a string containing the elements separated by new line.


arrayToSpaceSeparatedString

public static String arrayToSpaceSeparatedString(String[] sa)

arrayToQuotedString

public static String arrayToQuotedString(String[] sa,
                                         boolean unixShell,
                                         String quotation)

arrayToQuotedStrings

public static String arrayToQuotedStrings(String[] sa)
Get the comma-separated quoted strings from an array of strings.


replaceBackslashDollars

public static String replaceBackslashDollars(String s)

mergeArrays

public static String[] mergeArrays(String[] sa1,
                                   String[] sa2)

toSpaceSeparatedString

public static String toSpaceSeparatedString(Vector v)

getQuotedStrings

public static String[] getQuotedStrings(String str)
Converts a String of quoted values delimited by commas to an array of String values. If the values are not quoted, only commas works as delimeters.


getQuotedStringsWithPairedCharacters

public static String[] getQuotedStringsWithPairedCharacters(String str,
                                                            char p1,
                                                            char p2)
Converts a String of quoted values delimited by commas to an array of String values. If the values are not quoted, only commas works as delimeters. It also takes into account paired characters, all returned strings have correctly paired characters.


getQuotedArguments

public static String[] getQuotedArguments(String str)
Converts a String of quoted values delimited by spaces or any other white characters to an array of String values. If the values are not quoted, only white characters works as delimeters.


matchQuotedStringToSet

public static boolean matchQuotedStringToSet(String quotedStr,
                                             Set set)
Find out, whether some string from the field of quoted strings is contained in a set of strings.

Parameters:
quotedStr - the field of quoted strings, can be null
set - the set of strings
Returns:
true if there is a match, false otherwise

areQuotedStringsContainedInSet

public static boolean areQuotedStringsContainedInSet(String quotedStr,
                                                     Set set)
Find out, whether all string from the field of quoted strings are contained in a set of strings.

Parameters:
quotedStr - the field of quoted strings, can be null
set - the set of strings
Returns:
true if yes or the quoted string is null, false if there is a string, that is not contained in the set, or the set is null.

isSetContainedInQuotedStrings

public static boolean isSetContainedInQuotedStrings(String quotedStr,
                                                    Set set)
Find out, whether all members of a set of strings are contained in the field of quoted strings.

Parameters:
quotedStr - the field of quoted strings, can be null
set - the set of strings, can be null
Returns:
true if yes or the quoted string is null, false if there is a string, that is not contained in the set, or the set is null.

getSFSClassLoader

public static ClassLoader getSFSClassLoader()
Get the class loader, that loads classes from SystemFileSystem.


getBundleString

public static String getBundleString(String str)
Get a string from a resource bundle. An arbitrary resource bundle can be specified to get an arbitrary key from. This method resolves all occurrences of "getBundle().getString([, , ...])" to the value of the key obtained from the resource bundle formatted with the optional parameters.

Parameters:
str - the string
Returns:
the resolved string.

getBundleString

public static String getBundleString(String[] resourceBundles,
                                     String str)
Get a string where some of it's parts can be loaded from one or more resource bundles. This method resolves all occurrences of "ResourceMsg([, , ...])" to the value of the key obtained from the resource bundle formatted with the optional parameters, where "number" is the index of the resource bundle in the provided array.

Parameters:
resourceBundles - The array of class names or paths to the resource bundles
str - the string
Returns:
the resolved string.

getBundleString

public static String getBundleString(String[] resourceBundles,
                                     String str,
                                     String suffix)
Get a string where some of it's parts can be loaded from one or more resource bundles. This method resolves all occurrences of "ResourceMsg([, , ...])" to the value of the key obtained from the resource bundle formatted with the optional parameters, where "number" is the index of the resource bundle in the provided array.

Parameters:
resourceBundles - The array of class names or paths to the resource bundles
str - the key identifier (bundle, key string encoded pair)
suffix - key suffix
Returns:
the resolved string.

computeRegularExpressionFromIgnoreList

public static String computeRegularExpressionFromIgnoreList(List ignoreList)

getDirNamePart

public static String getDirNamePart(String path)

getFileNamePart

public static String getFileNamePart(String path)

getAncestor

public static Frame getAncestor(JComponent c,
                                Dialog[] dialog_ptr)
Get the top level ancestor of a component which is a Frame or Dialog. If no such ancestor is found a new JFrame is returned.

Parameters:
c - The component
dialog_ptr - The array in which the parent dialog is returned, if any
Returns:
The frame, if any. Either the frame or dialog is not null.

centerWindow

public static void centerWindow(Window w)

deleteRecursive

public static boolean deleteRecursive(File dir)

removeEnterFromKeymap

public static void removeEnterFromKeymap(JTextComponent component)

numChars

public static int numChars(String str,
                           char c)
Count the number of occurences of a character in the specified String.

Parameters:
str - the String to count the character in
c - the character to count

removeKeys

public static void removeKeys(HashMap table,
                              HashMap toRemove)
Removes all keys from the first Hashtable which are defined in the second one.


getSystemEnvVars

public static Map getSystemEnvVars()
Get just the system environment variables.


addEnvVars

public static Map addEnvVars(Map envVars,
                             Hashtable vars,
                             String varEnvPrefix)
Add environment variables from the variables table.

Parameters:
envVars - the map of environment variables. The additional variables will be added to it.
vars - the table of variables from which the additional environment variables will be added to envVars. Only variables with a given prefix will be added.
varEnvPrefix - the prefix of variables, which are considered as environmental
Returns:
the map of all environment variables

addEnvVars

public static Map addEnvVars(Map envVars,
                             Hashtable vars,
                             String varEnvPrefix,
                             String varEnvRemovePrefix)
Add environment variables from the variables table and remove any variables denoted with a remove prefix from the environment.

Parameters:
envVars - the map of environment variables. The additional variables will be added to it.
vars - the table of variables from which the additional environment variables will be added to envVars. Only variables with a given prefix will be added.
varEnvPrefix - the prefix of variables, which are considered as environmental
varEnvRemovePrefix - the prefix of variables, which will be removed from the environment.
Returns:
the map of all environment variables

getEnvString

public static String[] getEnvString(Map envVars)

createTMP

public static File createTMP()
Creates a temporary directory.


createUniqueName

public static String createUniqueName(String name,
                                      Collection names)
Create a unique name, that does not occure in the collections of names.

Parameters:
name - the base name
names - the collection of names
Returns:
the name if it's not contained in names, name followed by an underscore and a number otherwise

convertFileObjects

public static FileObject[] convertFileObjects(FileObject[] originals)
Performs the conversion from the Fileobjects retrieved from nodes to the real underlying versioning filesystem's fileobjects. Should be used in the action's code whenever the action needs to work with the fileobjects of the versioning fs. That is nessesary when the nodes come from the MultiFilesystem layer, otherwise we'll get the wrong set of fileobjects and commands will behave strangely.


getMainFileObject

public static FileObject getMainFileObject(FileObject fo)
Get the main FileObject that resides on MasterFS for the given FileObject that can be on some delegate FS.


encodeValue

public static String encodeValue(Object value)
                          throws IOException
Encodes Object into String encoded in HEX format

Parameters:
value - Object, which will be encoded
Returns:
serialized Object in String encoded in HEX format
Throws:
IOException

decodeValue

public static Object decodeValue(String value)
                          throws IOException
Creates serialized object, which was encoded in HEX format

Parameters:
value - Encoded serialized object in HEX format
Returns:
Created object from encoded HEX format
Throws:
IOException

 

Built on May 4 2005.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.