| Method from org.apache.cocoon.transformation.FragmentExtractorTransformer Detail: |
public void characters(char[] c,
int start,
int len) throws SAXException {
if (extractLevel == 0) {
super.characters(c, start, len);
} else {
this.serializer.characters(c, start, len);
}
}
Receive notification of character data. |
public void comment(char[] ch,
int start,
int len) throws SAXException {
if (extractLevel == 0) {
super.comment(ch, start, len);
} else {
this.serializer.comment(ch, start, len);
}
}
Report an XML comment anywhere in the document. |
public void configure(Configuration conf) throws ConfigurationException {
this.extractURI = conf.getChild(EXTRACT_URI_NAME).getValue(EXTRACT_URI);
this.extractElement = conf.getChild(EXTRACT_ELEMENT_NAME).getValue(EXTRACT_ELEMENT);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Extraction URI is " + this.extractURI);
getLogger().debug("Extraction element is " + this.extractElement);
}
}
Configure this transformer. |
public void dispose() {
recycle();
this.manager = null;
}
|
public void endCDATA() throws SAXException {
if (extractLevel == 0) {
super.endCDATA();
} else {
this.serializer.endCDATA();
}
}
Report the end of a CDATA section. |
public void endDTD() throws SAXException {
if (extractLevel == 0) {
super.endDTD();
} else {
throw new SAXException(
"Recieved endDTD after beginning fragment extraction process."
);
}
}
Report the end of DTD declarations. |
public void endElement(String uri,
String loc,
String raw) throws SAXException {
if (extractLevel == 0) {
super.endElement(uri, loc, raw);
} else {
this.serializer.endElement(uri, loc, raw);
if (uri == null) uri = "";
if (this.extractURI.equals(uri) && this.extractElement.equals(loc)) {
extractLevel--;
if (getLogger().isDebugEnabled()) {
getLogger().debug("extractLevel now " + extractLevel + ".");
}
if (extractLevel == 0) {
// finish building the fragment. remove existing prefix mappings.
Iterator itt = prefixMap.entrySet().iterator();
while (itt.hasNext()) {
Map.Entry entry = (Map.Entry) itt.next();
this.serializer.endPrefixMapping(
(String)entry.getKey()
);
}
this.serializer.endDocument();
Store store = null;
String id = Long.toHexString((hashCode()^HashUtil.hash(requestURI)) + fragmentID);
try {
store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);
store.store(id, this.serializer.getSAXFragment());
} catch (ServiceException se) {
throw new SAXException("Could not lookup for transient store.", se);
} catch (IOException ioe) {
throw new SAXException("Could not store fragment.", ioe);
} finally {
this.manager.release(store);
this.manager.release(this.serializer);
this.serializer = null;
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Stored document " + id + ".");
}
// Insert ref.
super.startPrefixMapping("fe", FE_URI);
AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "fragment-id", "fragment-id", "CDATA", id);
super.startElement(FE_URI, "fragment", "fe:fragment", atts);
super.endElement(FE_URI, "fragment", "fe:fragment");
super.endPrefixMapping("fe");
}
}
}
}
Receive notification of the end of an element. |
public void endEntity(String name) throws SAXException {
if (extractLevel == 0) {
super.endEntity(name);
} else {
this.serializer.endEntity(name);
}
}
Report the end of an entity. |
public void endPrefixMapping(String prefix) throws SAXException {
if (extractLevel == 0) {
super.endPrefixMapping(prefix);
prefixMap.remove(prefix);
} else {
this.serializer.endPrefixMapping(prefix);
}
}
End the scope of a prefix-URI mapping. |
public Serializable getKey() {
return "1";
}
Generate the unique key.
This key must be unique inside the space of this component. |
public SourceValidity getValidity() {
return NOPValidity.SHARED_INSTANCE;
}
Generate the validity object. |
public void ignorableWhitespace(char[] c,
int start,
int len) throws SAXException {
if (extractLevel == 0) {
super.ignorableWhitespace(c, start, len);
} else {
this.serializer.ignorableWhitespace(c, start, len);
}
}
Receive notification of ignorable whitespace in element content. |
public void processingInstruction(String target,
String data) throws SAXException {
if (extractLevel == 0) {
super.processingInstruction(target, data);
} else {
this.serializer.processingInstruction(target, data);
}
}
Receive notification of a processing instruction. |
public void recycle() {
if (this.manager != null) {
this.manager.release(serializer);
this.serializer = null;
}
super.recycle();
}
|
public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
}
Set the current ServiceManager instance used by this
Serviceable. |
public void setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws IOException, SAXException, ProcessingException {
extractLevel = 0;
fragmentID = 0;
prefixMap = new HashMap();
this.requestURI = ObjectModelHelper.getRequest(objectModel).getSitemapURI();
}
|
public void skippedEntity(String name) throws SAXException {
if (extractLevel == 0) {
super.skippedEntity(name);
} else {
this.serializer.skippedEntity(name);
}
}
Receive notification of a skipped entity. |
public void startCDATA() throws SAXException {
if (extractLevel == 0) {
super.startCDATA();
} else {
this.serializer.startCDATA();
}
}
Report the start of a CDATA section. |
public void startDTD(String name,
String publicId,
String systemId) throws SAXException {
if (extractLevel == 0) {
super.startDTD(name, publicId, systemId);
} else {
throw new SAXException(
"Recieved startDTD after beginning fragment extraction process."
);
}
}
Report the start of DTD declarations, if any. |
public void startElement(String uri,
String loc,
String raw,
Attributes a) throws SAXException {
if (uri == null) uri = "";
if (this.extractURI.equals(uri) && this.extractElement.equals(loc)) {
extractLevel++;
fragmentID++;
if (getLogger().isDebugEnabled()) {
getLogger().debug("extractLevel now " + extractLevel + ".");
}
try {
this.serializer = (XMLSerializer) this.manager.lookup(XMLSerializer.ROLE);
} catch (ServiceException se) {
throw new SAXException("Could not lookup for XMLSerializer.", se);
}
// Start the DOM document
this.serializer.startDocument();
Iterator itt = prefixMap.entrySet().iterator();
while (itt.hasNext()) {
Map.Entry entry = (Map.Entry)itt.next();
this.serializer.startPrefixMapping(
(String)entry.getKey(),
(String)entry.getValue()
);
}
}
if (extractLevel == 0) {
super.startElement(uri, loc, raw, a);
} else {
this.serializer.startElement(uri, loc, raw, a);
}
}
Receive notification of the beginning of an element. |
public void startEntity(String name) throws SAXException {
if (extractLevel == 0) {
super.startEntity(name);
} else {
this.serializer.startEntity(name);
}
}
Report the beginning of an entity. |
public void startPrefixMapping(String prefix,
String uri) throws SAXException {
if (extractLevel == 0) {
super.startPrefixMapping(prefix, uri);
prefixMap.put(prefix, uri);
} else {
this.serializer.startPrefixMapping(prefix, uri);
}
}
Begin the scope of a prefix-URI Namespace mapping. |