Base class for XSP's object model manipulation logicsheets
| Method from org.apache.cocoon.components.language.markup.xsp.XSPObjectHelper Detail: |
protected static void addAttribute(AttributesImpl attr,
String name,
String value) throws SAXException {
attr.addAttribute("", name, name, "CDATA", value);
}
|
protected static void data(ContentHandler contentHandler,
String data) throws SAXException {
contentHandler.characters(data.toCharArray(), 0, data.length());
}
|
protected static void elementData(String uri,
String prefix,
ContentHandler contentHandler,
String name,
String data) throws SAXException {
start(uri, prefix, contentHandler, name);
data(contentHandler, data);
end(uri, prefix, contentHandler, name);
}
Output an element containing text only and no attributes |
protected static void elementData(String uri,
String prefix,
ContentHandler contentHandler,
String name,
String data,
AttributesImpl attr) throws SAXException {
start(uri, prefix, contentHandler, name, attr);
data(contentHandler, data);
end(uri, prefix, contentHandler, name);
}
Output an element containing text only and attributes |
protected static void end(String uri,
String prefix,
ContentHandler contentHandler,
String name) throws SAXException {
contentHandler.endElement(uri, name, prefix + ":" + name);
}
End an element with the proper object's uri and prefix |
protected static void start(String uri,
String prefix,
ContentHandler contentHandler,
String name) throws SAXException {
contentHandler.startElement(uri, name, prefix + ":" + name, XMLUtils.EMPTY_ATTRIBUTES);
}
Start an element with the proper object's uri and prefix and no
attributes |
protected static void start(String uri,
String prefix,
ContentHandler contentHandler,
String name,
AttributesImpl attr) throws SAXException {
contentHandler.startElement(uri, name, prefix + ":" + name, attr);
}
Start an element with the proper object's uri and prefix and with
attributes |
public static void xspExpr(ContentHandler contentHandler,
char v) throws SAXException {
data(contentHandler, String.valueOf(v));
}
Implementation of <xsp:expr> for char :
outputs characters representing the value. |
public static void xspExpr(ContentHandler contentHandler,
byte v) throws SAXException {
data(contentHandler, String.valueOf(v));
}
Implementation of <xsp:expr> for byte :
outputs characters representing the value. |
public static void xspExpr(ContentHandler contentHandler,
boolean v) throws SAXException {
data(contentHandler, String.valueOf(v));
}
Implementation of <xsp:expr> for boolean :
outputs characters representing the value (true / false). |
public static void xspExpr(ContentHandler contentHandler,
int v) throws SAXException {
data(contentHandler, String.valueOf(v));
}
Implementation of <xsp:expr> for int :
outputs characters representing the value. |
public static void xspExpr(ContentHandler contentHandler,
long v) throws SAXException {
data(contentHandler, String.valueOf(v));
}
Implementation of <xsp:expr> for long :
outputs characters representing the value. |
public static void xspExpr(ContentHandler contentHandler,
float v) throws SAXException {
data(contentHandler, String.valueOf(v));
}
Implementation of <xsp:expr> for long :
outputs characters representing the value. |
public static void xspExpr(ContentHandler contentHandler,
double v) throws SAXException {
data(contentHandler, String.valueOf(v));
}
Implementation of <xsp:expr> for double :
outputs characters representing the value. |
public static void xspExpr(ContentHandler contentHandler,
String text) throws SAXException {
if (text != null) {
data(contentHandler, text);
}
}
Implementation of <xsp:expr> for String :
outputs characters representing the value. |
public static void xspExpr(ContentHandler contentHandler,
XMLizable v) throws SAXException {
if (v != null) {
v.toSAX(contentHandler);
}
}
Implementation of <xsp:expr> for XMLizable :
outputs the value by calling v.toSax(contentHandler). |
public static void xspExpr(ContentHandler contentHandler,
Node v) throws SAXException {
if (v != null) {
DOMStreamer streamer = new DOMStreamer(contentHandler);
streamer.stream(v);
}
}
Implementation of <xsp:expr> for org.w3c.dom.Node :
converts the Node to a SAX event stream. |
public static void xspExpr(ContentHandler contentHandler,
Collection v) throws SAXException {
if (v != null) {
Iterator iterator = v.iterator();
while (iterator.hasNext()) {
xspExpr(contentHandler, iterator.next());
}
}
}
Implementation of <xsp:expr> for java.util.Collection :
outputs the value by calling xspExpr() on each element of the
collection. |
public static void xspExpr(ContentHandler contentHandler,
Object v) throws SAXException {
if (v == null) {
return;
}
// Array: recurse over each element
if (v.getClass().isArray()) {
Object[] elements = (Object[]) v;
for (int i = 0; i < elements.length; i++) {
xspExpr(contentHandler, elements[i]);
}
return;
}
// Check handled object types in case they were not typed in the XSP
// XMLizable
if (v instanceof XMLizable) {
xspExpr(contentHandler, (XMLizable) v);
return;
}
// Now handled by XMLizable
// // XMLFragment
// if (v instanceof XMLFragment)
// {
// xspExpr(contentHandler, (XMLFragment)v);
// return;
// }
// Node
if (v instanceof Node) {
xspExpr(contentHandler, (Node) v);
return;
}
// Collection
if (v instanceof Collection) {
xspExpr(contentHandler, (Collection) v);
return;
}
// Give up: hope it's a string or has a meaningful string representation
data(contentHandler, String.valueOf(v));
}
Implementation of <xsp:expr> for Object depending on its class :
- if it's an array, call
xspExpr() on all its elements,
- if it's class has a specific
xspExpr()implementation, use it,
- else, output it's string representation.
|