public class APIUtil extends Object
APIUtil provides some utilities for JReport server and client.| Modifier and Type | Method and Description |
|---|---|
static String |
addUrlPath(String path1,
String path2)
Adds a path to a path string and the result path string is non-URL-encoded.
|
static String |
addUrlPaths(String path1,
String path2)
Adds a path to a URL address string and the result URL string is URL-encoded.
|
static String |
checkDigitalIDFileAndPassword(InputStream digitalID,
String password)
Checks whether the digital ID file is criterion or not.
|
static boolean |
checkFileNameWithTemplate(String fileName)
Checks if the user file name is valid for FileNameTemplate.
|
static String |
convertToAbsPath(File path,
File root)
Converts the real path of a file to the resource URL path of the report server.
|
static void |
deleteDirectory(String path)
Deletes a specific folder with all files inside (all sub-folders as well) it.
|
static String |
escapeHtmlSpecialChars(String originalString)
Deprecated.
since version 16.1
|
static boolean |
getBoolean(String s)
Parses a boolean string to boolean.
|
static boolean |
getBoolean(String s,
boolean defVal)
Parses a boolean string to boolean.
|
static String[] |
getDateFormats()
Gets the date formats supported by DHTML, Studio and Dashboard.
|
static String |
getDefaultTimeZone()
Gets the default timezone ID.
|
static String |
getDisplayNameOfTask(String taskClass)
Gets the display name through class names of scheduled tasks.
|
static String |
getEncodingDescriptionByName(String strName)
Gets encoding description with specific encoding name.
|
static String |
getEncodingNameByDescription(String strDesc)
Gets encoding name with specific description.
|
static String |
getExtName(String file)
This method returns a file's extension.
|
static String |
getFileNameWithoutDir(String file)
Removes a filename's path.
|
static String |
getLaunchTypeString(int launchType)
Gets the launch type of display string through the launch type of scheduled tasks.
|
static Vector[] |
getLcRelatedFiles(String folder)
Gets internal resource list of an LC object.
|
static String[] |
getLogicalFolderAndName(String fileName)
Returns the logical folder and file name.
|
static String |
getNameWithoutExt(String file)
Removes a filename's extension and path.
|
static String |
getNameWithoutExt(String file,
boolean removeWholeExt)
Removes a filename's extension and path.
|
static String |
getNodeNameWithoutExt(String name,
boolean removeWholeExt)
Removes a node name's extension.
|
static String[] |
getPathAndName(String url)
Gets the path name and its parent path of the url path.
|
static String |
getPrincipalDisplayName(String orgName,
String purePrincipalName)
Returns the display name of principal.
|
static String |
getPublishRptTaskDisplayName(Hashtable ht)
Converts a class name to string that is displayed in a task type column of a schedule table.
|
static Vector[] |
getRptRelatedFiles(String folder)
Gets reports, catalogs and sub-folders in a specific folder.
|
static int |
getScreenResolution()
Returns the screen resolution.
|
static String[] |
getServerDateFormats()
Gets the date formats supported by server.
|
static String[] |
getServerTimeFormats()
Gets the time formats supported by server.
|
static String |
getStackTraceString(Throwable t)
Gets the stack trace string of a Throwable object.
|
static String[] |
getSupportedEncodingDescriptions()
Gets all supported encoding description.
|
static String[] |
getSupportedEncodingNames()
Gets all supported encoding name.
|
static String[][] |
getSupportedEncodings()
Gets all supported encoding.
|
static Object |
getTempValueFromHt(String key)
Returns a certain object from a hashtable according to a key.
|
static String |
getTimeElapseString(long milliSeconds)
Converts milliseconds to display time.
|
static String[] |
getTimeFormats()
Gets the time formats supported by DHTML, Studio and Dashboard.
|
static String[] |
getTimestampFormats()
Gets the timestamp formats supported by DHTML, Studio and Dashboard.
|
static String |
getVirtualResourcePathPrefix(String orgName)
return virtual resource path prefix according to input organization name.
|
static int[] |
getYearMonthDate(Date dt) |
static boolean |
isBelongToOrganization(String principalName)
Check pricipal belongs to a organization or not according to principal name
|
static boolean |
isCatalogFile(String file)
Judges if the file is a catalog file.
|
static boolean |
isLCFile(String file)
Judges if the file is an LC file.
|
static boolean |
isLCResource(String resourcePath)
Checks if the specified server resource path is an LC resource path.
|
static boolean |
isMyFolderPath(String path)
Check if a resource path is under a user's my folder (My Components, My Reports).
|
static boolean |
isOrgFolderPath(String path) |
static boolean |
isReportFile(String file)
Judges if the file is a report file.
|
static boolean |
isRootFolder(String path)
check if a path indicates one of root paths: My Reports, My Components, Public Reports,
Public Components, Organization Reports, Organization Components.
|
static boolean |
isValidEmailAddress(String address)
Checks if the input string is a valild e-mail address.
|
static boolean |
isValidFormat(String format)
Check whether a date/time format is valid.
|
static boolean |
isValidNodeName(String name)
Checks if the input string is a valid node name.
|
static Properties |
makeMailProperty(Properties propMail,
boolean isNormalMail)
Makes APIConst.TAG_JRMAIL or APIConst.TAG_CSMAIL property field by properties of an E-Mail.
|
static double |
parseDouble(String str,
double f)
Parses a double string to double.
|
static int |
parseInt(String str)
Parses an integer string to int.
|
static int |
parseInt(String str,
int defVal)
Parses an integer string to int.
|
static long |
parseLong(String str)
Parses an integer string to long.
|
static long |
parseLong(String str,
int defVal)
Parses a long integer string to long.
|
static long |
parseLong(String str,
long defVal)
Parses a long integer string to long.
|
static Hashtable |
parseParamValues(InputStream input)
Parses parameters from a parameter file input stream.
|
static String[] |
parsePrincipalDisplayName(String principalDisplayName)
Parses principal display name to organization name & principal name.
|
static Properties |
parseQuery(String query)
Parses an HTTP query string into a Properties object.
|
static String[] |
parseUserFromResourcePath(String path)
Parses virtual resource path, get user from the path if the path is under user folders (My Reports, My Components).
|
static String[] |
parseVirtualResourcePath(String path)
Parses virtual resource path to organization name & resource path.
|
static String |
properties2String(Properties props,
String delimiter,
String kvDelimiter)
Print a Properties to a string with specified the delimiter for key-value pairs
and the delimiter for a key value pair
|
static void |
putTempValueToHt(String key,
String value)
Puts a certain value to a temp hashtable.
|
static String |
removeExtName(String file)
Removes a filename's extension.
|
static void |
removeTempValueInHt(String key)
Removes a certain value in a temp hashtable.
|
static <T> T |
requireNonNullElse(T obj,
T defaultObj) |
static String[][] |
sortAsCol(String[][] dataTable,
int colIndex,
int SDirection)
Sorts the objects in String Array based on the special column which does not judge capital and lower.
|
static Vector |
sortAsCol(Vector vectorOfObject,
Vector vectorOfColString,
boolean sortDirection)
Sorts the objects in vector based on the special column which does not judge capital and lower.
|
static Properties |
string2Properties(String str,
String delimiter,
String kvDelimiter)
Parse a string which likes "key1:val1, key2:val2" to a Properties.
|
static String |
toDateTimeString(Date dt,
TimeZone tz)
Converts a Date object to string with the format "EEE MMM d HH:mm:ss z yyyy".
|
static String |
toSortableWinDateString(Date date)
Converts a Date object to Windows style date string with the format "MM'/'dd'/'yy HH:mm".
|
static String |
toWinDateSecondString(Date date)
Converts a Date object to Windows style date string with the format "MM/dd/yy h:mm:ss a".
|
static String |
toWinDateString(Date date)
Converts a Date object to Windows style date string with the format "MM/dd/yy h:mm a".
|
static String |
toWinDateStringShowing(Date date)
Converts a Date object to Windows style date string with the format "MMM dd, yyyy".
|
static void |
transferJRMailProperties(Properties propMail)
Deprecated.
|
static String |
VectorToURLEncodedString(Vector v)
Gets the HTTP query string from a Vector.
|
static String |
writeFileToString(File strFile)
Reads a file content and returns the content string.
|
public static int parseInt(String str)
str - The integer string.public static int parseInt(String str, int defVal)
str - The integer string.defVal - The default int value.public static long parseLong(String str)
str - The long integer string.public static long parseLong(String str, int defVal)
str - The long integer string.defVal - The default int value.public static long parseLong(String str, long defVal)
str - The long integer string.defVal - The default long value.public static double parseDouble(String str, double f)
str - The double string.defVal - The default double value.public static boolean getBoolean(String s)
s - The boolean string.public static boolean getBoolean(String s, boolean defVal)
s - The boolean string.defVal - The default boolean value.public static String getDefaultTimeZone()
public static String getStackTraceString(Throwable t)
t - The Throwable object.public static String toDateTimeString(Date dt, TimeZone tz)
dt - The Date object.tz - The timezone.public static String toWinDateString(Date date)
date - The Date object.public static String toSortableWinDateString(Date date)
date - The Date object.public static String toWinDateStringShowing(Date date)
date - The Date object.public static String toWinDateSecondString(Date date)
date - The Date object.public static String getTimeElapseString(long milliSeconds)
milliSeconds - The time elapsed in milliseconds.public static String getLaunchTypeString(int launchType)
launchType - The launch type of scheduled tasks.public static String getDisplayNameOfTask(String taskClass)
taskClass - The class name of scheduled tasks.public static Hashtable parseParamValues(InputStream input) throws IOException
input - The parameter file input stream.IOException - if an IOException occurs.public static String addUrlPath(String path1, String path2)
path1 - The path string.path2 - The path that will be appended to the path1.public static String addUrlPaths(String path1, String path2)
path1 - The URL address string.path2 - The path that will be appended to the URL address.public static String convertToAbsPath(File path, File root)
path - The file.root - The server root dir.public static String[] getPathAndName(String url)
url - The URL path.public static String VectorToURLEncodedString(Vector v)
v - The Vector.public static void transferJRMailProperties(Properties propMail)
propMail - The properties of an e-mail.public static Properties makeMailProperty(Properties propMail, boolean isNormalMail)
propMail - The properties of an e-mail.isNormalMail - Specifies if it is a normal e-mail(false: using APIConst.TAG_JRMAIL; true: using APIConst.TAG_CSMAIL).public static String[][] getSupportedEncodings()
public static String[] getSupportedEncodingNames()
public static String[] getSupportedEncodingDescriptions()
public static String getEncodingNameByDescription(String strDesc)
strDesc - the encoding description.public static String getEncodingDescriptionByName(String strName)
strName - the encoding name.public static String getExtName(String file)
file - String of the source file name.public static String removeExtName(String file)
file - String of the source file name.public static String getNameWithoutExt(String file)
file - String of the source file name.public static String getNameWithoutExt(String file, boolean removeWholeExt)
file - String of the source file name.removeWholeExt - For some recognized file type, if the value is true,
removes the whole extension, otherwise removes the extension after the last dot.
For example, test.cat.xml. If the value is true, returns test; if the value is false,
returns test.cat.public static String getNodeNameWithoutExt(String name, boolean removeWholeExt)
name - String of the node name.removeWholeExt - For some recognized file type, if the value is true,
removes the whole extension, otherwise removes the extension after the last dot.
For example, test.cat.xml. If the value is true, returns test; if the value is false,
returns test.cat.public static String getFileNameWithoutDir(String file)
file - String of the source file name.public static boolean checkFileNameWithTemplate(String fileName)
fileName - The user file name.public static String writeFileToString(File strFile)
strFile - The file is read.public static Properties parseQuery(String query)
query - The HTTP query string.public static String escapeHtmlSpecialChars(String originalString)
"&" to represent the & sign.
"<" to represent the < sign.
">" to represent the > sign.
"" to represent the " mark.
originalString - Original string.public static Vector sortAsCol(Vector vectorOfObject, Vector vectorOfColString, boolean sortDirection)
vectorOfObject - The vector of the sorting object.vectorOfColString - The vector of the column which is sorted as.sortDirection - The direction of the sorting. False is ascending; true is descending.public static String[][] sortAsCol(String[][] dataTable, int colIndex, int SDirection)
dataTable - The array of the sorting object.colIndex - The number of the column which is sorted as.SDirection - The direction of the sorting. 0 is ascending; 1 is descending.public static String getPublishRptTaskDisplayName(Hashtable ht)
ht - Properties of tasks.public static boolean isValidEmailAddress(String address)
address - The input string to be tested.public static boolean isValidNodeName(String name)
name - The string to be tested.public static int[] getYearMonthDate(Date dt)
public static void deleteDirectory(String path) throws SecurityException
path - The full path of the file or folder which will be deleted.SecurityExceptionpublic static Vector[] getRptRelatedFiles(String folder) throws SecurityException
folder - The full path of the folder.SecurityExceptionpublic static Vector[] getLcRelatedFiles(String folder) throws Exception
folder - The file path of LC.Exceptionpublic static boolean isReportFile(String file)
file - The full path of the file.public static boolean isCatalogFile(String file)
file - The full path of the file.public static boolean isLCFile(String file)
file - The full path of the file.public static String[] getLogicalFolderAndName(String fileName)
the - specific file name.public static void putTempValueToHt(String key, String value)
key - The key.value - The certain value.public static Object getTempValueFromHt(String key)
key - The key.public static void removeTempValueInHt(String key)
key - The key.public static String checkDigitalIDFileAndPassword(InputStream digitalID, String password)
digitalID - The input stream of the digital ID file .password - The digital id file open password.public static int getScreenResolution()
public static boolean isLCResource(String resourcePath)
resourcePath - The specified server resource path.public static String[] getServerDateFormats()
public static String[] getServerTimeFormats()
public static String[] getDateFormats()
public static String[] getTimeFormats()
public static String[] getTimestampFormats()
public static boolean isValidFormat(String format)
public static String[] parsePrincipalDisplayName(String principalDisplayName)
principalDisplayName - the user|role|group dispaly name, for example: orgname\userNamepublic static boolean isBelongToOrganization(String principalName)
principalName - the user|role|group dispaly name, for example: orgname\userNamepublic static String getPrincipalDisplayName(String orgName, String purePrincipalName)
orgName - purePrincipalName - orgName\purePrincipalName, otherwise return purePrincipalNamepublic static String getVirtualResourcePathPrefix(String orgName)
orgName - /<orgName>public static String[] parseVirtualResourcePath(String path)
path - the virtual resource path, for example: <org1>/folder1public static String[] parseUserFromResourcePath(String path)
path - the resource path.path
is not under user folder,public static boolean isMyFolderPath(String path)
path - the resource path.public static boolean isRootFolder(String path)
path - resource pathpublic static Properties string2Properties(String str, String delimiter, String kvDelimiter)
str - delimiter - The delimiter for splitting multiple key-value pair.kvDelimiter - The delimiter for splitting key and valuepublic static String properties2String(Properties props, String delimiter, String kvDelimiter)
props - delimiter - The delimiter for splitting multiple key-value pair.kvDelimiter - The delimiter for splitting key and valuepublic static <T> T requireNonNullElse(T obj,
T defaultObj)
public static boolean isOrgFolderPath(String path)
© insightsoftware. All rights reserved.