Author: Alex.Kolonitsky
Date: 2010-05-06 04:41:13 -0400 (Thu, 06 May 2010)
New Revision: 16906
Modified:
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/XIncludeTransformer.java
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/xpointer/XPointerContext.java
Log:
fix checkstyle
Modified:
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/XIncludeTransformer.java
===================================================================
---
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/XIncludeTransformer.java 2010-05-06
03:58:58 UTC (rev 16905)
+++
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/sax/XIncludeTransformer.java 2010-05-06
08:41:13 UTC (rev 16906)
@@ -1,4 +1,3 @@
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,15 +15,9 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+*/
package org.apache.cocoon.pipeline.component.sax;
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
import org.apache.cocoon.pipeline.component.xpointer.XPointer;
import org.apache.cocoon.pipeline.component.xpointer.XPointerContext;
import org.apache.cocoon.pipeline.component.xpointer.parser.ParseException;
@@ -40,6 +33,12 @@
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.XMLReaderFactory;
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
public final class XIncludeTransformer implements SAXConsumer {
private static final String DEFAULT_CHARSET = "UTF-8";
private static final String HTTP_ACCEPT = "Accept";
@@ -56,12 +55,17 @@
private static final String XINCLUDE_PARSE_TEXT = "text";
private static final String XINCLUDE_PARSE_XML = "xml";
private static final String XINCLUDE_XPOINTER = "xpointer";
- private final Logger LOG ;
- /** The nesting level of fallback that should be used */
+ private final Logger log;
+
+ /**
+ * The nesting level of fallback that should be used
+ */
private int useFallbackLevel = 0;
- /** The nesting level of xi:include elements that have been encountered. */
+ /**
+ * The nesting level of xi:include elements that have been encountered.
+ */
private int xIncludeElementLevel = 0;
/**
@@ -72,7 +76,9 @@
private URI baseUri;
private ContentHandler contentHandler;
- /** The nesting level of xi:fallback elements that have been encountered. */
+ /**
+ * The nesting level of xi:fallback elements that have been encountered.
+ */
private int fallbackElementLevel;
private LexicalHandler lexicalHandler;
@@ -84,16 +90,17 @@
private EntityResolver2 resolver;
public XIncludeTransformer(Logger log) {
- this.LOG = log;
+ this.log = log;
}
- public XIncludeTransformer(URI baseUri,Logger log) {
+ public XIncludeTransformer(URI baseUri, Logger log) {
this(log);
this.setBaseUri(baseUri);
}
/**
* <p class="changed_added_4_0"></p>
+ *
* @return the resolver
*/
public EntityResolver2 getResolver() {
@@ -102,6 +109,7 @@
/**
* <p class="changed_added_4_0"></p>
+ *
* @param resolver the resolver to set
*/
public void setResolver(EntityResolver2 resolver) {
@@ -110,6 +118,7 @@
/**
* <p class="changed_added_4_0"></p>
+ *
* @return the contentHandler
*/
public ContentHandler getContentHandler() {
@@ -118,6 +127,7 @@
/**
* <p class="changed_added_4_0"></p>
+ *
* @return the lexicalHandler
*/
public LexicalHandler getLexicalHandler() {
@@ -222,21 +232,21 @@
}
private void processXIncludeElement(String href, String parse, String xpointer,
String encoding, String accept,
- String acceptLanguage) throws SAXException {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Processing XInclude element: href=" + href + ",
parse=" + parse + ", xpointer=" + xpointer
- + ", encoding=" + encoding + ", accept=" +
accept + ", acceptLanguage=" + acceptLanguage);
+ String acceptLanguage) throws SAXException {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Processing XInclude element: href=" + href + ",
parse=" + parse + ", xpointer=" + xpointer
+ + ", encoding=" + encoding + ", accept=" + accept +
", acceptLanguage=" + acceptLanguage);
}
int fragmentIdentifierPos = href.indexOf('#');
if (fragmentIdentifierPos != -1) {
- LOG.warn("Fragment identifer found in 'href' attribute: " +
href
- + "\nFragment identifiers are forbidden by the XInclude
specification. "
- + "They are still handled by XIncludeTransformer for backward
"
- + "compatibility, but their use is deprecated and will be
prohibited "
- + "in a future release. Use the 'xpointer' attribute
instead.");
+ log.warn("Fragment identifer found in 'href' attribute: " +
href
+ + "\nFragment identifiers are forbidden by the XInclude
specification. "
+ + "They are still handled by XIncludeTransformer for backward
"
+ + "compatibility, but their use is deprecated and will be prohibited
"
+ + "in a future release. Use the 'xpointer' attribute
instead.");
if (xpointer == null) {
xpointer = href.substring(fragmentIdentifierPos + 1);
@@ -253,15 +263,15 @@
InputSource source = createSource(href);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Parse type=" + parse);
+ if (log.isDebugEnabled()) {
+ log.debug("Parse type=" + parse);
}
if (XINCLUDE_PARSE_XML.equals(parse)) {
try {
if (xpointer != null && xpointer.length() > 0) {
XPointer xPointer = XPointerFrameworkParser.parse(xpointer);
- XPointerContext xPointerContext = new XPointerContext(xpointer,
source, this, resolver,LOG);
+ XPointerContext xPointerContext = new XPointerContext(xpointer,
source, this, resolver, log);
for (Entry<String, String> namespace : namespaces.entrySet())
{
xPointerContext.addPrefix(namespace.getKey(),
namespace.getValue());
@@ -282,13 +292,13 @@
// this exception is thrown in case of an invalid xpointer expression
useFallbackLevel++;
- LOG.info("Error parsing XPointer expression:
"+e.getMessage()+" , will try to use fallback.");
+ log.info("Error parsing XPointer expression: " + e.getMessage()
+ " , will try to use fallback.");
} catch (IOException e) {
useFallbackLevel++;
- LOG.info("Error processing an xInclude: "+e.getMessage()+"
will try to use fallback.");
+ log.info("Error processing an xInclude: " + e.getMessage() +
" will try to use fallback.");
} catch (SAXException e) {
useFallbackLevel++;
- LOG.info("Error processing an xInclude: "+e.getMessage()+"
will try to use fallback.");
+ log.info("Error processing an xInclude: " + e.getMessage() +
" will try to use fallback.");
}
} else if (XINCLUDE_PARSE_TEXT.equals(parse)) {
if (xpointer != null) {
@@ -307,7 +317,7 @@
// get from url.
} else {
useFallbackLevel++;
- LOG.error("Can't read XInclude href " + href + " at
" + getLocation());
+ log.error("Can't read XInclude href " + href + " at
" + getLocation());
}
} else {
throw new SAXException("Found 'parse' attribute with unknown
value " + parse + " at " + getLocation());
@@ -331,21 +341,21 @@
source = new InputSource(sourceAtt);
}
- if (this.LOG.isDebugEnabled()) {
- this.LOG.debug("Including source: " + sourceAtt);
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("Including source: " + sourceAtt);
}
return source;
} catch (IllegalArgumentException e) {
String message = "Invalid xinclude URI " + sourceAtt;
- this.LOG.error(message, e);
+ this.log.error(message, e);
throw new ProcessingException(message, e);
} catch (IOException e) {
String message = "Can't resolve URL " + sourceAtt;
- this.LOG.error(message, e);
+ this.log.error(message, e);
throw new ProcessingException(message, e);
}
@@ -452,8 +462,8 @@
}
public void setDocumentLocator(Locator locator) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("setDocumentLocator called " + locator.getSystemId());
+ if (log.isDebugEnabled()) {
+ log.debug("setDocumentLocator called " + locator.getSystemId());
}
this.locator = locator;
@@ -467,18 +477,18 @@
}
private static final class DummyLexicalHandler implements LexicalHandler {
- public void startEntity(String name) throws SAXException {}
+ public void startEntity(String name) throws SAXException { }
- public void startDTD(String name, String publicId, String systemId) throws
SAXException {}
+ public void startDTD(String name, String publicId, String systemId) throws
SAXException { }
- public void startCDATA() throws SAXException {}
+ public void startCDATA() throws SAXException { }
- public void endEntity(String name) throws SAXException {}
+ public void endEntity(String name) throws SAXException { }
- public void endDTD() throws SAXException {}
+ public void endDTD() throws SAXException { }
- public void endCDATA() throws SAXException {}
+ public void endCDATA() throws SAXException { }
- public void comment(char[] ch, int start, int length) throws SAXException {}
+ public void comment(char[] ch, int start, int length) throws SAXException { }
}
}
Modified:
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/xpointer/XPointerContext.java
===================================================================
---
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/xpointer/XPointerContext.java 2010-05-06
03:58:58 UTC (rev 16905)
+++
root/cdk/trunk/plugins/xinclude/src/main/java/org/apache/cocoon/pipeline/component/xpointer/XPointerContext.java 2010-05-06
08:41:13 UTC (rev 16906)
@@ -39,7 +39,8 @@
private static final String XMLNS = "xmlns";
private static final String XMLNS_NAMESPACE =
"http://www.w3.org/2000/xmlns/";
private static final String XML_NAMESPACE =
"http://www.w3.org/XML/1998/namespace";
- private final Logger LOGGER ;
+
+ private final Logger logger;
private Map<String, String> prefixes = new HashMap<String, String>();
private Document document;
private final EntityResolver resolver;
@@ -47,12 +48,13 @@
private String xPointer;
private SAXConsumer xmlConsumer;
- public XPointerContext(String xPointer, InputSource source, SAXConsumer xmlConsumer,
EntityResolver resolver, Logger log) {
+ public XPointerContext(String xPointer, InputSource source,
+ SAXConsumer xmlConsumer, EntityResolver resolver, Logger log)
{
this.xPointer = xPointer;
this.source = source;
this.xmlConsumer = xmlConsumer;
this.resolver = resolver;
- this.LOGGER = log;
+ this.logger = log;
}
public String getXPointer() {
@@ -68,7 +70,7 @@
}
public Logger getLogger() {
- return LOGGER;
+ return logger;
}
public Document getDocument() throws IOException, SAXException {