1 |
interface ICallback |
public interface |
package com.tek271.util |
An interface that allows executing a callback method with a parameter. |
2 |
interface IExecutable |
public interface |
package com.tek271.util |
An interface that allows executing a method and returning a success/failed code.
|
3 |
class Printf |
public |
package com.tek271.util |
Different overloaded printf methods. Not as extensive as Java 1.5. Very handy for building dynamic SQL statements or error messages. |
4 |
class CacheItem |
|
package com.tek271.util.cache |
implements com.tek271.util.cache.ICacheItem |
Encapsulates an item in the cache. Note that this class has a package scope and cannot be accessed from outside the package. |
5 |
class CacheStore |
|
package com.tek271.util.cache |
implements com.tek271.util.cache.ICacheStore |
Encapsulates a caches store with a LRU and TTL removal policy, all methods of this class are synchronized. A store is uniquly identified by its name. Each store has a maximum size of items and a Time-To-Live (TTL) in seconds for its items.
To create a cache store use the StoreFactory.createStore() static method.
|
6 |
interface ICacheItem |
interface |
package com.tek271.util.cache |
An interface to represent a cached item. |
7 |
interface ICacheStore |
public interface |
package com.tek271.util.cache |
An interface to represent a cache store. |
8 |
class StoreFactory |
public |
package com.tek271.util.cache |
Contains static methods to create/access/remove a cache store. Cache stores are keyed by either User:StoreName or just StoreName. Note that this key is global per JVM, i.e. In the same JVM, two classes can access the same cache store by the same key value.
Warning 1: When two classes access the same store/key, one can modify a cached value that the other may use. Cached objects are available to all classes in the JVM. If you are concerned about this issue, store only immutable objects in the store.
Warning 2: Some objects have restrictions on how to read them, for example, the JDBC ResultSet after fully reading it, requires that you call the first() method in order to read it again. (Assuming you have the right JDBC driver)
|
9 |
class AbstractKey |
public abstract |
package com.tek271.util.cache.key |
implements com.tek271.util.cache.key.IKey, java.io.Serializable |
Implements th IKey interface, key classes should extend this class and implement the methods: getPart(int), setPart(int, String), compare(IKey, IKey). |
10 |
interface IKey |
public interface |
package com.tek271.util.cache.key |
implements java.lang.Comparable, java.util.Comparator |
Encapsulate a key to a cache store. The key can consist of 1 or more string parts. |
11 |
class Key1 |
public |
package com.tek271.util.cache.key |
extends com.tek271.util.cache.key.AbstractKey |
A key that consists of one part. |
12 |
class Key2 |
public |
package com.tek271.util.cache.key |
extends com.tek271.util.cache.key.AbstractKey |
A key that consists of two parts. |
13 |
class KeyN |
public |
package com.tek271.util.cache.key |
extends com.tek271.util.cache.key.AbstractKey |
A key that consists of N parts, where N is determined when you create an instance of KeyN. |
14 |
class CircularFifoOfLong |
public |
package com.tek271.util.collections |
Code adapted from org.apache.commons.collections.buffer.CircularFifoBuffer. CircularFifoBuffer is a first in first out buffer with a fixed size that replaces its oldest element if full.
The removal order of a CircularFifoBuffer is based on the insertion order; elements are removed in the same order in which they were added. The iteration order is the same as the removal order.
The add(Object), remove() and get() operations all perform in constant time. All other operations perform in linear time or worse.
Note that this implementation is not synchronized. The following can be used to provide synchronized access to yourCircularFifoBuffer :
Buffer fifo = BufferUtils.synchronizedBuffer(new CircularFifoBuffer());
|
15 |
class CollectionUtility |
public |
package com.tek271.util.collections |
extends CollectionUtils |
Different collections utility methods. Extends the Jakarta CollectionUtils class. |
16 |
class NotifyingCollection |
public |
package com.tek271.util.collections |
implements java.util.Collection |
A collection implementation that notifies when items are added or deleted. It decorates another collection be making it notifying. |
17 |
class ArrayUtilities |
public |
package com.tek271.util.collections.array |
extends ArrayUtils |
Generic array methods including different overloaded indexOf() and concat() methods. |
18 |
class AbstractGraphStructuredStackNode |
public abstract |
package com.tek271.util.collections.graph |
implements com.tek271.util.collections.graph.IGraphStructuredStackNode |
Implements IGraphStructuredStackNode which abstracts a Graph-structured Stack (GS) node. A GS is a directed acyclic graph where each directed path is considered a stack. You can think of a GS as a structure similar to a tree structure with the exception that a node can have more than one parent. See wikipedia for more info on GS. |
19 |
class GraphStructuredStackNode |
public |
package com.tek271.util.collections.graph |
extends com.tek271.util.collections.graph.AbstractGraphStructuredStackNode |
A node that has a key and contents. |
20 |
class GssUtils |
public |
package com.tek271.util.collections.graph |
Helper static methods for graph handling. |
21 |
class GssUtils.GraphEntry |
public static |
package com.tek271.util.collections.graph |
Encapsulates (key, contents, parentKey) of a graph entry, a list of this object can be used to construct a graph using the GssUtils.createGraph() method. |
22 |
interface GssUtils.IGssNodeFactory |
public static interface |
package com.tek271.util.collections.graph |
provides a method to create a IGraphStructuredStackNode object |
23 |
interface IGraphNode |
public interface |
package com.tek271.util.collections.graph |
Abstracts a node in a graph. The node has a key and contents. This interface does not enforce any restrictions on the keys or contents. |
24 |
interface IGraphStructuredStackNode |
public interface |
package com.tek271.util.collections.graph |
implements com.tek271.util.collections.graph.IGraphNode |
Abstracts a Graph-structured Stack (GS) node. A GS is a directed acyclic graph where each directed path is considered a stack. You can think of a GS as a structure similar to a tree structure with the exception that a node can have more than one parent. See wikipedia for more info on GS.
Notice that this interface extends the IGraphNode interface.
Each node consists of the following:
- Key
- Contents
- List of its children. Each child is an IGraphStructuredStackNode object. Children will have distinct keys.
- List of its parents. Each parent is an IGraphStructuredStackNode object. A node CAN have more than one parents with the same key. However, the list of parents will not contain the same parent node more than once.
|
25 |
class MapOfGraphNode |
public |
package com.tek271.util.collections.graph |
extends java.util.HashMap |
A map of IGraphNode objects. The key of the map is the node's key, and the value is the node itself. |
26 |
interface ILongIterator |
public interface |
package com.tek271.util.collections.iterator |
implements java.util.Iterator |
27 |
class NotifyingIterator |
public |
package com.tek271.util.collections.iterator |
implements java.util.Iterator |
Decorate an Iterator such that remove operations will cause a callback through aRemoveNotifier.execute(). |
28 |
class ListOfString |
public |
package com.tek271.util.collections.list |
extends java.util.ArrayList |
Encapsulates a list whose items are String objects. This class extends the ArrayList class. Some interesting features are:
- Can read/write to a text file where each line is an item in the list.
- Can populate from a page at a given URL where each line is an item in the list.
- Items can be in the form:
name=value . With methods to access by name.
- Many different indexOf() methods.
- Intersection/Difference/Merge two lists.
- Sort items of the list.
|
29 |
class RowList |
public |
package com.tek271.util.collections.list |
implements java.io.Serializable |
A RowList represents a growable table of data. A row within the RowList can contain many columns, however, each row in the RowList will contain the same number of columns. A column within a RowList consists of a column name and a column value.
A RowList can be populated from a Map, an array of Objects, or a List by invoking the appropriate add method.
The RowList class provides getXXX methods for retrieving column values from a row. Values can be retrieved using either the index number of the row, which returns a Map where the key is the column name and the value is the column value, or by supplying the index number and the column name. Rows are numbered from 0.
For the getXXX methods, the RowList attempts to convert the underlying data to the Java type specified in the XXX part of the getXXX method and returns a suitable Java value.
When a getXXX method is called with a column name and several columns have the same name, the value of the first matching column will be returned.
|
30 |
class RowListComparator |
|
package com.tek271.util.collections.list |
implements java.util.Comparator, java.io.Serializable |
RowListComparator implements the Comparator interface and provides the compare method to compare the rows in a RowList based on the column and direction flag arrays passed into it.
Note that the class has a default package scope, and is not accessiable outside its package.
|
31 |
class SingleRowList |
public |
package com.tek271.util.collections.list |
extends com.tek271.util.collections.list.RowList |
32 |
class MapOfString |
public |
package com.tek271.util.collections.map |
extends java.util.HashMap |
A map where both keys and values are strings. When you construct an object of this class you can specify if you want it to be case sensetive or not. Using the case insensetive option will not change the case of either keys or values. Additionally, using the setListOrder() method you can have the class keep track of the order in which items where added to the map. |
33 |
class MapOfStringMV |
public |
package com.tek271.util.collections.map |
extends com.tek271.util.collections.map.MapOfString |
A map of string which can have multiple values for the same key. |
34 |
class MapUtility |
public |
package com.tek271.util.collections.map |
extends MapUtils |
Static utility map-related methods. |
35 |
class MapValue |
|
package com.tek271.util.collections.map |
implements java.util.Map.Entry |
When running in a case insensitive mode, we need to maintain the original key in order to return it to the caller if needed. This class represent a value in a map with its original key. Used only in case insensitive mode.
Note that the class has a default package scope, and is not accessiable outside its package.
|
36 |
class MapValueMV |
|
package com.tek271.util.collections.map |
extends com.tek271.util.collections.map.MapValue |
n * Encapsulate a multi-value value for the MapOfStringMV class.
Note that the class has a default package scope, and is not accessiable outside its package.
|
37 |
class OrderedMapOfTimestamp |
public |
package com.tek271.util.collections.map |
extends LinkedMap |
A map whose values are the time stamp of addition to the map. The elements in the map are ordered by their insertion order. |
38 |
class TimedLruMap |
public |
package com.tek271.util.collections.map |
extends java.util.LinkedHashMap |
A map with a maximum size and time-to-live for ite entries. When trying to add to the map which reached its max size, the Least Recently Used (LRU) item is removed. Items that have been in the map for a period greater than the time-to-live period will be removed when trying to use any map-related method, in-other-words, methods of the Object class do not cause the removal of expired entries. This class extends java.utils.LinkedHashMap with accessOrder feature. |
39 |
class NotifyingSet |
public |
package com.tek271.util.collections.set |
extends com.tek271.util.collections.NotifyingCollection |
implements java.util.Set |
A set implementation that notifies when items are added or deleted. It decorates another set be making it notifying. |
40 |
class SetUtility |
public |
package com.tek271.util.collections.set |
extends SetUtils |
41 |
class AbstractTree |
public abstract |
package com.tek271.util.collections.tree |
extends com.tek271.util.collections.graph.AbstractGraphStructuredStackNode |
implements com.tek271.util.collections.tree.ITree |
Implements the ITree interface. Classes that need to implement ITree should extend this class and provide implementation for its abstract methods. The abstract methods of this class are:
abstract public Object getContents() ;
abstract public void setContents(final Object aContents);
abstract public boolean isEqualContents(final Object aContents);
abstract public Object getKey();
abstract public void setKey(final Object aKey);
abstract public boolean isEqualKey(final Object aKey);
|
42 |
interface ITree |
public interface |
package com.tek271.util.collections.tree |
implements com.tek271.util.collections.graph.IGraphStructuredStackNode |
Defines the interface of a generic tree node. A tree node consists of
- Key: must be unique for children of the same parent
- Contents
- List of children, each child is a also an ITree. (a recursive structure)
- A reference to the parent ITree node of this ITree.
|
43 |
class TreeOfString |
public |
package com.tek271.util.collections.tree |
extends com.tek271.util.collections.tree.AbstractTree |
A Tree structure of string objects. This tree has the same object for key and contents. |
44 |
class BlobUtil |
public |
package com.tek271.util.db |
Utility methods to handle Blobs in db tables.
Note that:
- This library uses 1 as the starting index of query parameters to stay similar to JDBC (albeit it is goofy).
- This library uses integers to represent sizes of blobs which will restrict the size of the blob to the max represented by Integer.MAX_VALUE.
- It does not make sense to create classes that implement the Blob interface outside the context of a JDBC driver. The Blob api requires direct connection to the db BLOB fields.
|
45 |
class ClobUtil |
public |
package com.tek271.util.db |
Utility methods to Clobs in db tables.
Note that:
- This library uses 1 as the starting index of query parameters to stay similar to JDBC (albeit it is goofy).
- This library uses integers to represent sizes of clobs which will restrict the size of the clob to the max represented by Integer.MAX_VALUE.
- It does not make sense to create classes that implement the Clob interfaces outside the context of a JDBC driver. The Clob api requires direct connection to the db CLOB fields.
|
46 |
class DBRowList |
public |
package com.tek271.util.db |
extends com.tek271.util.collections.list.RowList |
Extends a RowList by adding JDBC-related methods, including the ability to construct from a ResultSet . |
47 |
class DbUtil |
public |
package com.tek271.util.db |
Generic database library methods.
The motivation for creating this library:
- Simplify JDBC access, including handling exceptions and logging.
- Avoid adding a new abstraction or a framework that requires hours of learning or may impact performance.
- Do not try to remove SQL from the picture, just make it easier to issue SQL queries.
- If a feature is not supported by this library, the programmer can use her/his favorite method in conjunction with this library.
All the methods are:
- Static.
- Take a parameter of type
com.tek271.util.log.ILogger that allow logging errors when errors are possible. You can use SimpleConsoleLogger.LOGGER for logging to console.
- Handle and log exceptions so the user does not have to do try/catch.
- When possible, return a value indicating failure. (usually false or null)
Some interesting features are:
- Overloaded
close() to close Connection, Statement, and ResultSet.
- Given a resultset, close it, its Statement, and Connection using
closeAll() .
- Open either a standard JDBC connection, or get a connection from a JNDI lookup, used typically in J2EE environments.
- Get a row from a ResultSet as either an array or as a List.
- Increment the value of a numeric column in a table.
- Get the next value of an Oracle sequencer. (This does not mean that you can use Oracle only with this library, but that this method is only valid on an Oracle database.).
- Several
readCellAsXXX() methods that read a given column at a given row from a given table, where the value can be int, long, or String.
- Read a column from a table into a ListOfString.
- Read one row from a table into either an array or a ListOfString.
- Run a SELECT statement and put the result into a RowList object.
- Run a method in a transaction using the
IExecutable interface.
- Update the value of a given column in a table.
- Overloaded
write() and writeAndGetCount() methods that run write queries (insert, update, or delete).
- Insert or update blobs using the
writeLongString() method.
- And more ...
Example:
The following example opens a db connection, reads a value from a table, then closes the db connection.
ILogger log= SimpleConsoleLogger.LOGGER; // log errors to console
String driver= "oracle.jdbc.driver.OracleDriver";
String url= "jdbc:oracle:thin:@server1.tek271.com";
String user= "coolDude";
String password= "password";
Connection con= DbUtil.getConnectionJdbc(log, driver, url, user, password);
if (con==null) return; // error happened and logged
String sql= "select name from employee where id=5";
String name= DbUtil.readCellAsString(log, sql, con);
if (name==null) {
// error happened and logged
DbUtil.close(log, con);
return;
}
System.out.println("Name is " + name);
DbUtil.close(log, con);
In a typical application you may put the code to open connection in a separate method. Note the simplification here over standard JDBC calls; you do not have to do try/catch, and that logging is done automatically. |
48 |
class SqlSelect |
public |
package com.tek271.util.db |
Simplifies building Select SQL statement strings. When you have long SQL select statements that take many lines, this class will be very helpful. |
49 |
class SqlWhere |
public |
package com.tek271.util.db |
Build the where clause for an SQL statement. Helps avoiding string concatenations and worrying about quoting string values. |
50 |
class SqlWrite |
public |
package com.tek271.util.db |
Build an INSERT or an UPDATE SQL string. This is specially helpful to avoid repeating sql code for insert and update on the same table.
Example:
SqlWrite q = new SqlWrite(SqlWrite.UPDATE, "employee");
q.setWhere("age<18");
q.addColumn("destination", "Hawaii", true); // true: surround Hawaii by single quotes
q.addColumn("vacationDays", 10);
System.out.println(q.toString());
The above code will generate the following SQL statement:
UPDATE employee SET destination='Hawaii',vacationDays=10 WHERE age<18
Now, to generate an INSERT statement on the same table and columns, all we need is to call:
q.setQueryType(SqlWrite.INSERT);
System.out.println(q.toString());
Which will generate: (notice that we did not have to repeat column definitions)
INSERT INTO employee (destination,vacationDays) VALUES ('Hawaii',10) WHERE age<18
Although this was a simple example that may not justify using the SqlWrite class, it is meant to demonstrate the basic usage. This class really shines when you have complex inserts or updates that take many lines and are hard to follow.
|
51 |
class TransUtil |
public |
package com.tek271.util.db |
Database transactions utilities, including static methods for commit, rollback, setAutoCommit, and a method that executes several db operations as one transaction. |
52 |
class ExceptionUtil |
public |
package com.tek271.util.exception |
Generic static methods to manage exceptions, including:
- Build consistent debug or error messages.
- Log a debug, warning, or error message to an ILogger object.
- Convert an exception stack trace to a string.
- Print an exception's stack trace to console, an
OutputStream , or a Writer object. This is useful to print the stack trace to a web page during development.
|
53 |
class LoggedException |
public |
package com.tek271.util.exception |
extends java.lang.Exception |
An exception that logs error messages, it will also log the stack trace. |
54 |
class Email |
public |
package com.tek271.util.internet |
Simplifies sending SMTP email. Its static methods send() and sendAsynchronous() are very easy to use and send email.
Requires javax.mail. Can be downloaded at: http://java.sun.com/products/javamail/downloads/index.html . However, this is included with the tecuj.jar.
|
55 |
class EmailSender |
public |
package com.tek271.util.internet.email |
Send email using the SMTP/SMTPS prtocol. I used the smtpsend.java which comes with Java Mail API demo as a starting point for creating this class. The authors of smtpsend.java are Max Spivak and Bill Shannon. |
56 |
class EmailUtils |
public |
package com.tek271.util.internet.email |
Email helper static methods. |
57 |
class ColorGradient |
public |
package com.tek271.util.internet.html |
Given two colors and a range, get the gradient color for each step, in other words, get the interpolation of color as we transition in the range. |
58 |
class ComboBox |
public |
package com.tek271.util.internet.html |
Build the html for a combo box. |
59 |
class ErrorList |
public |
package com.tek271.util.internet.html |
Collect a list of errors which can be displayed later in one page. |
60 |
class Grade |
public |
package com.tek271.util.internet.html |
Display a list of grades (e.g. from 1 to 10) with each grade displayed as a link. Background colors will gradually change from minium grade to max grade |
61 |
class HtmlTable |
public |
package com.tek271.util.internet.html |
Generates an HTML table. To use this class,
- Implement the interface HtmlTable.ICellCallback
- create a new object of HtmlTable
- initialize its properties as you like,
- then call the toString() method.
|
62 |
interface HtmlTable.ICellCallback |
public static interface |
package com.tek271.util.internet.html |
Client applications should implement this interface to provide the text to be displayed at each cell in the table. |
63 |
class HtmlUtil |
public |
package com.tek271.util.internet.html |
Static methods to build different HTML tags and elements. Supported elements include: <a>, <b>, <br>, <h>, <i>, <img>, <p>, Check box, Font color, Numbered lines, ...
The purpose of this class is to simplify the creation of HTML elements in Java code.
|
64 |
class Paginator |
public |
package com.tek271.util.internet.html |
Generate pagination links that could be used to navigate to different search results. |
65 |
class TableUtils |
public |
package com.tek271.util.internet.html |
Utility methods for HTML tables, including the creation of <td> and <th> elements. |
66 |
class MultiLevelMenu |
public |
packagecom.tek271.util.internet.html.menu |
Generate a cross browser multi-level html menu. It expects that the style sheet multiLevelTopMenu.css is available to the browser.
The html and css idea of this class was taken and refactored from: www.cssplay.co.uk/menus/simple_vertical.html
|
67 |
class MultiLevelMenu.Config |
public static |
packagecom.tek271.util.internet.html.menu |
68 |
class XmlMultiLevelMenu |
public |
packagecom.tek271.util.internet.html.menu |
Create a MultiLevelMenu from XML. An example XML could be:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<menu>
<mi text='Home' href='home.html' />
<mi text='Affiliate' href='http://www.google.com' target='_blank' />
<mi text='Books' href='books.html'>
<mi text='Fiction' href='Fiction.html'>
<mi text='Mystery' href='Mystry.html'>
<mi text='Cold Prey' href='coldPrey.html' />
<mi text='Silent Prey' href='silentPrey.html' />
<mi text='Blood Memory' href='bloodMemory.html' />
</mi>
</mi>
</mi>
</menu>
|
69 |
class Compress |
public |
package com.tek271.util.io |
70 |
class ConfigFile |
public |
package com.tek271.util.io |
implements java.lang.Cloneable |
Encapsulates a configuration file interface. This is a better handler for properties files that can support inline comments and grouping.
The user can (optionally) specify in the file what is the equality character and the comment start character. For example:
_equal=>]
_comment=%
If the above two lines are the first two lines in the file, values will be separated from their names by the > or ] char, while comments will start with %.
The default Equal chars are = or : while the default Comment chars are ; or #.
|
71 |
class FileIO |
public |
package com.tek271.util.io |
Generic file i/o methods for reading, writing, listing, and finding files. |
72 |
class Net |
public |
package com.tek271.util.io |
73 |
class AbstractBufferedLogger |
public abstract |
package com.tek271.util.log |
implements com.tek271.util.log.ILogger |
Buffer logging messages. Remember to call flush when you are done with objects of this class. Implementing classes must provide logNow() implementation. |
74 |
class AbstractLogger |
public abstract |
package com.tek271.util.log |
implements com.tek271.util.log.ILogger |
Implements the ILogger interface method log(level, msg). This makes it easier for classes that implement the ILogger interface. |
75 |
class BufferedLog4jAdapter |
public |
package com.tek271.util.log |
extends com.tek271.util.log.AbstractBufferedLogger |
A buffered logger that uses log4j. Remember to call flush when you are done with objects of this class. Note that this class extends AbstractBufferedLogger which implements the ILogger interface, so you can use this class whereever ILogger is expected. |
76 |
class ClassLogger |
public |
package com.tek271.util.log |
Provide info/debug/warn/error methods for a client class
|
77 |
class CommonsLoggingAdapter |
public |
package com.tek271.util.log |
extends com.tek271.util.log.AbstractLogger |
Implements the ILogger interface using the commons logging logger.
|
78 |
interface ILogger |
public interface |
package com.tek271.util.log |
Interface of a generic logger. Used to create logging classes that implement this interface. The interface has only one method log() that is overloaded once. Some classes (E.g. DbUtil ) in this library use this interface to log error message.
To use this interface you should implement it in one of your classes and pass an object of your class.
|
79 |
class ListLogger |
public |
package com.tek271.util.log |
extends com.tek271.util.log.AbstractLogger |
An ILogger implementation that Decorates another ILogger by manitaining a list of logged events. The list can be accessed at any time. Remember that if you dump the list contents to some output device, you should clear it afterwords. |
80 |
class ListLogger.LogItem |
public |
package com.tek271.util.log |
a log item |
81 |
class Log4jAdapter |
public |
package com.tek271.util.log |
extends com.tek271.util.log.AbstractLogger |
Implements the ILogger interface using Log4j
|
82 |
class MultiThrowable |
|
package com.tek271.util.log |
extends java.lang.Throwable |
A throwable that can have multiple stack traces.
|
83 |
class PerformanceLog |
public |
package com.tek271.util.log |
Log timing for different events in the JVM. The caller logs the time of an event by name. Accessing this class is throu the singlton PerformanceLog.LOG. The method that will be called the most is PerformanceLog.LOG.putNow(key, startTime) |
84 |
class PerformanceLog.LogEntry |
public static |
package com.tek271.util.log |
Store info about a single operation logging times |
85 |
class SimpleConsoleLogger |
public |
package com.tek271.util.log |
extends com.tek271.util.log.AbstractLogger |
Simple logger that implements ILogger and writes to console. Usually used for debugging.
The static member SimpleConsoleLogger.LOGGER can be used instead of creating several objects of this class.
|
86 |
class AbstractTokenizer |
abstract |
package com.tek271.util.parse |
This is an abstract class that is implemented by the Tokenizer class.
- Has a default package scope, i.e. not visible outside this package.
- Defines the public properties, methods, and fields of the
Tokenizer class.
The class defines the following public methods:
set/get Text : The text or source to be tokenized.
getNext : abstract, implemented in the Tokenizer class. Returns the next token.
getList : Tokenize the source and return a list of Token objects.
toString : Converts the class into a string including its properties values.
set/is CaseSensitive : Controls if keywords are case sensitive or not.
set/get Keywords : A list of the keywords. E.g. if else class while .
set/get MultiLineCommentEnders : A list of character sequences that indicate end of a multi-line comment. E.g. */ or*) .
set/get MultiLineCommentStarters : A list of character sequences that indicate start of a multi-line comment. E.g. /* or(* .
set/get NewLineMarkers : A list of character sequences that indicate the end of a line and the start of a new line. E.g.\n or \n\r .
set/get Separators : A list of arithmetic or punctuation separators. E.g. = + - * == <= ; : .
set/get SingleLineCommentMarkers : A list of character sequences that indicate the start of a single line comment. The comment may start at any position in the line. E.g. // or REM .
set/get StringMarkers : A list of characters that indicate the beginning/end of a string literal. E.g. " or ' .
set/get WhiteSpaces : A list of characters that indicate a space. E.g. blank or tab.
The class also defines the following public boolean fields:
isReturnComments : Controls if comments should be returned as a result of tokenization. Default is true.
isReturnNewLineMarkers : Controls if new-line-markers should be returned as a result of tokenization. Default is true.
isReturnWhiteSpace : Controls if white-spaces should be returned as a result of tokenization. Default is true.
|
87 |
class FileTokenizer |
public |
package com.tek271.util.parse |
extends com.tek271.util.parse.Tokenizer |
- Extends the
Tokenizer class.
- Tokenizes a text file, reading the syntax definition from another file.
|
88 |
class Token |
public |
package com.tek271.util.parse |
The Tokenizer class produces Token objects. This is a simple data structure that contains the value, type, line, and column of the token. The token type can be one of: Keyword, String, Separator, Literal, White Space, Comment, New Line, and Error. |
89 |
class Token.List |
public static |
package com.tek271.util.parse |
Define a list of tokens. |
90 |
class Tokenizer |
public |
package com.tek271.util.parse |
extends com.tek271.util.parse.AbstractTokenizer |
A generic tokenizer. To use it:
- Initialize the syntax definition by calling setKeyworks, setCaseSensitive, setSeparators, ...
- Call setText() and pass it the text you want to tokenize.
- Call getNext() repeatedly. Each call will return an object of type
Token . When no more tokens, a null is returned.
- You can call getList() instead of calling getNext() many times.
|
91 |
class SelectParser |
public |
package com.tek271.util.parse.sql |
Define a parser that parses a Select Sql statement. To use it:
- Construct a SelectParser object using a select statement, this will also parse the Sql string.
- getColumns: a list of selected columns
- getTables: a list of tables in the
From clause.
- getWhere: a list of items in the
where clause.
- getGroupBy: an optional list of items in the
Group by clause.
- getOrderBy: an optional list of items in the
Order by clause.
|
92 |
class BasicTypes |
public |
package com.tek271.util.reflect |
Utility class that define primitive types, their wrappers, and other basic types |
93 |
interface IPrimitiveWrapper |
public interface |
package com.tek271.util.reflect |
Allows grouping primitive types with their wrappers |
94 |
class ReflectUtil |
public |
package com.tek271.util.reflect |
Utility methods that handle dynamic class introspections |
95 |
class BeanAccessor |
public |
package com.tek271.util.reflect.accessors |
96 |
class FieldAccessor |
public |
package com.tek271.util.reflect.accessors |
97 |
class MethodAccessor |
public |
package com.tek271.util.reflect.accessors |
98 |
class AbstractBeanBuilder |
public abstract |
package com.tek271.util.reflect.builder |
Dynamically creates a bean that implements a given interface and back its property values using the IBeanValueAccessor interface. |
99 |
interfaceAbstractBeanBuilder.IBeanValueAccessor |
public static interface |
package com.tek271.util.reflect.builder |
An interface that must be implemented by subclasses of AbstractBeanBuilder. It provides the mechanism to get and set the bean property values using the name of the property. |
100 |
class BeanFromMapBuilder |
public |
package com.tek271.util.reflect.builder |
extends com.tek271.util.reflect.builder.AbstractBeanBuilder |
Dynamically creats a bean that implements a given interface and back its property values using a Map object. An example which uses this class:
import java.util.*;
import com.tek271.util.collections.map.MapUtility;
...
public interface IPerson {
String getName();
void setName(String name);
Integer getAge();
void setAge(Integer age);
String getSsn();
void setSsn(String ssn);
}
private static final Object[][] ARRAY = {
{"name", "abdul"},
{"age", new Integer(40)},
{"ssn", "123456789"},
};
public static final Map MAP= MapUtility.toMap(ARRAY);
public void testSetProperties() throws Exception {
IPerson person= (IPerson) BeanFromMapBuilder.create(IPerson.class, MAP);
System.out.println(person.getName()); // abdul
System.out.println(person.getAge()); // 40
System.out.println(person.getSsn()); // 123456789
person.setName("aaa");
System.out.println(person.getName() ); // aaa
}
|
101 |
class MethodFilter |
public |
package com.tek271.util.reflect.filter |
Provides a list of methods on a class filtered by different criteria. To use the class, set the exclude properties, then call getMethods(). |
102 |
class MethodSignature |
public |
package com.tek271.util.reflect.filter |
Encapsulates the signature of a method, ie, its name and parameters types. |
103 |
class Encryption |
public |
package com.tek271.util.security |
A simple encryption program to encrypt and decrypt strings using a given password. It helps encrypting password columns in db tables. Uses DES algorithm. |
104 |
class StringComparator |
public |
package com.tek271.util.string |
implements java.util.Comparator, java.lang.Comparable |
Implement the Comparator and Comparable interfaces for String objects, with support for case sensitivity. |
105 |
class StringEscapeUtility |
public |
package com.tek271.util.string |
extends StringEscapeUtils |
Different string escapeing methods. |
106 |
class StringUtility |
public |
package com.tek271.util.string |
extends StringUtils |
Contains common string functions. Note that this class extends org.apache.commons.lang.StringUtils . The StringUtils class is available to download from http://jakarta.apache.org/commons/lang/. Make sure to include the downloaded jar file in your classpath, currently this is commons-lang-2.1.jar . However, the tecuj download includes this jar file.
Some interesting features are:
- Define some common String constants like NEW_LINE, ALPHA_CAPS, WHITE_SPACE, ...
- Delete a set of characters from a given string.
equals() method with a case sensitivity flag.
- Convert to/from Hexadecimals and Unicode.
- Check if a value is a member in a given set of values.
- Several overloaded indexOf(), indexOfAny(), indexOfAnyBut() methods to find the index of a value in a target.
- Get the lastChar() of a given string.
- Repeat a character a given number of times.
- And more ...
|
107 |
class TextTemplate |
public |
package com.tek271.util.string |
A text template class that allows substituting patterns (or tags) with values. The easiest way to use it is to call one of the process() static methods.
However, if you want to reuse the same template in your program but with different values, consider creating a TextTemplate object and assigning values to it using either setTagValue() or setAll().
History:
- 2005.06.22: Added copy() method.
- 2006.01.30: Added ITagTransformer and transformTags()
|
108 |
interface TextTemplate.ITagTransformer |
public static interface |
package com.tek271.util.string |
Allows transforming tags to new values |
109 |
class TextTemplate.Element |
public |
package com.tek271.util.string |
Represents a single element of the processed text, the element can be either a string or a tag. |
110 |
class WordUtility |
public |
package com.tek271.util.string |
extends WordUtils |
111 |
class AbstractMutex |
public abstract |
package com.tek271.util.thread |
implements com.tek271.util.thread.IMutex |
Implements the IMutex interface
|
112 |
class FileMutex |
public |
package com.tek271.util.thread |
extends com.tek271.util.thread.AbstractMutex |
A mutual-exclusion-lock based on the existance of a file in the file system
|
113 |
interface IMutex |
public interface |
package com.tek271.util.thread |
Define the interface of a mutual-exclusion-lock
|
114 |
class Mutex |
public |
package com.tek271.util.thread |
extends com.tek271.util.thread.AbstractMutex |
Create an in-memory mutual-exclusion-lock
|
115 |
class OsExecutor |
public |
package com.tek271.util.thread |
A wrapper around Runtime.getRuntime().exec() |
116 |
class ThreadUtility |
public |
package com.tek271.util.thread |
Several static thread related methods including sleep(seconds) . |
117 |
class DateFormatUt |
public |
package com.tek271.util.time |
extends DateFormatUtils |
Date/Time formatting functions. |
118 |
class DateUt |
public |
package com.tek271.util.time |
extends DateUtils |
Date/Time functions. |
119 |
class XmlTree |
public |
package com.tek271.util.xml |
implements java.lang.Cloneable |
A tree data structure that represents an XML document in a simplified DOM style. It is a wrapper around the XML libraries that come with J2SE.
To use this class, use the static methods create() or createXxx() which will return an XmlTree object.
The program uses SAX to parse the XML document and build the tree. Some of its features:
- You can parse an XML document from a String, InputStream, Reader, File, or URL.
- Each
XmlTree has a tag, optional text, an optional list of attributes, and an optional list of children.
- The children are
XmlTree objects also. This structure is recursive.
- You can add, get, or delete children by index or path (slash / separated).
- You can get/set the tag, attributes, and text of an
XmlTree object.
- You can get the string representation of an
XmlTree object.
|
120 |
class XmlTreeParser |
|
package com.tek271.util.xml |
extends org.xml.sax.helpers.DefaultHandler |
Handles events received from SAX parser to populate an XmlTree object.
Note that this class has a package scope and is not intended to be used by classes other than XmlTree .
This parser will ignore all comments in the XML data.
This class was refactored in 2006.08.15 to extend DefaultHandler instead of HandlerBase which was deprecated.
|
121 |
class XmlUtil |
public |
package com.tek271.util.xml |
General XML utility methods, including the building of XML tags from their components.
|