|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eigenbase.xom.XMLUtil
org.eigenbase.xom.XOMUtil
mondrian.olap.Util
public class Util
Utility functions used throughout mondrian. All methods are static.
Nested Class Summary | |
---|---|
static class |
Util.ErrorCellValue
|
static class |
Util.PropertyList
PropertyList is an order-preserving list of key-value
pairs. |
Field Summary | |
---|---|
static java.lang.Object |
EmptyValue
Placeholder which indicates an EMPTY value. |
static int |
JdbcVersion
What version of JDBC? Returns 4 in JDK 1.6 and higher, 3 otherwise. |
static java.lang.String |
nl
|
static java.lang.Object |
nullValue
Placeholder which indicates a value NULL. |
static boolean |
PreJdk15
Whether we are running a version of Java before 1.5. |
static boolean |
Retrowoven
Whether the code base has re-engineered using retroweaver. |
Constructor Summary | |
---|---|
Util()
|
Method Summary | ||
---|---|---|
static void |
addDatabaseTime(long millis)
Adds to the cumulative amount of time spent accessing the database. |
|
static java.util.List<Member> |
addLevelCalculatedMembers(SchemaReader reader,
Level level,
java.util.List<Member> members)
|
|
static
|
append(T[] a,
T o)
Adds an object to the end of an array. |
|
static
|
appendArrays(T[] a0,
T[]... as)
Concatenates one or more arrays. |
|
static
|
areOccurencesEqual(java.util.Collection<T> collection)
Returns whether a collection contains precisely one distinct element. |
|
static void |
assertPostcondition(boolean b)
Checks that a postcondition (declared using the javadoc @post tag) is satisfied. |
|
static void |
assertPostcondition(boolean b,
java.lang.String condition)
Checks that a postcondition (declared using the javadoc @post tag) is satisfied. |
|
static void |
assertPrecondition(boolean b)
Checks that a precondition (declared using the javadoc @pre
tag) is satisfied. |
|
static void |
assertPrecondition(boolean b,
java.lang.String condition)
Checks that a precondition (declared using the javadoc @pre
tag) is satisfied. |
|
static void |
assertTrue(boolean b)
Throws an internal error if condition is not true. |
|
static void |
assertTrue(boolean b,
java.lang.String message)
Throws an internal error with the given messagee if condition is not true. |
|
static
|
badValue(java.lang.Enum<T> anEnum)
Returns an exception indicating that we didn't expect to find this value here. |
|
static java.lang.String |
camelToUpper(java.lang.String s)
Converts a camel-case name to an upper-case name with underscores. |
|
static int |
caseSensitiveCompareName(java.lang.String s,
java.lang.String t)
Compares two names. |
|
static
|
cast(java.util.List<?> list)
Casts a List to a List with a different element type. |
|
static
|
cast(java.util.Set<?> set)
Casts a Set to a Set with a different element type. |
|
static
|
castToIterable(java.lang.Object iterable)
Casts a collection to iterable. |
|
static void |
checkCJResultLimit(long resultSize)
Check the resultSize against the result limit setting. |
|
static
|
commaList(java.lang.String s,
java.util.List<T> list)
Converts a list of a string. |
|
static int |
compareKey(java.lang.Object k1,
java.lang.Object k2)
Returns the result of ((Comparable) k1).compareTo(k2), with special-casing for the fact that Boolean only became comparable in JDK 1.5. |
|
static int |
compareName(java.lang.String s,
java.lang.String t)
Compares two names. |
|
static java.lang.String[] |
convertStackToString(java.lang.Throwable e)
Converts an error into an array of strings, the most recent error first. |
|
static Exp |
createExpr(OlapElement element)
Converts an olap element (dimension, hierarchy, level or member) into an expression representing a usage of that element in an MDX statement. |
|
static java.util.Random |
createRandom(long seed)
Creates a random number generator. |
|
static Validator |
createSimpleValidator(FunTable funTable)
Creates a very simple implementation of Validator . |
|
static UserDefinedFunction |
createUdf(java.lang.Class<? extends UserDefinedFunction> udfClass,
java.lang.String functionName)
Creates a new udf instance from the given udf class. |
|
static long |
dbTimeMillis()
Returns the cumulative amount of time spent accessing the database. |
|
static void |
deprecated(java.lang.String reason)
Deprecated. |
|
static
|
enumSetAllOf(java.lang.Class<E> elementType)
Equivalent to EnumSet.allOf(Class) on JDK 1.5 or later. |
|
static
|
enumSetNoneOf(java.lang.Class<E> elementType)
Equivalent to EnumSet.noneOf(Class) on JDK 1.5 or
later. |
|
static
|
enumSetOf(E first,
E... rest)
Equivalent to EnumSet.of(Enum, Enum[]) on JDK 1.5 or
later. |
|
static boolean |
equal(java.lang.String s,
java.lang.String t,
boolean matchCase)
Tests two strings for equality, optionally ignoring case. |
|
static
|
equalArray(T[] a1,
T[] a2)
Returns whether two arrays have equal contents. |
|
static boolean |
equalName(java.lang.String s,
java.lang.String t)
Returns whether two names are equal. |
|
static boolean |
equals(java.lang.Object s,
java.lang.Object t)
Returns true if two objects are equal, or are both null. |
|
static boolean |
equals(java.lang.String s,
java.lang.String t)
Returns true if two strings are equal, or are both null. |
|
static
|
getAnnotation(java.lang.reflect.Method method,
java.lang.String annotationClassName,
T defaultValue)
Returns an annotation of a particular class on a method. |
|
static java.lang.String |
getErrorMessage(java.lang.Throwable err)
Constructs the message associated with an arbitrary Java error, making up one based on the stack trace if there is none. |
|
static java.lang.String |
getErrorMessage(java.lang.Throwable err,
boolean prependClassName)
Constructs the message associated with an arbitrary Java error, making up one based on the stack trace if there is none. |
|
static Member |
getFirstDescendantOnLevel(SchemaReader reader,
Member parent,
Level level)
returns the first descendant on the level underneath parent. |
|
static int |
getMemberOrdinalInParent(SchemaReader reader,
Member member)
Finds the zero based ordinal of a Member among its siblings. |
|
static int |
hash(int i,
int j)
Combines two integers into a hash code. |
|
static int |
hash(int h,
java.lang.Object o)
Computes a hash code from an existing hash code and an object (which may be null). |
|
static int |
hashArray(int h,
java.lang.Object[] a)
Computes a hash code from an existing hash code and an array of objects (which may be null). |
|
static java.lang.String |
implode(java.util.List<Id.Segment> names)
Converts an array of name parts {"part1", "part2"} into a single string "[part1].[part2]". |
|
static boolean |
isBlank(java.lang.String str)
Copied from commons-lang Checks if a String is whitespace, empty ("") or null. |
|
static boolean |
isEmpty(java.lang.String s)
Returns whether a string is null or empty. |
|
static boolean |
isNull(java.lang.Object o)
|
|
static
|
isSorted(java.util.List<T> list)
Returns whether a list is strictly sorted. |
|
static boolean |
isValidProperty(Member member,
java.lang.String propertyName)
Returns whether a property is valid for a given member. |
|
static
|
lookup(java.lang.Class<E> clazz,
java.lang.String name)
Looks up an enumeration by name, returning null if not valid. |
|
static
|
lookup(java.lang.Class<E> clazz,
java.lang.String name,
E defaultValue)
Looks up an enumeration by name, returning a given default value if not valid. |
|
static OlapElement |
lookup(Query q,
java.util.List<Id.Segment> nameParts)
|
|
static Exp |
lookup(Query q,
java.util.List<Id.Segment> nameParts,
boolean allowProp)
Converts an identifier into an expression by resolving its parts into an OLAP object (dimension, hierarchy, level or member) within the context of a query. |
|
static Exp |
lookup(Query q,
SchemaReader schemaReader,
java.util.List<Id.Segment> nameParts,
boolean allowProp)
Converts an identifier into an expression by resolving its parts into an OLAP object (dimension, hierarchy, level or member) within the context of a query. |
|
static OlapElement |
lookupCompound(SchemaReader schemaReader,
OlapElement parent,
java.util.List<Id.Segment> names,
boolean failIfNotFound,
int category)
|
|
static OlapElement |
lookupCompound(SchemaReader schemaReader,
OlapElement parent,
java.util.List<Id.Segment> names,
boolean failIfNotFound,
int category,
MatchType matchType)
Resolves a name such as '[Products].[Product Department].[Produce]' by resolving the components ('Products', and so forth) one at a time. |
|
(package private) static Cube |
lookupCube(SchemaReader schemaReader,
java.lang.String cubeName,
boolean fail)
Looks up a cube in a schema reader. |
|
static Level |
lookupHierarchyLevel(Hierarchy hierarchy,
java.lang.String s)
Finds a named level in this hierarchy. |
|
static Member |
lookupHierarchyRootMember(SchemaReader reader,
Hierarchy hierarchy,
Id.Segment memberName)
|
|
static Member |
lookupHierarchyRootMember(SchemaReader reader,
Hierarchy hierarchy,
Id.Segment memberName,
MatchType matchType)
Finds a root member of a hierarchy with a given name. |
|
protected static Property |
lookupProperty(Level level,
java.lang.String propertyName)
Finds a member property called propertyName at, or above,
level . |
|
static java.math.BigDecimal |
makeBigDecimalFromDouble(double d)
Make a BigDecimal from a double. |
|
static java.lang.String |
makeFqName(OlapElement parent,
java.lang.String name)
|
|
static java.lang.String |
makeFqName(java.lang.String name)
|
|
static java.lang.String |
makeFqName(java.lang.String parentUniqueName,
java.lang.String name)
|
|
static java.lang.String |
maskVersion(java.lang.String str)
Masks Mondrian's version number from a string. |
|
static java.lang.String |
mdxEncodeString(java.lang.String st)
Encodes string for MDX (escapes ] as ]] inside a name). |
|
static java.lang.RuntimeException |
needToImplement(java.lang.Object o)
Returns an exception which indicates that a particular piece of functionality should work, but a developer has not implemented it yet. |
|
static java.lang.RuntimeException |
newError(java.lang.String message)
Creates a non-internal error. |
|
static java.lang.RuntimeException |
newError(java.lang.Throwable e,
java.lang.String message)
Creates a non-internal error. |
|
static java.lang.RuntimeException |
newInternal(java.lang.String message)
Creates an internal error with a given message. |
|
static java.lang.RuntimeException |
newInternal(java.lang.Throwable e,
java.lang.String message)
Creates an internal error with a given message and cause. |
|
static long |
nonDbTimeMillis()
Returns the system time less the time spent accessing the database. |
|
static java.lang.String |
normalizeName(java.lang.String s)
Generates a normalized form of a name, for use as a key into a map. |
|
static java.util.List<java.lang.String> |
parseCommaList(java.lang.String nameCommaList)
Parses a comma-separated list. |
|
static Util.PropertyList |
parseConnectString(java.lang.String s)
Converts an OLE DB connect string into a Util.PropertyList . |
|
static java.util.List<Id.Segment> |
parseIdentifier(java.lang.String s)
|
|
static java.lang.String |
printMemory()
|
|
static java.lang.String |
printMemory(java.lang.String msg)
|
|
static java.lang.String |
quoteForMdx(java.lang.String val)
Converts a string into a double-quoted string. |
|
static java.lang.String |
quoteMdxIdentifier(java.util.List<Id.Segment> ids)
Return identifiers quoted in [...].[...]. |
|
static void |
quoteMdxIdentifier(java.util.List<Id.Segment> ids,
java.lang.StringBuilder sb)
|
|
static java.lang.String |
quoteMdxIdentifier(java.lang.String id)
Return string quoted in [...]. |
|
static void |
quoteMdxIdentifier(java.lang.String id,
java.lang.StringBuilder buf)
|
|
static java.lang.String |
quotePattern(java.lang.String s)
Returns a literal pattern String for the specified String. |
|
static java.lang.String |
readFully(java.io.Reader rdr,
int bufferSize)
Reads a Reader until it returns EOF and return the contents as a String. |
|
static java.lang.String |
readURL(java.lang.String urlStr)
Read URL and return String containing content. |
|
static java.lang.String |
readURL(java.lang.String urlStr,
java.util.Map<java.lang.String,java.lang.String> map)
Returns the contents of a URL, substituting tokens. |
|
static java.lang.String |
readURL(java.net.URL url)
Returns the contents of a URL. |
|
static java.lang.String |
readURL(java.net.URL url,
java.util.Map<java.lang.String,java.lang.String> map)
Returns the contents of a URL, substituting tokens. |
|
static java.io.InputStream |
readVirtualFile(java.lang.String url)
Gets content via Apache VFS. |
|
static java.lang.StringBuilder |
replace(java.lang.StringBuilder buf,
int start,
java.lang.String find,
java.lang.String replace)
Replaces all occurrences of a string in a buffer with another. |
|
static java.lang.String |
replace(java.lang.String s,
java.lang.String find,
java.lang.String replace)
Returns a string with every occurrence of a seek string replaced with another. |
|
static java.lang.String |
replaceProperties(java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> env)
Replaces tokens in a string. |
|
static java.lang.String |
singleQuoteString(java.lang.String val)
Encloses a value in single-quotes, to make a SQL string value. |
|
static void |
singleQuoteString(java.lang.String val,
java.lang.StringBuilder buf)
Encloses a value in single-quotes, to make a SQL string value. |
|
static java.util.Map<java.lang.String,java.lang.String> |
toMap(java.util.Properties properties)
Converts a Properties object to a string-to-string Map . |
|
static java.net.URL |
toURL(java.io.File file)
Creates a file-protocol URL for the given file. |
|
static java.lang.RuntimeException |
unexpected(java.lang.Enum value)
Returns an exception indicating that we didn't expect to find this value here. |
|
static java.lang.String |
uniquify(java.lang.String name,
int maxLength,
java.util.Collection<java.lang.String> nameList)
Makes a name distinct from other names which have already been used and shorter than a length limit, adds it to the list, and returns it. |
|
static java.lang.String |
unparse(Exp exp)
Converts an expression to a string. |
|
static java.lang.String |
unparse(Query query)
Converts an query to a string. |
|
static java.lang.String |
wildcardToRegexp(java.util.List<java.lang.String> wildcards)
Converts a list of SQL-style patterns into a Java regular expression. |
Methods inherited from class org.eigenbase.xom.XOMUtil |
---|
addChild, addChild, addChildren, addElement, concatenate, createDefaultParser, discard, discard, discard, discard, discard, discard, discard, discard, discard, getFirstInstance, wrapperToXml |
Methods inherited from class org.eigenbase.xom.XMLUtil |
---|
getFirstTagName, printAtt, printAtt, printAtt, printAtt, printPCDATA, printPCDATA, printPCDATA, quoteAtt, quoteAtt, quoteAtt, quoteAtt, quotePCDATA, stringEncodeXML, stringHasXMLSpecials |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String nl
public static final java.lang.Object nullValue
public static final java.lang.Object EmptyValue
public static final boolean PreJdk15
If this variable is true, we will be running retroweaver. Retroweaver
has some problems involving EnumSet
.
public static final int JdbcVersion
public static final boolean Retrowoven
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static boolean isNull(java.lang.Object o)
public static <T> boolean isSorted(java.util.List<T> list)
list
- List
public static java.lang.String mdxEncodeString(java.lang.String st)
public static java.lang.String quoteForMdx(java.lang.String val)
public static java.lang.String quoteMdxIdentifier(java.lang.String id)
public static void quoteMdxIdentifier(java.lang.String id, java.lang.StringBuilder buf)
public static java.lang.String quoteMdxIdentifier(java.util.List<Id.Segment> ids)
public static void quoteMdxIdentifier(java.util.List<Id.Segment> ids, java.lang.StringBuilder sb)
public static boolean equals(java.lang.Object s, java.lang.Object t)
public static <T> boolean equalArray(T[] a1, T[] a2)
T
- Element typea1
- First arraya2
- Second array
public static boolean equals(java.lang.String s, java.lang.String t)
The result is not affected by
the case sensitive option
; if
you wish to compare names, use equalName(String, String)
.
public static boolean equalName(java.lang.String s, java.lang.String t)
case sensitive option
.
Names may be null.
public static boolean equal(java.lang.String s, java.lang.String t, boolean matchCase)
s
- First stringt
- Second stringmatchCase
- Whether to perform case-sensitive match
public static int caseSensitiveCompareName(java.lang.String s, java.lang.String t)
case
sensitive option
.
Names must not be null.
public static int compareName(java.lang.String s, java.lang.String t)
case
sensitive option
.
Names must not be null.
public static java.lang.String normalizeName(java.lang.String s)
MondrianProperties.CaseSensitive
is true, the name unchanged
otherwise.
public static int compareKey(java.lang.Object k1, java.lang.Object k2)
Comparable.compareTo(T)
public static java.lang.String replace(java.lang.String s, java.lang.String find, java.lang.String replace)
public static java.lang.StringBuilder replace(java.lang.StringBuilder buf, int start, java.lang.String find, java.lang.String replace)
buf
- String buffer to act onstart
- Ordinal within find
to start searchingfind
- String to findreplace
- String to replace it with
public static java.util.List<Id.Segment> parseIdentifier(java.lang.String s)
public static java.lang.String implode(java.util.List<Id.Segment> names)
public static java.lang.String makeFqName(java.lang.String name)
public static java.lang.String makeFqName(OlapElement parent, java.lang.String name)
public static java.lang.String makeFqName(java.lang.String parentUniqueName, java.lang.String name)
public static OlapElement lookupCompound(SchemaReader schemaReader, OlapElement parent, java.util.List<Id.Segment> names, boolean failIfNotFound, int category)
public static OlapElement lookupCompound(SchemaReader schemaReader, OlapElement parent, java.util.List<Id.Segment> names, boolean failIfNotFound, int category, MatchType matchType)
schemaReader
- Schema reader, supplies access-control contextparent
- Parent element to search innames
- Exploded compound name, such as {"Products",
"Product Department", "Produce"}failIfNotFound
- If the element is not found, determines whether
to return null or throw an errorcategory
- Type of returned element, a Category
value;
Category.Unknown
if it doesn't matter.parseIdentifier(String)
public static OlapElement lookup(Query q, java.util.List<Id.Segment> nameParts)
public static Exp lookup(Query q, java.util.List<Id.Segment> nameParts, boolean allowProp)
If allowProp
is true, also allows property references
from valid members, for example
[Measures].[Unit Sales].FORMATTED_VALUE
.
In this case, the result will be a ResolvedFunCall
.
q
- Query expression belongs tonameParts
- Parts of the identifierallowProp
- Whether to allow property references
public static Exp lookup(Query q, SchemaReader schemaReader, java.util.List<Id.Segment> nameParts, boolean allowProp)
If allowProp
is true, also allows property references
from valid members, for example
[Measures].[Unit Sales].FORMATTED_VALUE
.
In this case, the result will be a ResolvedFunCall
.
q
- Query expression belongs toschemaReader
- Schema readernameParts
- Parts of the identifierallowProp
- Whether to allow property references
static Cube lookupCube(SchemaReader schemaReader, java.lang.String cubeName, boolean fail)
cubeName
- Cube namefail
- Whether to fail if not found.
public static Exp createExpr(OlapElement element)
public static Member lookupHierarchyRootMember(SchemaReader reader, Hierarchy hierarchy, Id.Segment memberName)
public static Member lookupHierarchyRootMember(SchemaReader reader, Hierarchy hierarchy, Id.Segment memberName, MatchType matchType)
hierarchy
- HierarchymemberName
- Name of root member
public static Level lookupHierarchyLevel(Hierarchy hierarchy, java.lang.String s)
public static int getMemberOrdinalInParent(SchemaReader reader, Member member)
public static Member getFirstDescendantOnLevel(SchemaReader reader, Member parent, Level level)
public static boolean isEmpty(java.lang.String s)
public static java.lang.String singleQuoteString(java.lang.String val)
singleQuoteForSql(null)
yields NULL
;
singleQuoteForSql("don't")
yields 'don''t'
.
public static void singleQuoteString(java.lang.String val, java.lang.StringBuilder buf)
singleQuoteForSql(null)
yields NULL
;
singleQuoteForSql("don't")
yields 'don''t'
.
public static java.util.Random createRandom(long seed)
seed
- Seed for random number generator.
If 0, generate a seed from the system clock and print the value
chosen. (This is effectively non-deterministic.)
If -1, generate a seed from an internal random number generator.
(This is deterministic, but ensures that different tests have
different seeds.)
public static boolean isValidProperty(Member member, java.lang.String propertyName)
member
- MemberpropertyName
- Property name
protected static Property lookupProperty(Level level, java.lang.String propertyName)
propertyName
at, or above,
level
.
public static void deprecated(java.lang.String reason)
public static java.util.List<Member> addLevelCalculatedMembers(SchemaReader reader, Level level, java.util.List<Member> members)
public static java.lang.RuntimeException needToImplement(java.lang.Object o)
public static <T extends java.lang.Enum<T>> java.lang.RuntimeException badValue(java.lang.Enum<T> anEnum)
public static java.lang.String maskVersion(java.lang.String str)
str
- String
public static java.lang.String wildcardToRegexp(java.util.List<java.lang.String> wildcards)
For example, {"Foo_", "Bar%BAZ"} becomes "Foo.|Bar.*BAZ".
wildcards
- List of SQL-style wildcard expressions
public static java.lang.String camelToUpper(java.lang.String s)
For example, camelToUpper("FooBar")
returns "FOO_BAR".
s
- Camel-case string
public static java.util.List<java.lang.String> parseCommaList(java.lang.String nameCommaList)
If a value contains a comma, escape it with a second comma. For
example, parseCommaList("x,y,,z")
returns
{"x", "y,z"}
.
nameCommaList
- List of names separated by commas
public static <T> T getAnnotation(java.lang.reflect.Method method, java.lang.String annotationClassName, T defaultValue)
method
- Method containing annotationannotationClassName
- Name of annotation class to finddefaultValue
- Value to return if annotation is not present
public static <T> java.lang.String commaList(java.lang.String s, java.util.List<T> list)
commaList("foo", Arrays.asList({"a", "b"}))
returns "foo(a, b)".
s
- Prefixlist
- List
public static java.lang.String uniquify(java.lang.String name, int maxLength, java.util.Collection<java.lang.String> nameList)
name
- Suggested name, may not be uniquemaxLength
- Maximum length of generated namenameList
- Collection of names already used
public static <T> boolean areOccurencesEqual(java.util.Collection<T> collection)
collection
- Collection
public static void assertTrue(boolean b)
assert
, but that is a keyword as of JDK 1.4.
public static void assertTrue(boolean b, java.lang.String message)
assert
, but that is a keyword as
of JDK 1.4.
public static java.lang.RuntimeException newInternal(java.lang.String message)
public static java.lang.RuntimeException newInternal(java.lang.Throwable e, java.lang.String message)
public static java.lang.RuntimeException newError(java.lang.String message)
public static java.lang.RuntimeException newError(java.lang.Throwable e, java.lang.String message)
public static java.lang.RuntimeException unexpected(java.lang.Enum value)
value
- Valuepublic static void assertPrecondition(boolean b)
@pre
tag) is satisfied.
b
- The value of executing the conditionpublic static void assertPrecondition(boolean b, java.lang.String condition)
@pre
tag) is satisfied. For example,
void f(String s) { Util.assertPrecondition(s != null, "s != null"); ... }
b
- The value of executing the conditioncondition
- The text of the conditionpublic static void assertPostcondition(boolean b)
@post
tag) is satisfied.
b
- The value of executing the conditionpublic static void assertPostcondition(boolean b, java.lang.String condition)
@post
tag) is satisfied.
b
- The value of executing the conditionpublic static java.lang.String[] convertStackToString(java.lang.Throwable e)
e
- the error; may be null. Errors are chained according to their
cause
.public static java.lang.String getErrorMessage(java.lang.Throwable err)
getErrorMessage(Throwable,boolean)
, but does not print the
class name if the exception is derived from SQLException
or is exactly a Exception
.
public static java.lang.String getErrorMessage(java.lang.Throwable err, boolean prependClassName)
err
- the errorprependClassName
- should the error be preceded by the
class name of the Java exception? defaults to false, unless the error
is derived from SQLException
or is exactly a Exception
public static java.lang.String unparse(Exp exp)
public static java.lang.String unparse(Query query)
public static java.net.URL toURL(java.io.File file) throws java.net.MalformedURLException
java.net.MalformedURLException
public static Util.PropertyList parseConnectString(java.lang.String s)
Util.PropertyList
.
For example, "Provider=MSOLAP; DataSource=LOCALHOST;"
becomes the set of (key, value) pairs {("Provider","MSOLAP"),
("DataSource", "LOCALHOST")}
. Another example is
Provider='sqloledb';Data Source='MySqlServer';Initial
Catalog='Pubs';Integrated Security='SSPI';
.
This method implements as much as possible of the OLE DB connect string syntax
specification. To find what it actually does, take
a look at the mondrian.olap.UtilTestCase
test case.
public static int hash(int i, int j)
public static int hash(int h, java.lang.Object o)
public static int hashArray(int h, java.lang.Object[] a)
public static <T> T[] appendArrays(T[] a0, T[]... as)
Resulting array has same element type as first array. Each arrays may be empty, but must not be null.
a0
- First arrayas
- Zero or more subsequent arrays
public static <T> T[] append(T[] a, T o)
String[]
) as the input array.
a
- Arrayo
- Element
appendArrays(T[], T[]...)
public static long dbTimeMillis()
public static void addDatabaseTime(long millis)
public static long nonDbTimeMillis()
public static Validator createSimpleValidator(FunTable funTable)
Validator
. (Only
useful for resolving trivial expressions.)
public static java.lang.String readFully(java.io.Reader rdr, int bufferSize) throws java.io.IOException
rdr
- Reader to Read.bufferSize
- size of buffer to allocate for reading.
java.io.IOException
public static java.lang.String readURL(java.lang.String urlStr) throws java.io.IOException
urlStr
- actually a catalog URL
java.net.MalformedURLException
java.io.IOException
public static java.lang.String readURL(java.lang.String urlStr, java.util.Map<java.lang.String,java.lang.String> map) throws java.io.IOException
Replaces the tokens "${key}" if "key" occurs in the key-value map.
urlStr
- URL stringmap
- Key/value map
java.net.MalformedURLException
java.io.IOException
public static java.lang.String readURL(java.net.URL url) throws java.io.IOException
url
- URL
java.io.IOException
public static java.lang.String readURL(java.net.URL url, java.util.Map<java.lang.String,java.lang.String> map) throws java.io.IOException
Replaces the tokens "${key}" if "key" occurs in the key-value map.
url
- URLmap
- Key/value map
java.io.IOException
public static java.io.InputStream readVirtualFile(java.lang.String url) throws org.apache.commons.vfs.FileSystemException
url
- String
org.apache.commons.vfs.FileSystemException
public static java.util.Map<java.lang.String,java.lang.String> toMap(java.util.Properties properties)
Properties
object to a string-to-string Map
.
properties
- Properties
public static java.lang.String replaceProperties(java.lang.String text, java.util.Map<java.lang.String,java.lang.String> env)
Replaces the tokens "${key}" if "key" occurs in the key-value map. Otherwise "${key}" is left in the string unchanged.
text
- Source stringenv
- Map of key-value pairs
public static java.lang.String printMemory()
public static java.lang.String printMemory(java.lang.String msg)
public static <T> java.util.Set<T> cast(java.util.Set<?> set)
set
- Set
public static <T> java.util.List<T> cast(java.util.List<?> list)
list
- List
public static <T> java.lang.Iterable<T> castToIterable(java.lang.Object iterable)
Collection
objects do not implement
Iterable
, so this method inserts a casting wrapper. (Since
Iterable does not exist under JDK 1.4, they will have been compiled
under JDK 1.5 or later, then retrowoven to 1.4 class format. References
to Iterable will have been replaced with references to
com.rc.retroweaver.runtime.Retroweaver_
.
Under later JDKs this method is trivial. This method can be deleted when we discontinue support for JDK 1.4.
T
- Element typeiterable
- Object which ought to be iterable
public static <E extends java.lang.Enum<E>> E lookup(java.lang.Class<E> clazz, java.lang.String name)
public static <E extends java.lang.Enum<E>> E lookup(java.lang.Class<E> clazz, java.lang.String name, E defaultValue)
public static <E extends java.lang.Enum<E>> java.util.Set<E> enumSetOf(E first, E... rest)
EnumSet.of(Enum, Enum[])
on JDK 1.5 or
later. Otherwise, returns an ordinary set.
first
- an element that the set is to contain initiallyrest
- the remaining elements the set is to contain initially
java.lang.NullPointerException
- if any of the specified elements are null,
or if rest is nullpublic static <E extends java.lang.Enum<E>> java.util.Set<E> enumSetNoneOf(java.lang.Class<E> elementType)
EnumSet.noneOf(Class)
on JDK 1.5 or
later. Otherwise, returns an ordinary set.
elementType
- the class object of the element type for this enum
setpublic static <E extends java.lang.Enum<E>> java.util.Set<E> enumSetAllOf(java.lang.Class<E> elementType)
EnumSet.allOf(Class)
on JDK 1.5 or later.
Otherwise, returns an ordinary set.
elementType
- the class object of the element type for this enum
setpublic static java.math.BigDecimal makeBigDecimalFromDouble(double d)
d
- the input double
public static java.lang.String quotePattern(java.lang.String s)
Specification as for Pattern.quote(String)
, which was
introduced in JDK 1.5.
s
- The string to be literalized
public static UserDefinedFunction createUdf(java.lang.Class<? extends UserDefinedFunction> udfClass, java.lang.String functionName)
udfClass
- the class to create new instance forfunctionName
- Function name, or null
public static void checkCJResultLimit(long resultSize)
resultSize
- Result limit
ResourceLimitExceededException
public static boolean isBlank(java.lang.String str)
Copied from commons-lang Checks if a String is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false
str
- the String to check, may be null
true
if the String is null, empty or whitespace
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |