Author: thorsten
Date: Wed Sep 24 03:47:59 2008
New Revision: 698516
URL: http://svn.apache.org/viewvc?rev=698516&view=rev
Log:
Extracting all captions that are most likely reused to a class on its one
Added:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/Captions.java
(with props)
Modified:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java
Modified:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java
URL:
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java?rev=698516&r1=698515&r2=698516&view=diff
==============================================================================
---
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java
(original)
+++
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java
Wed Sep 24 03:47:59 2008
@@ -25,36 +25,13 @@
import org.apache.forrest.dispatcher.config.DispatcherBean;
import org.apache.forrest.dispatcher.exception.DispatcherException;
import org.apache.forrest.dispatcher.factories.ContractFactory;
+import org.apache.forrest.dispatcher.impl.helper.Captions;
import org.apache.forrest.dispatcher.impl.helper.StAX;
import org.apache.forrest.dispatcher.utils.CommonString;
import org.xml.sax.InputSource;
public class XMLStructurer extends StAX implements Structurer {
- public static final String NS = "http://apache.org/forrest/templates/2.0";
-
- public static final String STRUCTURER_ELEMENT = "structurer";
-
- public static final String STRUCTURE_ELEMENT = "structure";
-
- public static final String TYPE_ATT = "type";
-
- public static final String HOOKS_ATT = "hooksXpath";
-
- public static final String CONTRACT_ELEMENT = "contract";
-
- public static final String NAME_ATT = "name";
-
- public static final String DATA_ATT = "dataURI";
-
- public static final String PROPERTY_ELEMENT = "property";
-
- public static final String HOOK_ELEMENT = "hook";
-
- private static final Object VALUE_ATT = "value";
-
- private static final Object CONTRACT_RESULT_XPATH = "xpath";
-
private final Resolver resolver;
private final boolean allowXmlProperties;
@@ -88,15 +65,15 @@
case XMLStreamConstants.START_ELEMENT:
String elementName = reader.getLocalName();
- if (elementName.equals(STRUCTURE_ELEMENT)) {
+ if (elementName.equals(Captions.STRUCTURE_ELEMENT)) {
String m_type = "", path = "";
// Get attribute names
for (int i = 0; i < reader.getAttributeCount(); i++) {
String localName = reader.getAttributeLocalName(i);
- if (localName.equals(TYPE_ATT)) {
+ if (localName.equals(Captions.TYPE_ATT)) {
// Return value
m_type = reader.getAttributeValue(i);
- } else if (localName.equals(HOOKS_ATT)) {
+ } else if (localName.equals(Captions.HOOKS_ATT)) {
path = reader.getAttributeValue(i);
}
}
@@ -144,22 +121,22 @@
switch (event) {
case XMLStreamConstants.END_ELEMENT:
elementName = reader.getLocalName();
- if (elementName.equals(STRUCTURE_ELEMENT)) {
+ if (elementName.equals(Captions.STRUCTURE_ELEMENT)) {
XMLEventWriter writer = getWriter(out);
createResultStax(writer);
resultTree.clear();
process = false;
- }else if (elementName.equals(HOOK_ELEMENT)){
+ }else if (elementName.equals(Captions.HOOK_ELEMENT)){
processHook(reader, false);
}
break;
case XMLStreamConstants.START_ELEMENT:
elementName = reader.getLocalName();
- if (elementName.equals(CONTRACT_ELEMENT)) {
+ if (elementName.equals(Captions.CONTRACT_ELEMENT)) {
log.debug("Path " + currentPath);
processContract(reader);
- } else if (elementName.equals(HOOK_ELEMENT)) {
+ } else if (elementName.equals(Captions.HOOK_ELEMENT)) {
log.debug("HOOKS " + elementName);
processHook(reader, true);
log.info("HOOKS transformation NOT YET IMPLEMENTED");
@@ -230,10 +207,10 @@
// Get attribute names
for (int i = 0; i < reader.getAttributeCount(); i++) {
String localName = reader.getAttributeLocalName(i);
- if (localName.equals(NAME_ATT)) {
+ if (localName.equals(Captions.NAME_ATT)) {
// Return value
name = reader.getAttributeValue(i);
- } else if (localName.equals(DATA_ATT)) {
+ } else if (localName.equals(Captions.DATA_ATT)) {
data = reader.getAttributeValue(i);
}
}
@@ -250,7 +227,7 @@
switch (event) {
case XMLStreamConstants.END_ELEMENT:
elementName = reader.getLocalName();
- if (elementName.equals(CONTRACT_ELEMENT)) {
+ if (elementName.equals(Captions.CONTRACT_ELEMENT)) {
InputStream resultStream = contract.execute(dataStream, param);
if (null != dataStream) {
dataStream.close();
@@ -265,7 +242,7 @@
case XMLStreamConstants.START_ELEMENT:
elementName = reader.getLocalName();
- if (elementName.equals(PROPERTY_ELEMENT)) {
+ if (elementName.equals(Captions.PROPERTY_ELEMENT)) {
processProperty(reader, param);
}
break;
@@ -291,7 +268,7 @@
// Get attribute names
for (int i = 0; i < contractResultReader.getAttributeCount(); i++) {
String localName = contractResultReader.getAttributeLocalName(i);
- if (localName.equals(CONTRACT_RESULT_XPATH)) {
+ if (localName.equals(Captions.CONTRACT_RESULT_XPATH)) {
// Return value
xpath = contractResultReader.getAttributeValue(i);
}
@@ -377,10 +354,10 @@
// Get attribute names
for (int i = 0; i < reader.getAttributeCount(); i++) {
String localName = reader.getAttributeLocalName(i);
- if (localName.equals(NAME_ATT)) {
+ if (localName.equals(Captions.NAME_ATT)) {
// Return value
propertyName = reader.getAttributeValue(i);
- } else if (localName.equals(VALUE_ATT)) {
+ } else if (localName.equals(Captions.VALUE_ATT)) {
propertyValue = reader.getAttributeValue(i);
}
}
@@ -405,7 +382,7 @@
currentEvent = allocator.allocate(reader);
switch (event) {
case XMLStreamConstants.END_ELEMENT:
- if (reader.getLocalName().equals(PROPERTY_ELEMENT)) {
+ if (reader.getLocalName().equals(Captions.PROPERTY_ELEMENT)) {
writerProperty.add(currentEvent);
writerProperty.flush();
writerProperty.close();
Added:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/Captions.java
URL:
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/Captions.java?rev=698516&view=auto
==============================================================================
---
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/Captions.java
(added)
+++
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/Captions.java
Wed Sep 24 03:47:59 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.dispatcher.impl.helper;
+
+public class Captions {
+ /*
+ * structurer captions
+ */
+ public static final String NS = "http://apache.org/forrest/templates/2.0";
+
+ public static final String STRUCTURER_ELEMENT = "structurer";
+
+ public static final String STRUCTURE_ELEMENT = "structure";
+
+ public static final String TYPE_ATT = "type";
+
+ public static final String HOOKS_ATT = "hooksXpath";
+
+ public static final String CONTRACT_ELEMENT = "contract";
+
+ public static final String NAME_ATT = "name";
+
+ public static final String DATA_ATT = "dataURI";
+
+ public static final String PROPERTY_ELEMENT = "property";
+
+ public static final String HOOK_ELEMENT = "hook";
+
+ public static final String VALUE_ATT = "value";
+
+ public static final String CONTRACT_RESULT_XPATH = "xpath";
+
+ /*
+ * Contract captions
+ */
+
+ public static final String CONTRACT_NAME_ATT = "name";
+
+ public static final String DESCRIPTION_ELEMENT = "description";
+
+ public static final String TEMPLATE_ELEMENT = "template";
+
+ public static final String TEMPLATE_FORMAT_ATT = "inputFormat";
+
+ public static final String USAGE_ELEMENT = "usage";
+
+ public static final String RESULT_XPATH = "xpath";
+
+}
Propchange:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/Captions.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java
URL:
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java?rev=698516&r1=698515&r2=698516&view=diff
==============================================================================
---
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java
(original)
+++
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java
Wed Sep 24 03:47:59 2008
@@ -50,22 +50,6 @@
private Transformer transformer = null;
- public static final String NS = "http://apache.org/forrest/templates/2.0";
-
- public static final String CONTRACT_ELEMENT = "contract";
-
- public static final String CONTRACT_NAME_ATT = "name";
-
- public static final String DESCRIPTION_ELEMENT = "description";
-
- public static final String TEMPLATE_ELEMENT = "template";
-
- public static final String TEMPLATE_FORMAT_ATT = "inputFormat";
-
- public static final String USAGE_ELEMENT = "usage";
-
- public static final String RESULT_XPATH = "xpath";
-
/**
* This method will prepare the transformation from the data and the xsl
* stylesheet from the contract.
@@ -160,17 +144,17 @@
case XMLStreamConstants.START_ELEMENT:
String localName = reader.getLocalName();
- if (localName.equals(CONTRACT_ELEMENT)) {
+ if (localName.equals(Captions.CONTRACT_ELEMENT)) {
contract.setName(processContract(reader));
}
- if (localName.equals(DESCRIPTION_ELEMENT)) {
+ if (localName.equals(Captions.DESCRIPTION_ELEMENT)) {
contract.setDescription(processDescription(reader));
}
- if (localName.equals(USAGE_ELEMENT)) {
+ if (localName.equals(Captions.USAGE_ELEMENT)) {
contract.setUsage(processUsage(reader));
}
- if (localName.equals(TEMPLATE_ELEMENT)) {
+ if (localName.equals(Captions.TEMPLATE_ELEMENT)) {
contract.setXslSource(processTemplate(reader));
}
@@ -189,7 +173,7 @@
for (int i = 0; i < reader.getAttributeCount(); i++) {
// Get attribute name
String localName = reader.getAttributeLocalName(i);
- if (localName.equals(TEMPLATE_FORMAT_ATT)) {
+ if (localName.equals(Captions.TEMPLATE_FORMAT_ATT)) {
// Return value
role = reader.getAttributeValue(i);
}
@@ -202,8 +186,8 @@
case XMLStreamConstants.END_ELEMENT:
if (reader.getNamespaceURI() != null) {
- if (reader.getNamespaceURI().equals(NS)
- & reader.getLocalName().equals(TEMPLATE_ELEMENT)) {
+ if (reader.getNamespaceURI().equals(Captions.NS)
+ & reader.getLocalName().equals(Captions.TEMPLATE_ELEMENT)) {
process = false;
} else {
allocator.allocate(reader,writer);
@@ -240,7 +224,7 @@
break;
case XMLStreamConstants.END_ELEMENT:
- if (reader.getLocalName().equals(USAGE_ELEMENT)) {
+ if (reader.getLocalName().equals(Captions.USAGE_ELEMENT)) {
process = false;
}
break;
@@ -267,7 +251,7 @@
break;
case XMLStreamConstants.END_ELEMENT:
- if (reader.getLocalName().equals(DESCRIPTION_ELEMENT)) {
+ if (reader.getLocalName().equals(Captions.DESCRIPTION_ELEMENT)) {
process = false;
}
break;
@@ -285,7 +269,7 @@
for (int i = 0; i < reader.getAttributeCount(); i++) {
// Get attribute name
String localName = reader.getAttributeLocalName(i);
- if (localName.equals(CONTRACT_NAME_ATT)) {
+ if (localName.equals(Captions.CONTRACT_NAME_ATT)) {
// Return value
contractName = reader.getAttributeValue(i);
return contractName;