SpecificationParser.java

Index Score
org.apache.tapestry.parse
Apache Tapestry 4

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
EXITSProcedure exits
WHITESPACENumber of whitespace lines
LOGICAL_LINESNumber of statements
JAVA0034JAVA0034 Missing braces in if statement
LINESNumber of lines in the source file
SIZESize of the file in bytes
LOCLines of code
ELOCEffective lines of code
DECL_COMMENTSComments in declarations
UNIQUE_OPERANDSNumber of unique operands
RETURNSNumber of return points from functions
OPERANDSNumber of operands
CYCLOMATICCyclomatic complexity
PROGRAM_LENGTHHalstead program length
PROGRAM_VOCABHalstead program vocabulary
OPERATORSNumber of operators
FUNCTIONSNumber of function declarations
LINE_COMMENTNumber of line comments
INTERFACE_COMPLEXITYInterface complexity
BLOCKSNumber of blocks
JAVA0020JAVA0020 Field name does not have required form
EXEC_COMMENTSComments in executable code
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
COMPARISONSNumber of comparison operators
DOC_COMMENTNumber of javadoc comment lines
COMMENTSComment lines
PARAMSNumber of formal parameter declarations
JAVA0040JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0031JAVA0031 Case statement not properly closed
JAVA0117JAVA0117 Missing javadoc: method 'method'
UNIQUE_OPERATORSNumber of unique operators
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
LOOPSNumber of loops
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0145JAVA0145 Tab character used in source file
// Copyright 2004, 2005 The Apache Software Foundation // // Licensed 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.tapestry.parse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hivemind.*; import org.apache.hivemind.impl.DefaultErrorHandler; import org.apache.hivemind.impl.LocationImpl; import org.apache.hivemind.parse.AbstractParser; import org.apache.tapestry.INamespace; import org.apache.tapestry.Tapestry; import org.apache.tapestry.bean.BindingBeanInitializer; import org.apache.tapestry.bean.LightweightBeanInitializer; import org.apache.tapestry.binding.BindingConstants; import org.apache.tapestry.binding.BindingSource; import org.apache.tapestry.coerce.ValueConverter; import org.apache.tapestry.spec.*; import org.apache.tapestry.util.IPropertyHolder; import org.apache.tapestry.util.RegexpMatcher; import org.apache.tapestry.util.xml.DocumentParseException; import org.apache.tapestry.util.xml.InvalidStringException; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /** * Parses the different types of Tapestry specifications. * <p> * Not threadsafe; it is the callers responsibility to ensure thread safety. * * @author Howard Lewis Ship */ public class SpecificationParser extends AbstractParser implements ISpecificationParser { /** * Perl5 pattern for asset names. Letter, followed by letter, number or underscore. Also allows * the special "$template" value. * * @since 2.2 */ public static final String ASSET_NAME_PATTERN = "(\\$template)|(" + Tapestry.SIMPLE_PROPERTY_NAME_PATTERN + ")"; /** * Perl5 pattern for helper bean names. Letter, followed by letter, number or underscore. * * @since 2.2 */ public static final String BEAN_NAME_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; public static final String IDENTIFIER_PATTERN = "_?[a-zA-Z]\\w*"; public static final String EXTENDED_IDENTIFIER_PATTERN = "_?[a-zA-Z](\\w|-)*"; /** * Perl5 pattern for component type (which was known as an "alias" in earlier versions of * Tapestry). This is either a simple property name, or a series of property names seperated by * slashes (the latter being new in Tapestry 4.0). This defines a literal that can appear in a * library or application specification. * * @since 2.2 */ public static final String COMPONENT_ALIAS_PATTERN = "^(" + IDENTIFIER_PATTERN + "/)*" + IDENTIFIER_PATTERN + "$"; /** * Perl5 pattern for component ids. Letter, followed by letter, number or underscore. * * @since 2.2 */ public static final String COMPONENT_ID_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; /** * Perl5 pattern for component types (i.e., the type attribute of the &lt;component&gt; * element). Component types are an optional namespace prefix followed by a component type * (within the library defined by the namespace). Starting in 4.0, the type portion is actually * a series of identifiers seperated by slashes. * * @since 2.2 */ public static final String COMPONENT_TYPE_PATTERN = "^(" + IDENTIFIER_PATTERN + ":)?" + "(" + IDENTIFIER_PATTERN + "/)*" + IDENTIFIER_PATTERN + "$"; /** * Extended version of {@link Tapestry#SIMPLE_PROPERTY_NAME_PATTERN}, but allows a series of * individual property names, seperated by periods. In addition, each name within the dotted * sequence is allowed to contain dashes. * * @since 2.2 */ public static final String EXTENDED_PROPERTY_NAME_PATTERN = "^" + EXTENDED_IDENTIFIER_PATTERN + "(\\." + EXTENDED_IDENTIFIER_PATTERN + ")*$"; /** * Per5 pattern for extension names. Letter followed by letter, number, dash, period or * underscore. * * @since 2.2 */ public static final String EXTENSION_NAME_PATTERN = EXTENDED_PROPERTY_NAME_PATTERN; /** * Perl5 pattern for library ids. Letter followed by letter, number or underscore. * * @since 2.2 */ public static final String LIBRARY_ID_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; /** * Perl5 pattern for page names. Page names appear in library and application specifications, in * the &lt;page&gt; element. Starting with 4.0, the page name may look more like a path name, * consisting of a number of ids seperated by slashes. This is used to determine the folder * which contains the page specification or the page's template. * * @since 2.2 */ public static final String PAGE_NAME_PATTERN = "^" + IDENTIFIER_PATTERN + "(/" + EXTENDED_IDENTIFIER_PATTERN + ")*$"; /** * Perl5 pattern that parameter names must conform to. Letter, followed by letter, number or * underscore. * * @since 2.2 */ public static final String PARAMETER_NAME_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; /** * Perl5 pattern that property names (that can be connected to parameters) must conform to. * Letter, followed by letter, number or underscore. * * @since 2.2 */ public static final String PROPERTY_NAME_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; /** * Perl5 pattern for service names. Letter followed by letter, number, dash, underscore or * period. * * @since 2.2 * @deprecated As of release 4.0, the &lt;service&gt; element (in 3.0 DTDs) is no longer * supported. */ public static final String SERVICE_NAME_PATTERN = EXTENDED_PROPERTY_NAME_PATTERN; /** @since 3.0 */ public static final String TAPESTRY_DTD_3_0_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Specification 3.0//EN"; /** @since 4.0 */ public static final String TAPESTRY_DTD_4_0_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Specification 4.0//EN"; /** @since 4.1 */ public static final String TAPESTRY_DTD_4_1_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Specification 4.1//EN"; private static final int STATE_ALLOW_DESCRIPTION = 2000; private static final int STATE_ALLOW_PROPERTY = 2001; private static final int STATE_APPLICATION_SPECIFICATION_INITIAL = 1002; private static final int STATE_BEAN = 4; /** Very different between 3.0 and 4.0 DTD. */ private static final int STATE_BINDING_3_0 = 7; /** @since 4.0 */ private static final int STATE_BINDING = 100; private static final int STATE_COMPONENT = 6; private static final int STATE_COMPONENT_SPECIFICATION = 1; private static final int STATE_COMPONENT_SPECIFICATION_INITIAL = 1000; private static final int STATE_CONFIGURE = 14; private static final int STATE_DESCRIPTION = 2; private static final int STATE_EXTENSION = 13; private static final int STATE_LIBRARY_SPECIFICATION = 12; private static final int STATE_LIBRARY_SPECIFICATION_INITIAL = 1003; private static final int STATE_LISTENER_BINDING = 8; private static final int STATE_NO_CONTENT = 3000; private static final int STATE_PAGE_SPECIFICATION = 11; private static final int STATE_PAGE_SPECIFICATION_INITIAL = 1001; private static final int STATE_META = 3; private static final int STATE_PROPERTY = 10; private static final int STATE_SET = 5; /** 3.0 DTD only. */ private static final int STATE_STATIC_BINDING = 9; /** * We can share a single map for all the XML attribute to object conversions, since the keys are * unique. */ private final Map _conversionMap = new HashMap(); /** @since 4.0 */ private final Log _log; /** @since 4.0 */ private final ErrorHandler _errorHandler; /** * Set to true if parsing the 4.0 DTD. * * @since 4.0 */ private boolean _dtd40; /** * The attributes of the current element, as a map (string keyed on string). */ private Map _attributes; /** * The name of the current element. */ private String _elementName; /** @since 1.0.9 */ private final SpecFactory _factory; private RegexpMatcher _matcher = new RegexpMatcher(); private SAXParser _parser; private SAXParserFactory _parserFactory = SAXParserFactory.newInstance(); /** * @since 3.0 */ private final ClassResolver _resolver; /** @since 4.0 */ private BindingSource _bindingSource; /** * The root object parsed: a component or page specification, a library specification, or an * application specification. */ private Object _rootObject; /** @since 4.0 */ private ValueConverter _valueConverter; // Identify all the different acceptible values. // We continue to sneak by with a single map because // there aren't conflicts; when we have 'foo' meaning // different things in different places in the DTD, we'll // need multiple maps. { _conversionMap.put("true", Boolean.TRUE); _conversionMap.put("t", Boolean.TRUE); _conversionMap.put("1", Boolean.TRUE); _conversionMap.put("y", Boolean.TRUE); _conversionMap.put("yes", Boolean.TRUE); _conversionMap.put("on", Boolean.TRUE); _conversionMap.put("aye", Boolean.TRUE); _conversionMap.put("false", Boolean.FALSE); _conversionMap.put("f", Boolean.FALSE); _conversionMap.put("0", Boolean.FALSE); _conversionMap.put("off", Boolean.FALSE); _conversionMap.put("no", Boolean.FALSE); _conversionMap.put("n", Boolean.FALSE); _conversionMap.put("nay", Boolean.FALSE); _conversionMap.put("none", BeanLifecycle.NONE); _conversionMap.put("request", BeanLifecycle.REQUEST); _conversionMap.put("page", BeanLifecycle.PAGE); _conversionMap.put("render", BeanLifecycle.RENDER); _parserFactory.setNamespaceAware(false); _parserFactory.setValidating(true); } /** * This constructor is a convienience used by some tests. */ public SpecificationParser(ClassResolver resolver) { this(new DefaultErrorHandler(), LogFactory.getLog(SpecificationParser.class), resolver, new SpecFactory()); } /** * The full constructor, used within Tapestry. */ public SpecificationParser(ErrorHandler errorHandler, Log log, ClassResolver resolver, SpecFactory factory) { _errorHandler = errorHandler; _log = log; _resolver = resolver; _factory = factory; } protected void begin(String elementName, Map attributes) { _elementName = elementName; _attributes = attributes; switch (getState()) { case STATE_COMPONENT_SPECIFICATION_INITIAL: beginComponentSpecificationInitial(); break; case STATE_PAGE_SPECIFICATION_INITIAL: beginPageSpecificationInitial(); break; case STATE_APPLICATION_SPECIFICATION_INITIAL: beginApplicationSpecificationInitial(); break; case STATE_LIBRARY_SPECIFICATION_INITIAL: beginLibrarySpecificationInitial(); break; case STATE_COMPONENT_SPECIFICATION: beginComponentSpecification(); break; case STATE_PAGE_SPECIFICATION: beginPageSpecification(); break; case STATE_ALLOW_DESCRIPTION: beginAllowDescription(); break; case STATE_ALLOW_PROPERTY: allowMetaData(); break; case STATE_BEAN: beginBean(); break; case STATE_COMPONENT: beginComponent(); break; case STATE_LIBRARY_SPECIFICATION: beginLibrarySpecification(); break; case STATE_EXTENSION: beginExtension(); break; default: unexpectedElement(_elementName); } } /** * Special state for a number of specification types that can support the &lt;description&gt; * element. */ private void beginAllowDescription() { if (_elementName.equals("description")) { enterDescription(); return; } unexpectedElement(_elementName); } /** * Special state for a number of elements that can support the nested &lt;meta&gt; meta data * element (&lt;property&gt; in 3.0 DTD). */ private void allowMetaData() { if (_dtd40) { if (_elementName.equals("meta")) { enterMeta(); return; } } else if (_elementName.equals("property")) { enterProperty30(); return; } unexpectedElement(_elementName); } private void beginApplicationSpecificationInitial() { expectElement("application"); String name = getAttribute("name"); String engineClassName = getAttribute("engine-class"); IApplicationSpecification as = _factory.createApplicationSpecification(); as.setName(name); if (HiveMind.isNonBlank(engineClassName)) as.setEngineClassName(engineClassName); _rootObject = as; push(_elementName, as, STATE_LIBRARY_SPECIFICATION); } private void beginBean() { if (_elementName.equals("set")) { enterSet(); return; } if (_elementName.equals("set-property")) { enterSetProperty30(); return; } if (_elementName.equals("set-message-property")) { enterSetMessage30(); return; } if (_elementName.equals("description")) { enterDescription(); return; } allowMetaData(); } private void beginComponent() { // <binding> has changed between 3.0 and 4.0 if (_elementName.equals("binding")) { enterBinding(); return; } if (_elementName.equals("static-binding")) { enterStaticBinding30(); return; } if (_elementName.equals("message-binding")) { enterMessageBinding30(); return; } if (_elementName.equals("inherited-binding")) { enterInheritedBinding30(); return; } if (_elementName.equals("listener-binding")) { enterListenerBinding(); return; } allowMetaData(); } private void beginComponentSpecification() { if (_elementName.equals("reserved-parameter")) { enterReservedParameter(); return; } if (_elementName.equals("parameter")) { enterParameter(); return; } // The remainder are common to both <component-specification> and // <page-specification> beginPageSpecification(); } private void beginComponentSpecificationInitial() { expectElement("component-specification"); IComponentSpecification cs = _factory.createComponentSpecification(); cs.setAllowBody(getBooleanAttribute("allow-body", true)); cs.setAllowInformalParameters(getBooleanAttribute("allow-informal-parameters", true)); cs.setDeprecated(getBooleanAttribute("deprecated", false)); String className = getAttribute("class"); if (className != null) cs.setComponentClassName(className); cs.setSpecificationLocation(getResource()); _rootObject = cs; push(_elementName, cs, STATE_COMPONENT_SPECIFICATION); } private void beginExtension() { if (_elementName.equals("configure")) { enterConfigure(); return; } allowMetaData(); } private void beginLibrarySpecification() { if (_elementName.equals("description")) { enterDescription(); return; } if (_elementName.equals("page")) { enterPage(); return; } if (_elementName.equals("component-type")) { enterComponentType(); return; } // Holdover from the 3.0 DTD, now ignored. if (_elementName.equals("service")) { enterService30(); return; } if (_elementName.equals("library")) { enterLibrary(); return; } if (_elementName.equals("extension")) { enterExtension(); return; } allowMetaData(); } private void beginLibrarySpecificationInitial() { expectElement("library-specification"); ILibrarySpecification ls = _factory.createLibrarySpecification(); _rootObject = ls; push(_elementName, ls, STATE_LIBRARY_SPECIFICATION); } private void beginPageSpecification() { if (_elementName.equals("component")) { enterComponent(); return; } if (_elementName.equals("bean")) { enterBean(); return; } // <property-specification> in 3.0, <property> in 4.0 // Have to be careful, because <meta> in 4.0 was <property> in 3.0 if (_elementName.equals("property-specification") || (_dtd40 && _elementName.equals("property"))) { enterProperty(); return; } if (_elementName.equals("inject")) { enterInject(); return; } // <asset> is new in 4.0 if (_elementName.equals("asset")) { enterAsset(); return; } // <context-asset>, <external-asset>, and <private-asset> // are all throwbacks to the 3.0 DTD and don't exist // in the 4.0 DTD. if (_elementName.equals("context-asset")) { enterContextAsset30(); return; } if (_elementName.equals("private-asset")) { enterPrivateAsset30(); return; } if (_elementName.equals("external-asset")) { enterExternalAsset30(); return; } if (_elementName.equals("description")) { enterDescription(); return; } allowMetaData(); } private void beginPageSpecificationInitial() { expectElement("page-specification"); IComponentSpecification cs = _factory.createComponentSpecification(); String className = getAttribute("class"); if (className != null) cs.setComponentClassName(className); cs.setSpecificationLocation(getResource()); cs.setPageSpecification(true); _rootObject = cs; push(_elementName, cs, STATE_PAGE_SPECIFICATION); } /** * Close a stream (if not null), ignoring any errors. */ private void close(InputStream stream) { try { if (stream != null) stream.close(); } catch (IOException ex) { // ignore } } private void copyBindings(String sourceComponentId, IComponentSpecification cs, IContainedComponent target) { IContainedComponent source = cs.getComponent(sourceComponentId); if (source == null) throw new DocumentParseException(ParseMessages.unableToCopy(sourceComponentId), getLocation()); Iterator i = source.getBindingNames().iterator(); while (i.hasNext()) { String bindingName = (String) i.next(); IBindingSpecification binding = source.getBinding(bindingName); target.setBinding(bindingName, binding); } target.setType(source.getType()); } protected void end(String elementName) { _elementName = elementName; switch (getState()) { case STATE_DESCRIPTION: endDescription(); break; case STATE_META: endProperty(); break; case STATE_SET: endSetProperty(); break; case STATE_BINDING_3_0: endBinding30(); break; case STATE_BINDING: endBinding(); break; case STATE_STATIC_BINDING: endStaticBinding(); break; case STATE_PROPERTY: endPropertySpecification(); break; case STATE_LIBRARY_SPECIFICATION: endLibrarySpecification(); break; case STATE_CONFIGURE: endConfigure(); break; default: break; } // Pop the top element of the stack and continue processing from there. pop(); } private void endBinding30() { BindingSetter bs = (BindingSetter) peekObject(); String expression = getExtendedValue(bs.getValue(), "expression", true); IBindingSpecification spec = _factory.createBindingSpecification(); spec.setType(BindingType.PREFIXED); spec.setValue(BindingConstants.OGNL_PREFIX + ":" + expression); bs.apply(spec); } private void endConfigure() { ExtensionConfigurationSetter setter = (ExtensionConfigurationSetter) peekObject(); String finalValue = getExtendedValue(setter.getValue(), "value", true); setter.apply(finalValue); } private void endDescription() { DescriptionSetter setter = (DescriptionSetter) peekObject(); String description = peekContent(); setter.apply(description); } private void endLibrarySpecification() { ILibrarySpecification spec = (ILibrarySpecification) peekObject(); spec.setSpecificationLocation(getResource()); spec.instantiateImmediateExtensions(); } private void endProperty() { PropertyValueSetter pvs = (PropertyValueSetter) peekObject(); String finalValue = getExtendedValue(pvs.getPropertyValue(), "value", true); pvs.applyValue(finalValue); } private void endPropertySpecification() { IPropertySpecification ps = (IPropertySpecification) peekObject(); String initialValue = getExtendedValue(ps.getInitialValue(), "initial-value", false); // In the 3.0 DTD, the initial value was always an OGNL expression. // In the 4.0 DTD, it is a binding reference, qualified with a prefix. if (initialValue != null && !_dtd40) initialValue = BindingConstants.OGNL_PREFIX + ":" + initialValue; ps.setInitialValue(initialValue); } private void endSetProperty() { BeanSetPropertySetter bs = (BeanSetPropertySetter) peekObject(); String finalValue = getExtendedValue(bs.getBindingReference(), "expression", true); bs.applyBindingReference(finalValue); } private void endStaticBinding() { BindingSetter bs = (BindingSetter) peekObject(); String literalValue = getExtendedValue(bs.getValue(), "value", true); IBindingSpecification spec = _factory.createBindingSpecification(); spec.setType(BindingType.PREFIXED); spec.setValue(BindingConstants.LITERAL_PREFIX + ":" + literalValue); bs.apply(spec); } private void enterAsset(String pathAttributeName, String prefix) { String name = getValidatedAttribute("name", ASSET_NAME_PATTERN, "invalid-asset-name"); String path = getAttribute(pathAttributeName); String propertyName = getValidatedAttribute( "property", PROPERTY_NAME_PATTERN, "invalid-property-name"); IAssetSpecification ia = _factory.createAssetSpecification(); ia.setPath(prefix == null ? path : prefix + path); ia.setPropertyName(propertyName); IComponentSpecification cs = (IComponentSpecification) peekObject(); cs.addAsset(name, ia); push(_elementName, ia, STATE_ALLOW_PROPERTY); } private void enterBean() { String name = getValidatedAttribute("name", BEAN_NAME_PATTERN, "invalid-bean-name"); String classAttribute = getAttribute("class"); // Look for the lightweight initialization int commax = classAttribute.indexOf(','); String className = commax < 0 ? classAttribute : classAttribute.substring(0, commax); BeanLifecycle lifecycle = (BeanLifecycle) getConvertedAttribute( "lifecycle", BeanLifecycle.REQUEST); String propertyName = getValidatedAttribute( "property", PROPERTY_NAME_PATTERN, "invalid-property-name"); IBeanSpecification bs = _factory.createBeanSpecification(); bs.setClassName(className); bs.setLifecycle(lifecycle); bs.setPropertyName(propertyName); if (commax > 0) { String initializer = classAttribute.substring(commax + 1); bs.addInitializer(new LightweightBeanInitializer(initializer)); } IComponentSpecification cs = (IComponentSpecification) peekObject(); cs.addBeanSpecification(name, bs); push(_elementName, bs, STATE_BEAN); } private void enterBinding() { if (!_dtd40) { enterBinding30(); return; } // 4.0 stuff String name = getValidatedAttribute( "name", PARAMETER_NAME_PATTERN, "invalid-parameter-name"); String value = getAttribute("value"); IContainedComponent cc = (IContainedComponent) peekObject(); BindingSetter bs = new BindingSetter(cc, name, value); push(_elementName, bs, STATE_BINDING, false); } private void endBinding() { BindingSetter bs = (BindingSetter) peekObject(); String value = getExtendedValue(bs.getValue(), "value", true); IBindingSpecification spec = _factory.createBindingSpecification(); spec.setType(BindingType.PREFIXED); spec.setValue(value); bs.apply(spec); } /** * Handles a binding in a 3.0 DTD. */ private void enterBinding30() { String name = getAttribute("name"); String expression = getAttribute("expression"); IContainedComponent cc = (IContainedComponent) peekObject(); BindingSetter bs = new BindingSetter(cc, name, expression); push(_elementName, bs, STATE_BINDING_3_0, false); } private void enterComponent() { String id = getValidatedAttribute("id", COMPONENT_ID_PATTERN, "invalid-component-id"); String type = getValidatedAttribute( "type", COMPONENT_TYPE_PATTERN, "invalid-component-type"); String copyOf = getAttribute("copy-of"); boolean inherit = getBooleanAttribute("inherit-informal-parameters", false); String propertyName = getValidatedAttribute( "property", PROPERTY_NAME_PATTERN, "invalid-property-name"); // Check that either copy-of or type, but not both boolean hasCopyOf = HiveMind.isNonBlank(copyOf); if (hasCopyOf) { if (HiveMind.isNonBlank(type)) throw new DocumentParseException(ParseMessages.bothTypeAndCopyOf(id), getLocation()); } else { if (HiveMind.isBlank(type)) throw new DocumentParseException(ParseMessages.missingTypeOrCopyOf(id), getLocation()); } IContainedComponent cc = _factory.createContainedComponent(); cc.setType(type); cc.setCopyOf(copyOf); cc.setInheritInformalParameters(inherit); cc.setPropertyName(propertyName); IComponentSpecification cs = (IComponentSpecification) peekObject(); cs.addComponent(id, cc); if (hasCopyOf) copyBindings(copyOf, cs, cc); push(_elementName, cc, STATE_COMPONENT); } private void enterComponentType() { String type = getValidatedAttribute( "type", COMPONENT_ALIAS_PATTERN, "invalid-component-type"); String path = getAttribute("specification-path"); ILibrarySpecification ls = (ILibrarySpecification) peekObject(); ls.setComponentSpecificationPath(type, path); push(_elementName, null, STATE_NO_CONTENT); } private void enterConfigure() { String attributeName = _dtd40 ? "property" : "property-name"; String propertyName = getValidatedAttribute( attributeName, PROPERTY_NAME_PATTERN, "invalid-property-name"); String value = getAttribute("value"); IExtensionSpecification es = (IExtensionSpecification) peekObject(); ExtensionConfigurationSetter setter = new ExtensionConfigurationSetter(es, propertyName, value); push(_elementName, setter, STATE_CONFIGURE, false); } private void enterContextAsset30() { enterAsset("path", "context:"); } /** * New in the 4.0 DTD. When using the 4.0 DTD, you must explicitly specify prefix if the asset * is not stored in the same domain as the specification file. * * @since 4.0 */ private void enterAsset() { enterAsset("path", null); } private void enterDescription() { push(_elementName, new DescriptionSetter(peekObject()), STATE_DESCRIPTION, false); } private void enterExtension() { String name = getValidatedAttribute( "name", EXTENSION_NAME_PATTERN, "invalid-extension-name"); boolean immediate = getBooleanAttribute("immediate", false); String className = getAttribute("class"); IExtensionSpecification es = _factory.createExtensionSpecification( _resolver, _valueConverter); es.setClassName(className); es.setImmediate(immediate); ILibrarySpecification ls = (ILibrarySpecification) peekObject(); ls.addExtensionSpecification(name, es); push(_elementName, es, STATE_EXTENSION); } private void enterExternalAsset30() { // External URLs get no prefix, but will have a scheme (i.e., "http:") that // fulfils much the same purpose. enterAsset("URL", null); } /** A throwback to the 3.0 DTD. */ private void enterInheritedBinding30() { String name = getAttribute("name"); String parameterName = getAttribute("parameter-name"); IBindingSpecification bs = _factory.createBindingSpecification(); bs.setType(BindingType.INHERITED); bs.setValue(parameterName); IContainedComponent cc = (IContainedComponent) peekObject(); cc.setBinding(name, bs); push(_elementName, null, STATE_NO_CONTENT); } private void enterLibrary() { String libraryId = getValidatedAttribute("id", LIBRARY_ID_PATTERN, "invalid-library-id"); String path = getAttribute("specification-path"); if (libraryId.equals(INamespace.FRAMEWORK_NAMESPACE) || libraryId.equals(INamespace.APPLICATION_NAMESPACE)) throw new DocumentParseException(ParseMessages .frameworkLibraryIdIsReserved(INamespace.FRAMEWORK_NAMESPACE), getLocation()); ILibrarySpecification ls = (ILibrarySpecification) peekObject(); ls.setLibrarySpecificationPath(libraryId, path); push(_elementName, null, STATE_NO_CONTENT); } private void enterListenerBinding() { _log.warn(ParseMessages.listenerBindingUnsupported(getLocation())); push(_elementName, null, STATE_LISTENER_BINDING, false); } private void enterMessageBinding30() { String name = getAttribute("name"); String key = getAttribute("key"); IBindingSpecification bs = _factory.createBindingSpecification(); bs.setType(BindingType.PREFIXED); bs.setValue(BindingConstants.MESSAGE_PREFIX + ":" + key); bs.setLocation(getLocation()); IContainedComponent cc = (IContainedComponent) peekObject(); cc.setBinding(name, bs); push(_elementName, null, STATE_NO_CONTENT); } private void enterPage() { String name = getValidatedAttribute("name", PAGE_NAME_PATTERN, "invalid-page-name"); String path = getAttribute("specification-path"); ILibrarySpecification ls = (ILibrarySpecification) peekObject(); ls.setPageSpecificationPath(name, path); push(_elementName, null, STATE_NO_CONTENT); } private void enterParameter() { IParameterSpecification ps = _factory.createParameterSpecification(); String name = getValidatedAttribute( "name", PARAMETER_NAME_PATTERN, "invalid-parameter-name"); String attributeName = _dtd40 ? "property" : "property-name"; String propertyName = getValidatedAttribute( attributeName, PROPERTY_NAME_PATTERN, "invalid-property-name"); if (propertyName == null) propertyName = name; ps.setParameterName(name); ps.setPropertyName(propertyName); ps.setRequired(getBooleanAttribute("required", false)); // In the 3.0 DTD, default-value was always an OGNL expression. // Starting with 4.0, it's like a binding (prefixed). For a 3.0 // DTD, we supply the "ognl:" prefix. String defaultValue = getAttribute("default-value"); if (defaultValue != null && !_dtd40) defaultValue = BindingConstants.OGNL_PREFIX + ":" + defaultValue; ps.setDefaultValue(defaultValue); if (!_dtd40) { // When direction=auto (in a 3.0 DTD), turn caching off String direction = getAttribute("direction"); ps.setCache(!"auto".equals(direction)); } else { boolean cache = getBooleanAttribute("cache", true); ps.setCache(cache); } // type will only be specified in a 3.0 DTD. String type = getAttribute("type"); if (type != null) ps.setType(type); // aliases is new in the 4.0 DTD String aliases = getAttribute("aliases"); ps.setAliases(aliases); ps.setDeprecated(getBooleanAttribute("deprecated", false)); IComponentSpecification cs = (IComponentSpecification) peekObject(); cs.addParameter(ps); push(_elementName, ps, STATE_ALLOW_DESCRIPTION); } private void enterPrivateAsset30() { enterAsset("resource-path", "classpath:"); } /** @since 4.0 */ private void enterMeta() { String key = getAttribute("key"); String value = getAttribute("value"); // Value may be null, in which case the value is set from the element content IPropertyHolder ph = (IPropertyHolder) peekObject(); push(_elementName, new PropertyValueSetter(ph, key, value), STATE_META, false); } private void enterProperty30() { String name = getAttribute("name"); String value = getAttribute("value"); // Value may be null, in which case the value is set from the element content IPropertyHolder ph = (IPropertyHolder) peekObject(); push(_elementName, new PropertyValueSetter(ph, name, value), STATE_META, false); } /** * &tl;property&gt; in 4.0, or &lt;property-specification&gt; in 3.0. */ private void enterProperty() { String name = getValidatedAttribute("name", PROPERTY_NAME_PATTERN, "invalid-property-name"); String type = getAttribute("type"); String persistence = null; if (_dtd40) persistence = getAttribute("persist"); else persistence = getBooleanAttribute("persistent", false) ? "session" : null; String initialValue = getAttribute("initial-value"); IPropertySpecification ps = _factory.createPropertySpecification(); ps.setName(name); if (HiveMind.isNonBlank(type)) ps.setType(type); ps.setPersistence(persistence); ps.setInitialValue(initialValue); IComponentSpecification cs = (IComponentSpecification) peekObject(); cs.addPropertySpecification(ps); push(_elementName, ps, STATE_PROPERTY, false); } /** * @since 4.0 */ private void enterInject() { String property = getValidatedAttribute( "property", PROPERTY_NAME_PATTERN, "invalid-property-name"); String type = getAttribute("type"); String objectReference = getAttribute("object"); InjectSpecification spec = _factory.createInjectSpecification(); spec.setProperty(property); spec.setType(type); spec.setObject(objectReference); IComponentSpecification cs = (IComponentSpecification) peekObject(); cs.addInjectSpecification(spec); push(_elementName, spec, STATE_NO_CONTENT); } private void enterReservedParameter() { String name = getAttribute("name"); IComponentSpecification cs = (IComponentSpecification) peekObject(); cs.addReservedParameterName(name); push(_elementName, null, STATE_NO_CONTENT); } private void enterService30() { _errorHandler.error(_log, ParseMessages.serviceElementNotSupported(), getLocation(), null); push(_elementName, null, STATE_NO_CONTENT); } private void enterSetMessage30() { String name = getAttribute("name"); String key = getAttribute("key"); BindingBeanInitializer bi = _factory.createBindingBeanInitializer(_bindingSource); bi.setPropertyName(name); bi.setBindingReference(BindingConstants.MESSAGE_PREFIX + ":" + key); bi.setLocation(getLocation()); IBeanSpecification bs = (IBeanSpecification) peekObject(); bs.addInitializer(bi); push(_elementName, null, STATE_NO_CONTENT); } private void enterSet() { String name = getAttribute("name"); String reference = getAttribute("value"); BindingBeanInitializer bi = _factory.createBindingBeanInitializer(_bindingSource); bi.setPropertyName(name); IBeanSpecification bs = (IBeanSpecification) peekObject(); push(_elementName, new BeanSetPropertySetter(bs, bi, null, reference), STATE_SET, false); } private void enterSetProperty30() { String name = getAttribute("name"); String expression = getAttribute("expression"); BindingBeanInitializer bi = _factory.createBindingBeanInitializer(_bindingSource); bi.setPropertyName(name); IBeanSpecification bs = (IBeanSpecification) peekObject(); push(_elementName, new BeanSetPropertySetter(bs, bi, BindingConstants.OGNL_PREFIX + ":", expression), STATE_SET, false); } private void enterStaticBinding30() { String name = getAttribute("name"); String expression = getAttribute("value"); IContainedComponent cc = (IContainedComponent) peekObject(); BindingSetter bs = new BindingSetter(cc, name, expression); push(_elementName, bs, STATE_STATIC_BINDING, false); } private void expectElement(String elementName) { if (_elementName.equals(elementName)) return; throw new DocumentParseException(ParseMessages.incorrectDocumentType( _elementName, elementName), getLocation(), null); } private String getAttribute(String name) { return (String) _attributes.get(name); } private boolean getBooleanAttribute(String name, boolean defaultValue) { String value = getAttribute(name); if (value == null) return defaultValue; Boolean b = (Boolean) _conversionMap.get(value); return b.booleanValue(); } private Object getConvertedAttribute(String name, Object defaultValue) { String key = getAttribute(name); if (key == null) return defaultValue; return _conversionMap.get(key); } private InputSource getDTDInputSource(String name) { InputStream stream = getClass().getResourceAsStream(name); return new InputSource(stream); } private String getExtendedValue(String attributeValue, String attributeName, boolean required) { String contentValue = peekContent(); boolean asAttribute = HiveMind.isNonBlank(attributeValue); boolean asContent = HiveMind.isNonBlank(contentValue); if (asAttribute && asContent) { throw new DocumentParseException(ParseMessages.noAttributeAndBody( attributeName, _elementName), getLocation(), null); } if (required && !(asAttribute || asContent)) { throw new DocumentParseException(ParseMessages.requiredExtendedAttribute( _elementName, attributeName), getLocation(), null); } if (asAttribute) return attributeValue; return contentValue; } private String getValidatedAttribute(String name, String pattern, String errorKey) { String value = getAttribute(name); if (value == null) return null; if (_matcher.matches(pattern, value)) return value; throw new InvalidStringException(ParseMessages.invalidAttribute(errorKey, value), value, getLocation()); } protected void initializeParser(Resource resource, int startState) { super.initializeParser(resource, startState); _rootObject = null; _attributes = new HashMap(); } public IApplicationSpecification parseApplicationSpecification(Resource resource) { initializeParser(resource, STATE_APPLICATION_SPECIFICATION_INITIAL); try { parseDocument(); return (IApplicationSpecification) _rootObject; } finally { resetParser(); } } public IComponentSpecification parseComponentSpecification(Resource resource) { initializeParser(resource, STATE_COMPONENT_SPECIFICATION_INITIAL); try { parseDocument(); return (IComponentSpecification) _rootObject; } finally { resetParser(); } } private void parseDocument() { InputStream stream = null; Resource resource = getResource(); boolean success = false; try { if (_parser == null) _parser = _parserFactory.newSAXParser(); URL resourceURL = resource.getResourceURL(); if (resourceURL == null) throw new DocumentParseException(ParseMessages.missingResource(resource), resource); InputStream rawStream = resourceURL.openStream(); stream = new BufferedInputStream(rawStream); _parser.parse(stream, this, resourceURL.toExternalForm()); stream.close(); stream = null; success = true; } catch (SAXParseException ex) { _parser = null; Location location = new LocationImpl(resource, ex.getLineNumber(), ex.getColumnNumber()); throw new DocumentParseException(ParseMessages.errorReadingResource(resource, ex), location, ex); } catch (Exception ex) { _parser = null; throw new DocumentParseException(ParseMessages.errorReadingResource(resource, ex), resource, ex); } finally { if (!success) _parser = null; close(stream); } } public ILibrarySpecification parseLibrarySpecification(Resource resource) { initializeParser(resource, STATE_LIBRARY_SPECIFICATION_INITIAL); try { parseDocument(); return (ILibrarySpecification) _rootObject; } finally { resetParser(); } } public IComponentSpecification parsePageSpecification(Resource resource) { initializeParser(resource, STATE_PAGE_SPECIFICATION_INITIAL); try { parseDocument(); return (IComponentSpecification) _rootObject; } finally { resetParser(); } } protected String peekContent() { String content = super.peekContent(); if (content == null) return null; return content.trim(); } protected void resetParser() { _rootObject = null; _dtd40 = false; _attributes.clear(); } /** * Resolved an external entity, which is assumed to be the doctype. Might need a check to ensure * that specs without a doctype fail. */ public InputSource resolveEntity(String publicId, String systemId) throws SAXException { if (TAPESTRY_DTD_4_0_PUBLIC_ID.equals(publicId)) { _dtd40 = true; return getDTDInputSource("Tapestry_4_0.dtd"); } if (TAPESTRY_DTD_4_1_PUBLIC_ID.equals(publicId)) { _dtd40 = true; return getDTDInputSource("Tapestry_4_1.dtd"); } if (TAPESTRY_DTD_3_0_PUBLIC_ID.equals(publicId)) return getDTDInputSource("Tapestry_3_0.dtd"); throw new DocumentParseException(ParseMessages.unknownPublicId(getResource(), publicId), new LocationImpl(getResource()), null); } /** @since 4.0 */ public void setBindingSource(BindingSource bindingSource) { _bindingSource = bindingSource; } /** @since 4.0 */ public void setValueConverter(ValueConverter valueConverter) { _valueConverter = valueConverter; } }

The table below shows all metrics for SpecificationParser.java.

MetricValueDescription
BLOCKS131.00Number of blocks
BLOCK_COMMENT 0.00Number of block comment lines
COMMENTS203.00Comment lines
COMMENT_DENSITY 0.25Comment density
COMPARISONS62.00Number of comparison operators
CYCLOMATIC179.00Cyclomatic complexity
DECL_COMMENTS58.00Comments in declarations
DOC_COMMENT158.00Number of javadoc comment lines
ELOC813.00Effective lines of code
EXEC_COMMENTS19.00Comments in executable code
EXITS195.00Procedure exits
FUNCTIONS74.00Number of function declarations
HALSTEAD_DIFFICULTY78.67Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY159.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 9.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 1.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003427.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 1.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 8.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 1.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 1.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 2.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 0.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 1.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 1.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 1.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1751.00Number of lines in the source file
LINE_COMMENT45.00Number of line comments
LOC1081.00Lines of code
LOGICAL_LINES570.00Number of statements
LOOPS 1.00Number of loops
NEST_DEPTH 3.00Maximum nesting depth
OPERANDS2104.00Number of operands
OPERATORS3782.00Number of operators
PARAMS37.00Number of formal parameter declarations
PROGRAM_LENGTH5886.00Halstead program length
PROGRAM_VOCAB733.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS122.00Number of return points from functions
SIZE48172.00Size of the file in bytes
UNIQUE_OPERANDS682.00Number of unique operands
UNIQUE_OPERATORS51.00Number of unique operators
WHITESPACE467.00Number of whitespace lines