Perforce

com.perforce.api
Class Utils

java.lang.Object
  |
  +--com.perforce.api.Utils

public final class Utils
extends Object

Class that contains static utility methods.

Version:
$Date: 2002/08/05 $ $Revision: #8 $
Author:
David Markley
See Also:
HashDecay

Constructor Summary
Utils()
           
 
Method Summary
static void cleanUp()
          Cleans up after the package has been used.
static String commonPrefix(Enumeration en)
          Returns common prefix for an Enumeration of strings.
static String commonPrefix(Vector v)
          Returns common prefix for a Vector of strings.
static StringBuffer formatDepotPath(String path, String pathfmt, String filefmt, String revfmt, boolean urlencode)
          Breaks up a depot path and formats each level.
static int getChangeFromPath(String path)
          Returns the change number portion of a depot path, if there is a valid one found.
static Enumeration getEnumeration(Iterator i)
           
static String HTMLEncode(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 boolean wildPathMatch(String wildpath, 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

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.

commonPrefix

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

commonPrefix

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

formatDepotPath

public static StringBuffer formatDepotPath(String path,
                                           String pathfmt,
                                           String filefmt,
                                           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.
See Also:
URLEncoder

getChangeFromPath

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

getEnumeration

public static Enumeration getEnumeration(Iterator i)

HTMLEncode

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

> becomes > and < becomes <


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(String wildpath,
                                    String path)
Returns true if the path matches the wildpath. Only perforce wildcards are considered in the wildpath.

Perforce

Copyright © 2001, Perforce Software, All rights reserved.