Methods Summary |
---|
private static native void | _copy(long destptr, java.lang.String hdfpath, long srcptr)
|
private static native void | _dealloc(long ptr)
|
private static native java.lang.String | _dump(long ptr)
|
private static native long | _getChild(long ptr, java.lang.String hdfpath)
|
private static native int | _getIntValue(long ptr, java.lang.String hdfname, int default_value)
|
private static native long | _getObj(long ptr, java.lang.String hdfpath)
|
private static native java.lang.String | _getValue(long ptr, java.lang.String hdfname, java.lang.String default_value)
|
private static native long | _init()
|
private static native long | _objChild(long ptr)
|
private static native java.lang.String | _objName(long ptr)
|
private static native long | _objNext(long ptr)
|
private static native java.lang.String | _objValue(long ptr)
|
private native boolean | _readFile(long ptr, java.lang.String filename, boolean use_cb)
|
private static native boolean | _readString(long ptr, java.lang.String data)
|
private static native void | _removeTree(long ptr, java.lang.String hdfname)
|
private static native void | _setSymLink(long ptr, java.lang.String hdf_name_src, java.lang.String hdf_name_dest)
|
private static native void | _setValue(long ptr, java.lang.String hdfname, java.lang.String hdf_value)
|
private static native boolean | _writeFile(long ptr, java.lang.String filename)
|
private static native boolean | _writeFileAtomic(long ptr, java.lang.String filename)
|
private static native java.lang.String | _writeString(long ptr)
|
public void | close()Clean up allocated memory if neccesary. close() allows application
to force clean up.
// Only root nodes have ownership of the C HDF pointer, so only a root
// node needs to dealloc hdfptr.dir
if ( root == null) {
if (hdfptr != 0) {
_dealloc(hdfptr);
hdfptr = 0;
}
}
|
public void | copy(java.lang.String hdfpath, org.clearsilver.HDF src)
if (hdfptr == 0 || src.hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
_copy(hdfptr, hdfpath, src.hdfptr);
|
public java.lang.String | dump()Generates a string representing the content of the HDF tree rooted at
this node.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _dump(hdfptr);
|
public void | exportDate(java.lang.String hdfname, java.util.TimeZone timeZone, java.util.Date date)Export a date to a clearsilver tree using a specified timezone
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
Calendar cal = Calendar.getInstance(timeZone);
cal.setTime(date);
String sec = Integer.toString(cal.get(Calendar.SECOND));
setValue(hdfname + ".sec", sec.length() == 1 ? "0" + sec : sec);
String min = Integer.toString(cal.get(Calendar.MINUTE));
setValue(hdfname + ".min", min.length() == 1 ? "0" + min : min);
setValue(hdfname + ".24hour",
Integer.toString(cal.get(Calendar.HOUR_OF_DAY)));
// java.util.Calendar uses represents 12 o'clock as 0
setValue(hdfname + ".hour",
Integer.toString(
cal.get(Calendar.HOUR) == 0 ? 12 : cal.get(Calendar.HOUR)));
setValue(hdfname + ".am",
cal.get(Calendar.AM_PM) == Calendar.AM ? "1" : "0");
setValue(hdfname + ".mday",
Integer.toString(cal.get(Calendar.DAY_OF_MONTH)));
setValue(hdfname + ".mon",
Integer.toString(cal.get(Calendar.MONTH)+1));
setValue(hdfname + ".year",
Integer.toString(cal.get(Calendar.YEAR)));
setValue(hdfname + ".2yr",
Integer.toString(cal.get(Calendar.YEAR)).substring(2));
setValue(hdfname + ".wday",
Integer.toString(cal.get(Calendar.DAY_OF_WEEK)));
boolean tzNegative = timeZone.getRawOffset() < 0;
int tzAbsolute = java.lang.Math.abs(timeZone.getRawOffset()/1000);
String tzHour = Integer.toString(tzAbsolute/3600);
String tzMin = Integer.toString(tzAbsolute/60 - (tzAbsolute/3600)*60);
String tzString = (tzNegative ? "-" : "+")
+ (tzHour.length() == 1 ? "0" + tzHour : tzHour)
+ (tzMin.length() == 1 ? "0" + tzMin : tzMin);
setValue(hdfname + ".tzoffset", tzString);
|
public void | exportDate(java.lang.String hdfname, java.lang.String tz, int tt)Export a date to a clearsilver tree using a specified timezone
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
TimeZone timeZone = TimeZone.getTimeZone(tz);
if (timeZone == null) {
throw new RuntimeException("Unknown timezone: " + tz);
}
Date date = new Date((long)tt * 1000);
exportDate(hdfname, timeZone, date);
|
protected java.lang.String | fileLoad(java.lang.String filename)
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
CSFileLoader aFileLoader = fileLoader;
if (aFileLoader == null) {
throw new NullPointerException("No fileLoader specified.");
} else {
String result = aFileLoader.load(this, filename);
if (result == null) {
throw new NullPointerException("CSFileLoader.load() returned null");
}
return result;
}
|
protected void | finalize()Call close() just in case when deallocating Java object.
close();
super.finalize();
|
public org.clearsilver.HDF | getChild(java.lang.String hdfpath)Retrieves the HDF for the first child of the root of the subtree
at hdfpath, or null if no child exists of that path or if the
path doesn't exist.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
long obj_ptr = _getChild(hdfptr, hdfpath);
if ( obj_ptr == 0 ) {
return null;
}
return new HDF(obj_ptr, this);
|
public CSFileLoader | getFileLoader()Get the file loader in use, if any.
return fileLoader;
|
public int | getIntValue(java.lang.String hdfname, int default_value)Retrieves the integer value at the specified path in this HDF node's
subtree. If the value does not exist, or cannot be converted to an
integer, default_value will be returned.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _getIntValue(hdfptr,hdfname,default_value);
|
public org.clearsilver.HDF | getObj(java.lang.String hdfpath)Retrieves the HDF object that is the root of the subtree at hdfpath, or
null if no object exists at that path.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
long obj_ptr = _getObj(hdfptr, hdfpath);
if ( obj_ptr == 0 ) {
return null;
}
return new HDF(obj_ptr, this);
|
public org.clearsilver.HDF | getOrCreateObj(java.lang.String hdfpath)Retrieves the HDF object that is the root of the subtree at
hdfpath, create the subtree if it doesn't exist
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
long obj_ptr = _getObj(hdfptr, hdfpath);
if ( obj_ptr == 0 ) {
// Create a node
_setValue(hdfptr, hdfpath, "");
obj_ptr = _getObj( hdfptr, hdfpath );
if ( obj_ptr == 0 ) {
return null;
}
}
return new HDF(obj_ptr, this);
|
public org.clearsilver.HDF | getRootObj()Return the root of the tree where the current node lies. If the
current node is the root, return this.
return root != null ? root : this;
|
public java.lang.String | getValue(java.lang.String hdfname, java.lang.String default_value)Retrieves the value at the specified path in this HDF node's subtree.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _getValue(hdfptr,hdfname,default_value);
|
public org.clearsilver.HDF | objChild()Returns the child of this HDF node, or null if there is no child.
Use this in conjunction with objNext to walk the HDF tree. Every node
in the tree can have a value, a child, and a next peer.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
long child_ptr = _objChild(hdfptr);
if ( child_ptr == 0 ) {
return null;
}
return new HDF(child_ptr, this);
|
public java.lang.String | objName()Returns the name of this HDF node. The root node has no name, so
calling this on the root node will return null.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _objName(hdfptr);
|
public org.clearsilver.HDF | objNext()Returns the next sibling of this HDF node, or null if there is no next
sibling. Use this in conjunction with objChild to walk the HDF tree.
Every node in the tree can have a value, a child, and a next peer.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
long next_ptr = _objNext(hdfptr);
if ( next_ptr == 0 ) {
return null;
}
return new HDF(next_ptr, this);
|
public java.lang.String | objValue()Returns the value of this HDF node, or null if this node has no value.
Every node in the tree can have a value, a child, and a next peer.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _objValue(hdfptr);
|
public boolean | readFile(java.lang.String filename)Loads the contents of the specified HDF file from disk into the current
HDF object. The loaded contents are merged with the existing contents.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _readFile(hdfptr, filename, fileLoader != null);
|
public boolean | readString(java.lang.String data)Parses/loads the contents of the given string as HDF into the current
HDF object. The loaded contents are merged with the existing contents.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _readString(hdfptr, data);
|
public void | removeTree(java.lang.String hdfname)Remove the specified subtree.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
_removeTree(hdfptr,hdfname);
|
public void | setFileLoader(CSFileLoader fileLoader)Set the CS file loader to use
this.fileLoader = fileLoader;
|
public void | setSymLink(java.lang.String hdf_name_src, java.lang.String hdf_name_dest)Links the src hdf name to the dest.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
_setSymLink(hdfptr,hdf_name_src,hdf_name_dest);
|
public void | setValue(java.lang.String hdfname, java.lang.String value)Sets the value at the specified path in this HDF node's subtree.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
_setValue(hdfptr,hdfname,value);
|
public boolean | writeFile(java.lang.String filename)Serializes HDF contents to a file (readable by readFile)
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _writeFile(hdfptr, filename);
|
public boolean | writeFileAtomic(java.lang.String filename)Serializes HDF contents to a file (readable by readFile), but
writes the file atomically by writing to a temp file then doing a
rename(2) on it.
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _writeFileAtomic(hdfptr, filename);
|
public java.lang.String | writeString()Serializes HDF contents to a string (readable by readString)
if (hdfptr == 0) {
throw new NullPointerException("HDF is closed.");
}
return _writeString(hdfptr);
|