| Method from com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet Detail: |
public void addAuxiliaryClass(Class auxClass) {
if (_auxClasses == null) _auxClasses = new Hashtable();
_auxClasses.put(auxClass.getName(), auxClass);
}
|
public void addCdataElement(String name) {
if (_cdata == null) {
_cdata = new Vector();
}
int lastColon = name.lastIndexOf(':");
if (lastColon > 0) {
String uri = name.substring(0, lastColon);
String localName = name.substring(lastColon+1);
_cdata.addElement(uri);
_cdata.addElement(localName);
} else {
_cdata.addElement(null);
_cdata.addElement(name);
}
}
Add's a name of an element whose text contents should be output as CDATA |
public void addDecimalFormat(String name,
DecimalFormatSymbols symbols) {
// Instanciate hashtable for formatting symbols if needed
if (_formatSymbols == null) _formatSymbols = new Hashtable();
// The name cannot be null - use empty string instead
if (name == null) name = EMPTYSTRING;
// Construct a DecimalFormat object containing the symbols we got
final DecimalFormat df = new DecimalFormat();
if (symbols != null) {
df.setDecimalFormatSymbols(symbols);
}
_formatSymbols.put(name, df);
}
Adds a DecimalFormat object to the _formatSymbols hashtable.
The entry is created with the input DecimalFormatSymbols. |
public final Object addParameter(String name,
Object value) {
name = BasisLibrary.mapQNameToJavaName (name);
return addParameter(name, value, false);
}
Add a new global parameter if not already in the current frame.
To setParameters of the form {http://foo.bar}xyz
This needs to get mapped to an instance variable in the class
The mapping created so that
the global variables in the generated class become
http$colon$$flash$$flash$foo$dot$bar$colon$xyz |
public final Object addParameter(String name,
Object value,
boolean isDefault) {
// Local parameters need to be re-evaluated for each iteration
for (int i = pframe - 1; i >= pbase; i--) {
final Parameter param = (Parameter) paramsStack.get(i);
if (param._name.equals(name)) {
// Only overwrite if current value is the default value and
// the new value is _NOT_ the default value.
if (param._isDefault || !isDefault) {
param._value = value;
param._isDefault = isDefault;
return value;
}
return param._value;
}
}
// Add new parameter to parameter stack
paramsStack.add(pframe++, new Parameter(name, value, isDefault));
return value;
}
Add a new global or local parameter if not already in the current frame.
The 'isDefault' parameter is set to true if the value passed is the
default value from the element's select attribute or
element body. |
public void buildKeyIndex(String name,
DOM dom) {
if (_keyIndexes == null) _keyIndexes = new Hashtable();
KeyIndex index = (KeyIndex)_keyIndexes.get(name);
if (index == null) {
_keyIndexes.put(name, index = new KeyIndex(_indexSize));
}
index.setDom(dom, dom.getDocument());
}
Create an empty KeyIndex in the DOM case |
public void buildKeyIndex(String name,
int node,
Object value) {
if (_keyIndexes == null) _keyIndexes = new Hashtable();
KeyIndex index = (KeyIndex)_keyIndexes.get(name);
if (index == null) {
_keyIndexes.put(name, index = new KeyIndex(_indexSize));
}
index.add(value, node, _currentRootForKeys);
}
Adds a value to a key/id index |
public void buildKeys(DOM document,
DTMAxisIterator iterator,
SerializationHandler handler,
int root) throws TransletException {
}
This method builds key indexes - it is overridden in the compiled
translet in cases where the element is used |
public final void characters(String string,
SerializationHandler handler) throws TransletException {
if (string != null) {
//final int length = string.length();
try {
handler.characters(string);
} catch (Exception e) {
throw new TransletException(e);
}
}
}
Used by some compiled code as a shortcut for passing strings to the
output handler |
public void clearParameters() {
pbase = pframe = 0;
paramsStack.clear();
}
Clears the parameter stack. |
public void closeOutputHandler(SerializationHandler handler) {
try {
handler.endDocument();
handler.close();
}
catch (Exception e) {
// what can you do?
}
}
|
public KeyIndex createKeyIndex() {
return(new KeyIndex(_indexSize));
}
Creates a KeyIndex object of the desired size - don't want to resize!!! |
public final void displayMessage(String msg) {
if (_msgHandler == null) {
System.err.println(msg);
}
else {
_msgHandler.displayMessage(msg);
}
}
Pass a message to the message handler - used by Message class. |
public Class getAuxiliaryClass(String className) {
if (_auxClasses == null) return null;
return((Class)_auxClasses.get(className));
}
|
public DOMCache getDOMCache() {
return(_domCache);
}
Returns the DOM cache used for this translet. Used by the LoadDocument
class (if present) when the document() function is used. |
public final DecimalFormat getDecimalFormat(String name) {
if (_formatSymbols != null) {
// The name cannot be null - use empty string instead
if (name == null) name = EMPTYSTRING;
DecimalFormat df = (DecimalFormat)_formatSymbols.get(name);
if (df == null) df = (DecimalFormat)_formatSymbols.get(EMPTYSTRING);
return df;
}
return(null);
}
Retrieves a named DecimalFormat object from _formatSymbols hashtable. |
public KeyIndex getKeyIndex(String name) {
// Return an empty key index iterator if none are defined
if (_keyIndexes == null) {
return (_emptyKeyIndex != null)
? _emptyKeyIndex
: (_emptyKeyIndex = new KeyIndex(1));
}
// Look up the requested key index
final KeyIndex index = (KeyIndex)_keyIndexes.get(name);
// Return an empty key index iterator if the requested index not found
if (index == null) {
return (_emptyKeyIndex != null)
? _emptyKeyIndex
: (_emptyKeyIndex = new KeyIndex(1));
}
return(index);
}
Returns the index for a given key (or id).
The index implements our internal iterator interface |
public String[] getNamesArray() {
return namesArray;
}
|
public String[] getNamespaceArray() {
return namespaceArray;
}
|
public final Object getParameter(String name) {
name = BasisLibrary.mapQNameToJavaName (name);
for (int i = pframe - 1; i >= pbase; i--) {
final Parameter param = (Parameter)paramsStack.get(i);
if (param._name.equals(name)) return param._value;
}
return null;
}
Get the value of a parameter from the current frame or
null if undefined. |
public Templates getTemplates() {
return _templates;
}
|
public int[] getTypesArray() {
return typesArray;
}
|
public String[] getUrisArray() {
return urisArray;
}
|
public boolean hasIdCall() {
return _hasIdCall;
}
|
public final DOMAdapter makeDOMAdapter(DOM dom) throws TransletException {
setRootForKeys(dom.getDocument());
return new DOMAdapter(dom, namesArray, urisArray, typesArray, namespaceArray);
}
Wrap the initial input DOM in a dom adapter. This adapter is wrapped in
a DOM multiplexer if the document() function is used (handled by compiled
code in the translet - see compiler/Stylesheet.compileTransform()). |
public Document newDocument(String uri,
String qname) throws ParserConfigurationException {
if (_domImplementation == null) {
_domImplementation = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().getDOMImplementation();
}
return _domImplementation.createDocument(uri, qname, null);
}
|
public SerializationHandler openOutputHandler(String filename) throws TransletException {
return openOutputHandler(filename, false);
}
|
public SerializationHandler openOutputHandler(String filename,
boolean append) throws TransletException {
try {
final TransletOutputHandlerFactory factory
= TransletOutputHandlerFactory.newInstance();
String dirStr = new File(filename).getParent();
if ((null != dirStr) && (dirStr.length() > 0)) {
File dir = new File(dirStr);
dir.mkdirs();
}
factory.setEncoding(_encoding);
factory.setOutputMethod(_method);
factory.setOutputStream(new FileOutputStream(filename, append));
factory.setOutputType(TransletOutputHandlerFactory.STREAM);
final SerializationHandler handler
= factory.getSerializationHandler();
transferOutputSettings(handler);
handler.startDocument();
return handler;
}
catch (Exception e) {
throw new TransletException(e);
}
}
Multiple output document extension.
See compiler/TransletOutput for actual implementation. |
public final void popParamFrame() {
if (pbase > 0) {
final int oldpbase = ((Integer)paramsStack.get(--pbase)).intValue();
for (int i = pframe - 1; i >= pbase; i--) {
paramsStack.remove(i);
}
pframe = pbase; pbase = oldpbase;
}
}
Pop the topmost parameter frame. |
public final void postInitialization() {
// If the version of the translet had just one namesArray, split
// it into multiple fields.
if (transletVersion < VER_SPLIT_NAMES_ARRAY) {
int arraySize = namesArray.length;
String[] newURIsArray = new String[arraySize];
String[] newNamesArray = new String[arraySize];
int[] newTypesArray = new int[arraySize];
for (int i = 0; i < arraySize; i++) {
String name = namesArray[i];
int colonIndex = name.lastIndexOf(':");
int lNameStartIdx = colonIndex+1;
if (colonIndex > -1) {
newURIsArray[i] = name.substring(0, colonIndex);
}
// Distinguish attribute and element names. Attribute has
// @ before local part of name.
if (name.charAt(lNameStartIdx) == '@") {
lNameStartIdx++;
newTypesArray[i] = DTM.ATTRIBUTE_NODE;
} else if (name.charAt(lNameStartIdx) == '?") {
lNameStartIdx++;
newTypesArray[i] = DTM.NAMESPACE_NODE;
} else {
newTypesArray[i] = DTM.ELEMENT_NODE;
}
newNamesArray[i] =
(lNameStartIdx == 0) ? name
: name.substring(lNameStartIdx);
}
namesArray = newNamesArray;
urisArray = newURIsArray;
typesArray = newTypesArray;
}
// Was translet compiled using a more recent version of the XSLTC
// compiler than is known by the AbstractTranslet class? If, so
// and we've made it this far (which is doubtful), we should give up.
if (transletVersion > CURRENT_TRANSLET_VERSION) {
BasisLibrary.runTimeError(BasisLibrary.UNKNOWN_TRANSLET_VERSION_ERR,
this.getClass().getName());
}
}
After constructing the translet object, this method must be called to
perform any version-specific post-initialization that's required. |
public final void prepassDocument(DOM document) {
setIndexSize(document.getSize());
buildIDIndex(document);
}
Give the translet an opportunity to perform a prepass on the document
to extract any information that it can store in an optimized form.
Currently, it only extracts information about attributes of type ID. |
public void printInternalState() {
System.out.println("-------------------------------------");
System.out.println("AbstractTranslet this = " + this);
System.out.println("pbase = " + pbase);
System.out.println("vframe = " + pframe);
System.out.println("paramsStack.size() = " + paramsStack.size());
System.out.println("namesArray.size = " + namesArray.length);
System.out.println("namespaceArray.size = " + namespaceArray.length);
System.out.println("");
System.out.println("Total memory = " + Runtime.getRuntime().totalMemory());
}
|
public final void pushParamFrame() {
paramsStack.add(pframe, new Integer(pbase));
pbase = ++pframe;
}
Push a new parameter frame. |
public void setAuxiliaryClasses(Hashtable auxClasses) {
_auxClasses = auxClasses;
}
|
public void setDOMCache(DOMCache cache) {
_domCache = cache;
}
Sets the DOM cache used for additional documents loaded using the
document() function. |
public void setIndexSize(int size) {
if (size > _indexSize) _indexSize = size;
}
This method is used to pass the largest DOM size to the translet.
Needed to make sure that the translet can index the whole DOM. |
public void setKeyIndexDom(String name,
DOM document) {
getKeyIndex(name).setDom(document, document.getDocument());
}
This method builds key indexes - it is overridden in the compiled
translet in cases where the element is used |
public final void setMessageHandler(MessageHandler handler) {
_msgHandler = handler;
}
Set the translet's message handler - must implement MessageHandler |
public void setTemplates(Templates templates) {
_templates = templates;
}
|
protected void transferOutputSettings(SerializationHandler handler) {
if (_method != null) {
if (_method.equals("xml")) {
if (_standalone != null) {
handler.setStandalone(_standalone);
}
if (_omitHeader) {
handler.setOmitXMLDeclaration(true);
}
handler.setCdataSectionElements(_cdata);
if (_version != null) {
handler.setVersion(_version);
}
handler.setIndent(_indent);
handler.setIndentAmount(_indentamount);
if (_doctypeSystem != null) {
handler.setDoctype(_doctypeSystem, _doctypePublic);
}
}
else if (_method.equals("html")) {
handler.setIndent(_indent);
handler.setDoctype(_doctypeSystem, _doctypePublic);
if (_mediaType != null) {
handler.setMediaType(_mediaType);
}
}
}
else {
handler.setCdataSectionElements(_cdata);
if (_version != null) {
handler.setVersion(_version);
}
if (_standalone != null) {
handler.setStandalone(_standalone);
}
if (_omitHeader) {
handler.setOmitXMLDeclaration(true);
}
handler.setIndent(_indent);
handler.setDoctype(_doctypeSystem, _doctypePublic);
}
}
Transfer the output settings to the output post-processor |
public final void transform(DOM document,
SerializationHandler handler) throws TransletException {
try {
transform(document, document.getIterator(), handler);
} finally {
_keyIndexes = null;
}
}
Calls transform() with a given output handler |
abstract public void transform(DOM document,
DTMAxisIterator iterator,
SerializationHandler handler) throws TransletException
Main transform() method - this is overridden by the compiled translet |