Class Olap4jUtil
This class, and this package as a whole, are part of the olap4j library but the methods are not part of the public olap4j API. The classes exist for the convenience of implementers of olap4j drivers, but their specification and implementation may change at any time.
Applications which use the API in this package will not be portable across multiple versions of olap4j. We encourage implementors of drivers to use classes in this package, but not writers of applications.
- Since:
- Dec 12, 2007
- Author:
- jhyde
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
Whether we are running a version of Java before 1.5.static final boolean
Whether the code base has re-engineered using retroweaver. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Converts a camel-case name to an upper-case name with underscores.static <T> List
<T> Casts a List to a List with a different element type.static <T> Set
<T> Casts a Set to a Set with a different element type.static <T> NamedList
<T> Casts a NamedList to a NamedList with a different element type.static void
discard
(boolean b) static void
discard
(byte b) static void
discard
(char c) static void
discard
(double v) static void
discard
(float v) static void
discard
(int i) static void
discard
(long l) static void
discard
(short i) static void
static <T> NamedList
<T> enumSetAllOf
(Class<E> elementType) Equivalent toEnumSet.allOf(Class)
on JDK 1.5 or later.enumSetNoneOf
(Class<E> elementType) Equivalent toEnumSet.noneOf(Class)
on JDK 1.5 or later.enumSetOf
(E first, E... rest) Equivalent toEnumSet.of(Enum, Enum[])
on JDK 1.5 or later.static <T> boolean
equal
(T t1, T t2) Returns true if two objects are equal, or are both null.static <K,
V> Map <K, V> Returns a hashmap with given contents.static RuntimeException
Returns an exception which indicates that a particular piece of functionality should work, but a developer has not implemented it yet.static String
parseFormattedCellValue
(String formattedValue, Map<String, String> map) Parses a formatted cell values.parseUniqueName
(String uniqueName) Parses a unique name.static String
Returns a literal pattern String for the specified String.static StringBuilder
replace
(StringBuilder buf, int start, String find, String replace) Replaces all occurrences of a string in a buffer with another.static String
Returns a string with every occurrence of a seek string replaced with another.static String
stringArrayToString
(String[] array) Converts the contents of an array of strings to a proper String representation.toMap
(Properties properties) Converts a Properties object to a Map with String keys and values.static AssertionError
unexpected
(Enum value) Returns an exception indicating that we didn't expect to find this value here.static <T> NamedList
<T> unmodifiableNamedList
(NamedList<T> list) Returns an unmodifiable view of the specified list.static String
wildcardToRegexp
(List<String> wildcards) Converts a list of SQL-style patterns into a Java regular expression.
-
Field Details
-
PreJdk15
public static final boolean PreJdk15Whether we are running a version of Java before 1.5.If this variable is true, we will be running retroweaver. Retroweaver has some problems involving
EnumSet
. -
Retrowoven
public static final boolean RetrowovenWhether the code base has re-engineered using retroweaver. If this is the case, some functionality is not available.
-
-
Constructor Details
-
Olap4jUtil
public Olap4jUtil()
-
-
Method Details
-
discard
public static void discard(boolean b) -
discard
public static void discard(byte b) -
discard
public static void discard(char c) -
discard
public static void discard(double v) -
discard
public static void discard(float v) -
discard
public static void discard(int i) -
discard
public static void discard(long l) -
discard
-
discard
public static void discard(short i) -
cast
Casts a Set to a Set with a different element type.- Parameters:
set
- Set- Returns:
- Set of desired type
-
cast
Casts a List to a List with a different element type.- Parameters:
list
- List- Returns:
- List of desired type
-
cast
Casts a NamedList to a NamedList with a different element type.- Parameters:
list
- Named list- Returns:
- Named list of desired type
-
mapOf
Returns a hashmap with given contents.Use this method in initializers. Type parameters are inferred from context, and the contents are initialized declaratively. For example,
Map<String, Integer> population =
Olap4jUtil.mapOf(
"UK", 65000000,
"USA", 300000000);- Type Parameters:
K
- Key typeV
- Value type- Parameters:
key
- First keyvalue
- First valuekeyValues
- Second and sequent key/value pairs- Returns:
- Map with given contents
- See Also:
-
toMap
Converts a Properties object to a Map with String keys and values.- Parameters:
properties
- Properties- Returns:
- Map backed by the given Properties object
-
unexpected
Returns an exception indicating that we didn't expect to find this value here.- Parameters:
value
- Value- Returns:
- an AssertionError which can be thrown
-
equal
public static <T> boolean equal(T t1, T t2) Returns true if two objects are equal, or are both null.- Parameters:
t1
- First valuet2
- Second value- Returns:
- Whether values are both equal or both null
-
replace
Returns a string with every occurrence of a seek string replaced with another.- Parameters:
s
- String to act onfind
- String to findreplace
- String to replace it with- Returns:
- The modified string
-
replace
Replaces all occurrences of a string in a buffer with another.- Parameters:
buf
- String buffer to act onstart
- Ordinal withinfind
to start searchingfind
- String to findreplace
- String to replace it with- Returns:
- The string buffer
-
wildcardToRegexp
Converts a list of SQL-style patterns into a Java regular expression.For example, {"Foo_", "Bar%BAZ"} becomes "Foo.|Bar.*BAZ".
- Parameters:
wildcards
- List of SQL-style wildcard expressions- Returns:
- Regular expression
-
quotePattern
Returns a literal pattern String for the specified String.Specification as for
Pattern.quote(String)
, which was introduced in JDK 1.5.- Parameters:
s
- The string to be literalized- Returns:
- A literal string replacement
-
camelToUpper
Converts a camel-case name to an upper-case name with underscores.For example,
camelToUpper("FooBar")
returns "FOO_BAR".- Parameters:
s
- Camel-case string- Returns:
- Upper-case string
-
needToImplement
Returns an exception which indicates that a particular piece of functionality should work, but a developer has not implemented it yet.- Parameters:
o
- Object operation was called on, perhaps indicating the subtype where a virtual method needs to be implemented- Returns:
- an exception which can be thrown
-
parseUniqueName
Parses a unique name.For example, uniqueNameToStringArray("[foo].[bar]") returns
["foo", "bar"]
.- Parameters:
uniqueName
- Unique name- Returns:
- Parsed unique name
- See Also:
-
stringArrayToString
Converts the contents of an array of strings to a proper String representation.- Parameters:
array
- Array of strings- Returns:
- string representation of the array
-
emptyNamedList
-
unmodifiableNamedList
Returns an unmodifiable view of the specified list. This method allows modules to provide users with "read-only" access to internal lists. Query operations on the returned list "read through" to the specified list, and attempts to modify the returned list, whether direct or via its iterator, result in an UnsupportedOperationException.The returned list will be serializable if the specified list is serializable. Similarly, the returned list will implement
RandomAccess
if the specified list does.The equivalent of
Collections.unmodifiableList(java.util.List)
.- Parameters:
list
- the list for which an unmodifiable view is to be returned.- Returns:
- an unmodifiable view of the specified list.
-
enumSetOf
Equivalent toEnumSet.of(Enum, Enum[])
on JDK 1.5 or later. Otherwise, returns an ordinary set.- Parameters:
first
- an element that the set is to contain initiallyrest
- the remaining elements the set is to contain initially- Returns:
- an enum set initially containing the specified elements
- Throws:
NullPointerException
- if any of the specified elements are null, or if rest is null
-
enumSetNoneOf
Equivalent toEnumSet.noneOf(Class)
on JDK 1.5 or later. Otherwise, returns an ordinary set.- Parameters:
elementType
- the class object of the element type for this enum set- Returns:
- an empty enum set
-
enumSetAllOf
Equivalent toEnumSet.allOf(Class)
on JDK 1.5 or later. Otherwise, returns an ordinary set.- Parameters:
elementType
- the class object of the element type for this enum set- Returns:
- an enum set containing all elements of the given enum class
-
parseFormattedCellValue
Parses a formatted cell values.There is a customary way of including formatting infornation in cell values (started with Microsoft OLAP Services, and continued by JPivot and now Pentaho Analyzer). This method parses out the formatted value that should be displayed on the screen and also any properties present.
Examples:
- "$123" no formatting information
- "|$123|style=red|" print in red style
- "|$123|style=red|arrow=up|" print in red style with an up arrow
Properties
Name Value Description style red|green|yellow renders the Member in that color link a url creates a hyperlink on the member arrow up|down|blank paints an arrow image image a uri. If the uri starts with "/" the context name will be prepended paints image - Parameters:
formattedValue
- Formatted cell valuemap
- Map into which to place (property, value) pairs- Returns:
- Formatted cell value with properties removed
-