You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by th...@apache.org on 2009/08/31 15:25:14 UTC
svn commit: r809576 -
/forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java
Author: thorsten
Date: Mon Aug 31 13:25:14 2009
New Revision: 809576
URL: http://svn.apache.org/viewvc?rev=809576&view=rev
Log:
white noise - formating changes
Modified:
forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java
Modified: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java
URL: http://svn.apache.org/viewvc/forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java?rev=809576&r1=809575&r2=809576&view=diff
==============================================================================
--- forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java (original)
+++ forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java Mon Aug 31 13:25:14 2009
@@ -170,7 +170,7 @@
public void setManager(ServiceManager manager) {
this.manager = manager;
}
-
+
/**
* The level of xpath support we need.
* <p>
@@ -242,10 +242,10 @@
private InputStream dataStream;
private String prefixString;
-
+
private TransformerFactory tfactory = TransformerFactory.newInstance();
- private EntityResolver entityResolver;
+ private EntityResolver entityResolver;
/*
* @see
@@ -259,7 +259,8 @@
config = new WritableDispatcherBean();
config.setStaxHelper(new StAX());
// are we allowing xml properties?
- boolean allowXml = configuration.getChild("allowXml").getValueAsBoolean(false);
+ boolean allowXml = configuration.getChild("allowXml").getValueAsBoolean(
+ false);
config.setAllowXmlProperties(allowXml);
// set the prefix for the contract resolving
contractUriPrefix = configuration.getChild("contractUriPrefix").getValue(
@@ -278,9 +279,9 @@
try {
setNewTransformerFactory();
} catch (ProcessingException e) {
- throw new ConfigurationException(e.getLocalizedMessage(),e);
+ throw new ConfigurationException(e.getLocalizedMessage(), e);
} catch (TransformerFactoryConfigurationError e) {
- throw new ConfigurationException(e.getLocalizedMessage(),e);
+ throw new ConfigurationException(e.getLocalizedMessage(), e);
}
}
@@ -290,10 +291,11 @@
*
* @param config
* the configuration to use.
- * @throws TransformerFactoryConfigurationError
- * @throws ProcessingException
+ * @throws TransformerFactoryConfigurationError
+ * @throws ProcessingException
*/
- public void setConfig(WritableDispatcherBean config) throws ProcessingException, TransformerFactoryConfigurationError {
+ public void setConfig(WritableDispatcherBean config)
+ throws ProcessingException, TransformerFactoryConfigurationError {
this.config = config;
if (config.getTransFact() == null) {
setNewTransformerFactory();
@@ -305,7 +307,7 @@
* Will prepare the factories that we need in further processing
*
* @throws TransformerFactoryConfigurationError
- * @throws ProcessingException
+ * @throws ProcessingException
*/
private void setNewTransformerFactory()
throws TransformerFactoryConfigurationError, ProcessingException {
@@ -323,7 +325,7 @@
parser = (SAXParser) manager.lookup(SAXParser.ROLE);
} catch (ServiceException e) {
String error = "dispatcherError:\n"
- + "SAXParser could not be setup! Abort";
+ + "SAXParser could not be setup! Abort";
getLogger().error(error);
throw new ProcessingException(error);
}
@@ -412,7 +414,7 @@
if (this.insideProperties && this.includeNodes) {
// just start the recording
super.startElement(uri, name, raw, attr);
- //startSerializedXMLRecording(null);
+ // startSerializedXMLRecording(null);
} else if (Captions.NS.equals(uri)) {
// we are in the dispatcher ns
try {
@@ -431,9 +433,9 @@
contractProcessingStart(attr);
} else if (Captions.PROPERTY_ELEMENT.equals(name)) {
// we are inside a property element
- //this.insideProperties = true;
+ // this.insideProperties = true;
propertyProcessingStart(uri, name, raw, attr);
- }
+ }
}
} catch (Exception e) {
throw new SAXException(e);
@@ -441,7 +443,7 @@
} else {
// Do we want to allow to have structurer definitions as nested elements?
if (!this.insideProperties && this.includeNodes) {
- //super.startElement(uri, name, raw, attr);
+ // super.startElement(uri, name, raw, attr);
}
}
@@ -461,7 +463,7 @@
if (Captions.STRUCTURE_ELEMENT.equals(name)) {
// we are in a structurer end element
if (includeNodes) {
- includeNodes=false;
+ includeNodes = false;
}
} else if (Captions.HOOK_ELEMENT.equals(name) && this.includeNodes) {
// we are inside a hook end element
@@ -474,10 +476,12 @@
if (config.isAllowXmlProperties()) {
String property = null;
try {
- //XMLizable endSAXRecording = super.endSAXRecording();
- property = prefixString+endSerializedXMLRecording()+"</forrest:property>";
+ // XMLizable endSAXRecording = super.endSAXRecording();
+ property = prefixString + endSerializedXMLRecording()
+ + "</forrest:property>";
insideProperties = false;
- getLogger().debug("super.endSerializedXMLRecording(): "+property);
+ getLogger().debug(
+ "super.endSerializedXMLRecording(): " + property);
} catch (Exception e) {
throw new SAXException(e);
}
@@ -494,47 +498,43 @@
}
}
-
- public void characters(char c[], int start, int len)
- throws SAXException {
+ public void characters(char c[], int start, int len) throws SAXException {
/*
- * only if we in properties mode we want to record
- * the characters.
+ * only if we in properties mode we want to record the characters.
*/
- if (includeNodes && insideProperties){
+ if (includeNodes && insideProperties) {
super.characters(c, start, len);
}
}
-
+
public void startDocument() throws SAXException {
// Add the namespace filter to our own output.
RedundantNamespacesFilter nsPipe = new RedundantNamespacesFilter();
if (this.xmlConsumer != null) {
- nsPipe.setConsumer(this.xmlConsumer);
+ nsPipe.setConsumer(this.xmlConsumer);
} else {
- nsPipe.setContentHandler(this.contentHandler);
+ nsPipe.setContentHandler(this.contentHandler);
}
setConsumer(nsPipe);
}
-
- public void endDocument()
- throws SAXException {
+
+ public void endDocument() throws SAXException {
structurerProcessingEnd();
}
-
+
/*
* do nothing on the following methods, since we do not use them
*/
public void ignorableWhitespace(char c[], int start, int len)
- throws SAXException {
+ throws SAXException {
}
-
+
public void startCDATA() throws SAXException {
}
public void endCDATA() throws SAXException {
}
-
+
public void comment(char[] ary, int start, int length) throws SAXException {
}
@@ -597,7 +597,7 @@
// get the children of a part. This children needs to be injected in
// the result
Iterator<OMNode> children = part.getChildren();
-
+
if (xpath == null) {
// when we do not have a xpath to inject we will inject it in the
// current loaction
@@ -607,10 +607,10 @@
}
} else {
// make sure the xpath is starting with "/"
- if (!xpath.startsWith("/")){
- String message = contract.getName() +
- " is using relative injection points which is not permited. "+
- "Please fix this ASAP, for now we will do it for you.";
+ if (!xpath.startsWith("/")) {
+ String message = contract.getName()
+ + " is using relative injection points which is not permited. "
+ + "Please fix this ASAP, for now we will do it for you.";
getLogger().warn(message);
xpath = "/" + xpath;
}
@@ -666,26 +666,26 @@
* Finish the processing of the structurer
*
* @param raw
- * @throws SAXException
+ * @throws SAXException
*/
private void structurerProcessingEnd() throws SAXException {
try {
- // get the result of the structurer as stream
+ // get the result of the structurer as stream
ByteArrayOutputStream out = new ByteArrayOutputStream();
OMElement firstElement = root.getFirstElement();
- if (null!=firstElement){
+ if (null != firstElement) {
firstElement.serialize(out);
- }else{
+ } else {
root.serialize(out);
}
-
+
InputSource is = new InputSource(new StringReader(out.toString()));
- // adding the result to the consumer
+ // adding the result to the consumer
parser.parse(is, super.xmlConsumer);
} catch (Exception e) {
throw new SAXException(e);
}
-
+
}
/**
@@ -702,11 +702,11 @@
Attributes attr) throws SAXException {
// determine the name and a possible value
String id = null, value = null;
- String attributesString ="";
+ String attributesString = "";
for (int i = 0; i < attr.getLength(); i++) {
String localName = attr.getLocalName(i);
String localValue = attr.getValue(i);
- attributesString += " "+localName+"=\""+localValue+"\"";
+ attributesString += " " + localName + "=\"" + localValue + "\"";
if (Captions.NAME_ATT.equals(localName)) {
id = localValue;
} else if (Captions.VALUE_ATT.equals(localName)) {
@@ -716,8 +716,8 @@
currentProperty = id;
// if we allow xml properties we will just record them
if (config.isAllowXmlProperties()) {
- // just start the recording
- prefixString = "<"+raw+attributesString+">";
+ // just start the recording
+ prefixString = "<" + raw + attributesString + ">";
startSerializedXMLRecording((XMLUtils.createPropertiesForXML(true)));
insideProperties = true;
} else {
@@ -738,33 +738,32 @@
*/
private void contractProcessingStart(Attributes attr) throws SAXException {
String name = "", data = null;
- for (int i = 0; i < attr.getLength(); i++) {
- String localName = attr.getLocalName(i);
- String value = attr.getValue(i);
- if (Captions.NAME_ATT.equals(localName)) {
- // get the name of the contract
- name = value;
- } else if (Captions.DATA_ATT.equals(localName)) {
- // see whether we have a defined dataUri
- data = value;
- }
+ for (int i = 0; i < attr.getLength(); i++) {
+ String localName = attr.getLocalName(i);
+ String value = attr.getValue(i);
+ if (Captions.NAME_ATT.equals(localName)) {
+ // get the name of the contract
+ name = value;
+ } else if (Captions.DATA_ATT.equals(localName)) {
+ // see whether we have a defined dataUri
+ data = value;
}
- dataStream = null;
- if (null != data && !data.equals("")) {
- // try resolving the dataUri
- try {
- dataStream = resolverDispatcher.resolve(data);
- } catch (Exception e) {
- String error = DispatcherException.ERROR_500 + "\n"
- + "component: ContractBean" + "\n"
- + "message: ContractBean \"" +name+ "\" has thrown an exception "
- + "resolving the dataUri \""+data+"\".\n\n"
- + "dispatcherErrorStack:\n" + e;
- getLogger().error(error);
- throw new SAXException(error);
}
- }
+ dataStream = null;
+ if (null != data && !data.equals("")) {
+ // try resolving the dataUri
try {
+ dataStream = resolverDispatcher.resolve(data);
+ } catch (Exception e) {
+ String error = DispatcherException.ERROR_500 + "\n"
+ + "component: ContractBean" + "\n" + "message: ContractBean \""
+ + name + "\" has thrown an exception " + "resolving the dataUri \""
+ + data + "\".\n\n" + "dispatcherErrorStack:\n" + e;
+ getLogger().error(error);
+ throw new SAXException(error);
+ }
+ }
+ try {
// get the contract
contract = contractRep.resolve(name);
@@ -774,7 +773,7 @@
} catch (Exception e) {
String error = DispatcherException.ERROR_500 + "\n"
+ "component: ContractBean" + "\n"
- + "message: Could not setup contractBean \"" +name+ "\".\n\n"
+ + "message: Could not setup contractBean \"" + name + "\".\n\n"
+ "dispatcherErrorStack:\n" + e;
getLogger().error(error);
throw new SAXException(error);
@@ -900,7 +899,6 @@
}
-
/**
* Generate the unique key. This key must be unique inside the space of this
* component.
@@ -950,7 +948,8 @@
*/
public void service(ServiceManager manager) throws ServiceException {
super.service(manager);
- this.entityResolver = (EntityResolver) this.manager.lookup(org.apache.excalibur.xml.EntityResolver.ROLE);
+ this.entityResolver = (EntityResolver) this.manager
+ .lookup(org.apache.excalibur.xml.EntityResolver.ROLE);
}
/**
@@ -971,15 +970,15 @@
*/
public void recycle() {
this.includeNodes = false;
- this.insideProperties= false;
- this.requestId= "";
+ this.insideProperties = false;
+ this.requestId = "";
this.validity = null;
- this.root=null;
- this.pathNode=null;
- this.contract=null;
- this.map=null;
- this.localParams=null;
- this.currentProperty=null;
+ this.root = null;
+ this.pathNode = null;
+ this.contract = null;
+ this.map = null;
+ this.localParams = null;
+ this.currentProperty = null;
super.recycle();
}
@@ -1065,7 +1064,8 @@
/**
* Return a new <code>InputSource</code> object that uses the <code>
- * InputStream</code> and the system ID of the <code>Source</code> object.
+ * InputStream</code>
+ * and the system ID of the <code>Source</code> object.
*
* @throws IOException
* if I/O error occured.