ilog.views.appframe.util
Class IlvUtil

java.lang.Object
  extended by ilog.views.appframe.util.IlvUtil

public class IlvUtil
extends Object

Utility class that gathers useful static methods.


Method Summary
static String AbbreviatePathName(String pathname, IlvApplication application, int maxCharacterCount, boolean atLeastFilename)
          Abbreviates a file name string to a string containing a specified number of characters.
static Object[] AddToArray(Object[] src, Object object)
          Adds the object in the src array.
static Object[] AddToArray(Object[] src, Object object, int index)
          Adds the object in the src array at the specified index.
static Object[] CopyArray(Object[] src)
          Makes a copy of the specified array of objects.
static Color DecodeColor(String s)
          Decodes the specified string to a color.
static Font DecodeFont(String s)
          Decodes the specified string to a font.
static String EncodeColor(Color color)
          Encodes the specified color.
static String EncodeFont(Font font)
          Encodes the specified font.
static String GetFileExtension(String filename)
          Returns the extension of the specified file name.
static String GetFileName(String pathname)
          Returns the file name of the specified pathname.
static String GetFileName(URL url)
          Returns the file name of the specified file URL.
static int GetMinorVersion()
          Deprecated. Please use IlvFrameworkProduct.getMinorVersion() instead.
static String GetRelativePath(String p1, String p2)
          Calculates the relative path expression that defines the specified pathname p1 relative to the specified p2 directory path.
static int GetVersion()
          Deprecated. Please use IlvFrameworkProduct.getVersion() instead.
static int IndexOf(Object[] src, Object object)
          Gets the index of the specified object in the src array of objects.
static boolean IsWhitespace(String s)
          Determines whether the specified string is composed of white characters.
static Object[] RemoveFromArray(Object[] src, int index)
          Removes the object at the index in the src array.
static Object[] RemoveFromArray(Object[] src, Object object)
          Removes the object from the src array.
static Object[] SetElementAt(Object[] src, Object object, int index)
          Sets the object at the specified index in the src array of objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

AddToArray

public static Object[] AddToArray(Object[] src,
                                  Object object,
                                  int index)
Adds the object in the src array at the specified index.

Returns:
The new array containing the objects of the src array plus the specified object.

AddToArray

public static Object[] AddToArray(Object[] src,
                                  Object object)
Adds the object in the src array.

Returns:
The new array containing the objects of the src array plus the specified object.

RemoveFromArray

public static Object[] RemoveFromArray(Object[] src,
                                       int index)
Removes the object at the index in the src array.

Parameters:
src - The array of objects to remove an object from.
index - The index of the object to remove.
Returns:
The new array containing the objects within the src array without the object at the specified index.

RemoveFromArray

public static Object[] RemoveFromArray(Object[] src,
                                       Object object)
Removes the object from the src array.

Parameters:
src - The array of objects to remove the object from.
object - The object to remove.
Returns:
The new array containing the objects within the src array without the object. If the specified object was not contained in the src array, the src is returned.

IndexOf

public static int IndexOf(Object[] src,
                          Object object)
Gets the index of the specified object in the src array of objects.

Returns:
The index of the specified object in the src array of objects; -1 if this object is not contained in the array.

SetElementAt

public static Object[] SetElementAt(Object[] src,
                                    Object object,
                                    int index)
Sets the object at the specified index in the src array of objects.

Parameters:
src - The array of objects to set an element to or null.
object - The object to set.
index - The index to set the object at.
Returns:
The specified src array of objects, if the specified index is lower than the length of this array. Otherwise, a new array of objects is created and returned. This new array has a length equal to index + 1. The first src.length objects are the objects specified in the src array. The objects at the index from src.length to index - 1 are null and the object at the index is the specified object.

CopyArray

public static Object[] CopyArray(Object[] src)
Makes a copy of the specified array of objects.

Parameters:
src - The array of objects to copy.
Returns:
A new array of objects containing the same objects as the specified array.

AbbreviatePathName

public static String AbbreviatePathName(String pathname,
                                        IlvApplication application,
                                        int maxCharacterCount,
                                        boolean atLeastFilename)
Abbreviates a file name string to a string containing a specified number of characters.

For example, the string subdir1/subdir2/subdir3/file.txt will be abbreviated to the strings:

Parameters:
pathname - The pathname to truncate.
application - The application to get the abbreviation format from. If it is null, the abbreviation format will be ...{0}.
maxCharacterCount - The maximum number of characters allowed for the abbreviated string. If atLeastFilename is true, the resulting string can exceed the maxCharacterCount value.
atLeastFilename - If true, the resulting string can exceed the maximum number of characters allowed to contain the file name of the specified pathname. Otherwise, the returned string never exceeds the maximum number of characters allowed.
Returns:
The abbreviated pathname string.

GetFileName

public static String GetFileName(String pathname)
Returns the file name of the specified pathname.

Returns:
The file name.

GetRelativePath

public static String GetRelativePath(String p1,
                                     String p2)
Calculates the relative path expression that defines the specified pathname p1 relative to the specified p2 directory path.

Parameters:
p1 - The pathname to return a relative path from.
p2 - The directory path that the returned relative path is based on.
Returns:
The relative path.

GetFileName

public static String GetFileName(URL url)
Returns the file name of the specified file URL.

Parameters:
url - The URL to get the file name from.
Returns:
The file name.

GetFileExtension

public static String GetFileExtension(String filename)
Returns the extension of the specified file name.

Parameters:
filename - The file name to retrieve the extension from.
Returns:
The file extension of the specified file name.

IsWhitespace

public static boolean IsWhitespace(String s)
Determines whether the specified string is composed of white characters. A character is considered to be a white character if Character.isWhitespace() returns true for this character.

Parameters:
s - The string to test.
Returns:
true if the specified string is composed of white characters; false otherwise.

EncodeColor

public static String EncodeColor(Color color)
Encodes the specified color.

Parameters:
color - The color to get a string representation from.
Returns:
The string representation of the specified color.
See Also:
DecodeColor(java.lang.String)

DecodeColor

public static Color DecodeColor(String s)
Decodes the specified string to a color.

Parameters:
s - The string to decode.
Returns:
The color represented in the specified string or null, if the specified string does not contain a color representation.
See Also:
EncodeColor(java.awt.Color)

EncodeFont

public static String EncodeFont(Font font)
Encodes the specified font.

Parameters:
font - The font to encode.
Returns:
The string representation of the specified font.
See Also:
DecodeFont(java.lang.String)

DecodeFont

public static Font DecodeFont(String s)
Decodes the specified string to a font.

Parameters:
s - The string to decode.
Returns:
The font represented in the specified string or null if the specified string does not contain a font representation.
See Also:
EncodeFont(java.awt.Font)

GetVersion

public static final int GetVersion()
Deprecated. Please use IlvFrameworkProduct.getVersion() instead.

Returns the version number.


GetMinorVersion

public static final int GetMinorVersion()
Deprecated. Please use IlvFrameworkProduct.getMinorVersion() instead.

Returns the minor version number.



Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.