com.perforce.api
Class Utils

java.lang.Object
  extended by com.perforce.api.Utils

public final class Utils
extends java.lang.Object

Class that contains static utility methods.

Version:
$Date: 2002/08/12 $ $Revision: #6 $
Author:
David Markley
See Also:
HashDecay

Constructor Summary
Utils()
           
 
Method Summary
static void cleanUp()
          Cleans up after the package has been used.
static java.lang.String commonPrefix(java.util.Enumeration en)
          Returns common prefix for an Enumeration of strings.
static java.lang.String commonPrefix(java.util.Vector v)
          Returns common prefix for a Vector of strings.
static java.lang.StringBuffer formatDepotPath(java.lang.String path, java.lang.String pathfmt, java.lang.String filefmt, java.lang.String revfmt, boolean urlencode)
          Breaks up a depot path and formats each level.
static int getChangeFromPath(java.lang.String path)
          Returns the change number portion of a depot path, if there is a valid one found.
static java.util.Enumeration getEnumeration(java.util.Iterator i)
           
static java.lang.String HTMLEncode(java.lang.String str)
          Returns the string encoded for HTML use.
static void initPackage()
          Initializes the package, in order to avoid some arbitrary JVM problems that have been encountered.
static boolean isMSJVM()
          Check to see if the current Java Virtual Machine is made by Microsoft
static boolean isWindows()
          Check to see if the current operating system is a Windows OS
static void main(java.lang.String[] argv)
          Deprecated. Useful for testing, but should not be documented.
static boolean wildPathMatch(java.lang.String wildpath, java.lang.String path)
          Returns true if the path matches the wildpath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

initPackage

public static void initPackage()
Initializes the package, in order to avoid some arbitrary JVM problems that have been encountered. This is a hack and should not have to be done if certain overbearing empires starting with the letter M built a fully compliant JVM.


isMSJVM

public static boolean isMSJVM()
Check to see if the current Java Virtual Machine is made by Microsoft

Returns:
boolean true if the java.vendor property comtains the word 'Microsoft'

isWindows

public static boolean isWindows()
Check to see if the current operating system is a Windows OS

Returns:
boolean true if the os.name property comtains the word 'Windows'

wildPathMatch

public static boolean wildPathMatch(java.lang.String wildpath,
                                    java.lang.String path)
Returns true if the path matches the wildpath. Only perforce wildcards are considered in the wildpath.


HTMLEncode

public static java.lang.String HTMLEncode(java.lang.String str)
Returns the string encoded for HTML use.

> becomes > and < becomes <


commonPrefix

public static java.lang.String commonPrefix(java.util.Vector v)
Returns common prefix for a Vector of strings. This is very useful for determining a commong prefix for a set of paths.


commonPrefix

public static java.lang.String commonPrefix(java.util.Enumeration en)
Returns common prefix for an Enumeration of strings.


getChangeFromPath

public static final int getChangeFromPath(java.lang.String path)
Returns the change number portion of a depot path, if there is a valid one found. Otherwise, it returns -1.


cleanUp

public static void cleanUp()
Cleans up after the package has been used. This stops any running threads and releases any objects for garbage collection.


formatDepotPath

public static java.lang.StringBuffer formatDepotPath(java.lang.String path,
                                                     java.lang.String pathfmt,
                                                     java.lang.String filefmt,
                                                     java.lang.String revfmt,
                                                     boolean urlencode)
                                              throws PerforceException
Breaks up a depot path and formats each level. Each format string takes two arguments. The first is set to the full path to a particular element. The second is set to the short name for the element.

This is extremely useful for setting up links from each component of a path.

Parameters:
path - The path to be formatted.
pathfmt - The format to be used for path elements.
filefmt - The format to be used for the file element.
revfmt - The format to be used for the rev component.
urlencode - Determines if paths are encoded.
Throws:
PerforceException
See Also:
URLEncoder

getEnumeration

public static java.util.Enumeration getEnumeration(java.util.Iterator i)

main

public static void main(java.lang.String[] argv)
Deprecated. Useful for testing, but should not be documented.



Copyright © 2010. All Rights Reserved.