Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/ParseMessages.java URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/ParseMessages.java?rev=385164&r1=385163&r2=385164&view=diff ============================================================================== --- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/ParseMessages.java (original) +++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/ParseMessages.java Sat Mar 11 12:54:27 2006 @@ -1,4 +1,4 @@ -// Copyright 2004, 2005, 2006 The Apache Software Foundation +// 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. @@ -16,7 +16,6 @@ import org.apache.hivemind.HiveMind; import org.apache.hivemind.Location; -import org.apache.hivemind.Messages; import org.apache.hivemind.Resource; import org.apache.hivemind.impl.MessageFormatter; @@ -26,174 +25,178 @@ * @author Howard Lewis Ship * @since 4.0 */ -final class ParseMessages +class ParseMessages { - - private final static Messages MESSAGES = new MessageFormatter(ParseMessages.class); - - /** @since 4.1 */ - private ParseMessages() - { - } + private final static MessageFormatter _formatter = new MessageFormatter(ParseMessages.class); static String commentNotEnded(int line) { - return MESSAGES.format("comment-not-ended", new Integer(line)); + return _formatter.format("comment-not-ended", new Integer(line)); } static String unclosedUnknownTag(int line) { - return MESSAGES.format("unclosed-unknown-tag", new Integer(line)); + return _formatter.format("unclosed-unknown-tag", new Integer(line)); } static String unclosedTag(String tagName, int line) { - return MESSAGES.format("unclosed-tag", tagName, new Integer(line)); + return _formatter.format("unclosed-tag", tagName, new Integer(line)); } static String missingAttributeValue(String tagName, int line, String attributeName) { - return MESSAGES.format("missing-attribute-value", tagName, new Integer(line), attributeName); + return _formatter.format( + "missing-attribute-value", + tagName, + new Integer(line), + attributeName); } static String componentMayNotBeIgnored(String tagName, int line) { - return MESSAGES.format("component-may-not-be-ignored", tagName, new Integer(line)); + return _formatter.format("component-may-not-be-ignored", tagName, new Integer(line)); } static String componentIdInvalid(String tagName, int line, String jwcid) { - return MESSAGES.format("component-id-invalid", tagName, new Integer(line), jwcid); + return _formatter.format("component-id-invalid", tagName, new Integer(line), jwcid); } static String unknownComponentId(String tagName, int line, String jwcid) { - return MESSAGES.format("unknown-component-id", tagName, new Integer(line), jwcid); + return _formatter.format("unknown-component-id", tagName, new Integer(line), jwcid); } static String nestedIgnore(String tagName, int line) { - return MESSAGES.format("nested-ignore", tagName, new Integer(line)); + return _formatter.format("nested-ignore", tagName, new Integer(line)); } static String contentBlockMayNotBeIgnored(String tagName, int line) { - return MESSAGES.format("content-block-may-not-be-ignored", tagName, new Integer(line)); + return _formatter.format("content-block-may-not-be-ignored", tagName, new Integer(line)); } static String contentBlockMayNotBeEmpty(String tagName, int line) { - return MESSAGES.format("content-block-may-not-be-empty", tagName, new Integer(line)); + return _formatter.format("content-block-may-not-be-empty", tagName, new Integer(line)); } static String incompleteCloseTag(int line) { - return MESSAGES.format("incomplete-close-tag", new Integer(line)); + return _formatter.format("incomplete-close-tag", new Integer(line)); } - static String improperlyNestedCloseTag(String tagName, int closeLine, String startTagName, int startLine) + static String improperlyNestedCloseTag(String tagName, int closeLine, String startTagName, + int startLine) { - return MESSAGES.format("improperly-nested-close-tag", new Object[] { tagName, new Integer(closeLine), - startTagName, new Integer(startLine) }); + return _formatter.format("improperly-nested-close-tag", new Object[] + { tagName, new Integer(closeLine), startTagName, new Integer(startLine) }); } static String unmatchedCloseTag(String tagName, int line) { - return MESSAGES.format("unmatched-close-tag", tagName, new Integer(line)); + return _formatter.format("unmatched-close-tag", tagName, new Integer(line)); } static String failConvertBoolean(String value) { - return MESSAGES.format("fail-convert-boolean", value); + return _formatter.format("fail-convert-boolean", value); } static String failConvertDouble(String value) { - return MESSAGES.format("fail-convert-double", value); + return _formatter.format("fail-convert-double", value); } static String failConvertInt(String value) { - return MESSAGES.format("fail-convert-int", value); + return _formatter.format("fail-convert-int", value); } static String failConvertLong(String value) { - return MESSAGES.format("fail-convert-long", value); + return _formatter.format("fail-convert-long", value); } static String unableToCopy(String id) { - return MESSAGES.format("unable-to-copy", id); + return _formatter.format("unable-to-copy", id); } static String bothTypeAndCopyOf(String id) { - return MESSAGES.format("both-type-and-copy-of", id); + return _formatter.format("both-type-and-copy-of", id); } static String missingTypeOrCopyOf(String id) { - return MESSAGES.format("missing-type-or-copy-of", id); + return _formatter.format("missing-type-or-copy-of", id); } static String frameworkLibraryIdIsReserved(String id) { - return MESSAGES.format("framework-library-id-is-reserved", id); + return _formatter.format("framework-library-id-is-reserved", id); } static String incorrectDocumentType(String expected, String actual) { - return MESSAGES.format("incorrect-document-type", expected, actual); + return _formatter.format("incorrect-document-type", expected, actual); } static String noAttributeAndBody(String attributeName, String elementName) { - return MESSAGES.format("no-attribute-and-body", attributeName, elementName); + return _formatter.format("no-attribute-and-body", attributeName, elementName); } static String requiredExtendedAttribute(String elementName, String attributeName) { - return MESSAGES.format("required-extended-attribute", elementName, attributeName); + return _formatter.format("required-extended-attribute", elementName, attributeName); } static String invalidAttribute(String key, String value) { - return MESSAGES.format(key, value); + return _formatter.format(key, value); } static String missingResource(Resource resource) { - return MESSAGES.format("missing-resource", resource); + return _formatter.format("missing-resource", resource); } static String errorReadingResource(Resource resource, Throwable cause) { - return MESSAGES.format("error-reading-resource", resource, cause); + return _formatter.format("error-reading-resource", resource, cause); } static String unknownPublicId(Resource resource, String publicId) { - return MESSAGES.format("unknown-public-id", resource, publicId); + return _formatter.format("unknown-public-id", resource, publicId); } static String serviceElementNotSupported() { - return MESSAGES.getMessage("service-element-not-supported"); + return _formatter.getMessage("service-element-not-supported"); } static String rangeError(TemplateToken token, int length) { - return MESSAGES.format("range-error", token, new Integer(length)); + return _formatter.format("range-error", token, new Integer(length)); } public static String duplicateTagAttribute(String tagName, int line, String attributeName) { - return MESSAGES.format("duplicate-tag-attribute", tagName, new Integer(line), attributeName); + return _formatter.format( + "duplicate-tag-attribute", + tagName, + new Integer(line), + attributeName); } public static Object listenerBindingUnsupported(Location location) { - return MESSAGES.format("listener-binding-unsupported", HiveMind.getLocationString(location)); + return _formatter.format("listener-binding-unsupported", HiveMind + .getLocationString(location)); } -} +} \ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/SpecificationParser.java URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/SpecificationParser.java?rev=385164&r1=385163&r2=385164&view=diff ============================================================================== --- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/SpecificationParser.java (original) +++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/SpecificationParser.java Sat Mar 11 12:54:27 2006 @@ -73,9 +73,9 @@ */ public class SpecificationParser extends AbstractParser implements ISpecificationParser { - public static final String IDENTIFIER_PATTERN = "_?[a-zA-Z]\\w*"; + private static final String IDENTIFIER_PATTERN = "_?[a-zA-Z]\\w*"; - public static final String EXTENDED_IDENTIFIER_PATTERN = "_?[a-zA-Z](\\w|-)*"; + private static final String EXTENDED_IDENTIFIER_PATTERN = "_?[a-zA-Z](\\w|-)*"; /** * Perl5 pattern for asset names. Letter, followed by letter, number or underscore. Also allows @@ -128,6 +128,13 @@ + IDENTIFIER_PATTERN + "/)*" + IDENTIFIER_PATTERN + "$"; /** + * We can share a single map for all the XML attribute to object conversions, since the keys are + * unique. + */ + + private final Map CONVERSION_MAP = new HashMap(); + + /** * Extended version of [EMAIL PROTECTED] 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. @@ -154,7 +161,21 @@ */ public static final String LIBRARY_ID_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; - + + /** @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 _DTD_4_0; + /** * Perl5 pattern for page names. Page names appear in library and application specifications, in * the <page> element. Starting with 4.0, the page name may look more like a path name, @@ -195,15 +216,7 @@ */ 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"; - private static final int STATE_ALLOW_DESCRIPTION = 2000; private static final int STATE_ALLOW_PROPERTY = 2001; @@ -212,7 +225,7 @@ private static final int STATE_BEAN = 4; - /** Very different between 3.0 and 4.0 DTD. */ + /** Very different between 3.0 and 4.0 DTD */ private static final int STATE_BINDING_3_0 = 7; @@ -250,31 +263,17 @@ private static final int STATE_SET = 5; - /** 3.0 DTD only. */ + /** 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 3.0 */ - - /** @since 4.0 */ - private final Log _log; + public static final String TAPESTRY_DTD_3_0_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Specification 3.0//EN"; /** @since 4.0 */ - private final ErrorHandler _errorHandler; - /** - * Set to true if parsing the 4.0 DTD. - * - * @since 4.0 - */ + public static final String TAPESTRY_DTD_4_0_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Specification 4.0//EN"; - private boolean _dtd40; - /** * The attributes of the current element, as a map (string keyed on string). */ @@ -325,26 +324,26 @@ { - _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); + CONVERSION_MAP.put("true", Boolean.TRUE); + CONVERSION_MAP.put("t", Boolean.TRUE); + CONVERSION_MAP.put("1", Boolean.TRUE); + CONVERSION_MAP.put("y", Boolean.TRUE); + CONVERSION_MAP.put("yes", Boolean.TRUE); + CONVERSION_MAP.put("on", Boolean.TRUE); + CONVERSION_MAP.put("aye", Boolean.TRUE); + + CONVERSION_MAP.put("false", Boolean.FALSE); + CONVERSION_MAP.put("f", Boolean.FALSE); + CONVERSION_MAP.put("0", Boolean.FALSE); + CONVERSION_MAP.put("off", Boolean.FALSE); + CONVERSION_MAP.put("no", Boolean.FALSE); + CONVERSION_MAP.put("n", Boolean.FALSE); + CONVERSION_MAP.put("nay", Boolean.FALSE); + + CONVERSION_MAP.put("none", BeanLifecycle.NONE); + CONVERSION_MAP.put("request", BeanLifecycle.REQUEST); + CONVERSION_MAP.put("page", BeanLifecycle.PAGE); + CONVERSION_MAP.put("render", BeanLifecycle.RENDER); _parserFactory.setNamespaceAware(false); _parserFactory.setValidating(true); @@ -477,7 +476,7 @@ private void allowMetaData() { - if (_dtd40) + if (_DTD_4_0) { if (_elementName.equals("meta")) { @@ -487,7 +486,7 @@ } else if (_elementName.equals("property")) { - enterProperty3(); + enterProperty_3_0(); return; } @@ -523,13 +522,13 @@ if (_elementName.equals("set-property")) { - enterSetProperty3(); + enterSetProperty_3_0(); return; } if (_elementName.equals("set-message-property")) { - enterSetMessage3(); + enterSetMessage_3_0(); return; } @@ -554,19 +553,19 @@ if (_elementName.equals("static-binding")) { - enterStaticBinding3(); + enterStaticBinding_3_0(); return; } if (_elementName.equals("message-binding")) { - enterMessageBinding3(); + enterMessageBinding_3_0(); return; } if (_elementName.equals("inherited-binding")) { - enterInheritedBinding3(); + enterInheritedBinding_3_0(); return; } @@ -656,7 +655,7 @@ if (_elementName.equals("service")) { - enterService3(); + enterService_3_0(); return; } @@ -704,7 +703,7 @@ // Have to be careful, because <meta> in 4.0 was <property> in 3.0 if (_elementName.equals("property-specification") - || (_dtd40 && _elementName.equals("property"))) + || (_DTD_4_0 && _elementName.equals("property"))) { enterProperty(); return; @@ -730,19 +729,19 @@ if (_elementName.equals("context-asset")) { - enterContextAsset3(); + enterContextAsset_3_0(); return; } if (_elementName.equals("private-asset")) { - enterPrivateAsset3(); + enterPrivateAsset_3_0(); return; } if (_elementName.equals("external-asset")) { - enterExternalAsset3(); + enterExternalAsset_3_0(); return; } @@ -833,7 +832,7 @@ case STATE_BINDING_3_0: - endBinding3(); + endBinding_3_0(); break; case STATE_BINDING: @@ -870,7 +869,7 @@ pop(); } - private void endBinding3() + private void endBinding_3_0() { BindingSetter bs = (BindingSetter) peekObject(); @@ -929,7 +928,7 @@ // 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) + if (initialValue != null && !_DTD_4_0) initialValue = BindingConstants.OGNL_PREFIX + ":" + initialValue; ps.setInitialValue(initialValue); @@ -1020,9 +1019,9 @@ private void enterBinding() { - if (!_dtd40) + if (!_DTD_4_0) { - enterBinding3(); + enterBinding_3_0(); return; } @@ -1059,7 +1058,7 @@ * Handles a binding in a 3.0 DTD. */ - private void enterBinding3() + private void enterBinding_3_0() { String name = getAttribute("name"); String expression = getAttribute("expression"); @@ -1135,7 +1134,7 @@ private void enterConfigure() { - String attributeName = _dtd40 ? "property" : "property-name"; + String attributeName = _DTD_4_0 ? "property" : "property-name"; String propertyName = getValidatedAttribute( attributeName, @@ -1152,7 +1151,7 @@ push(_elementName, setter, STATE_CONFIGURE, false); } - private void enterContextAsset3() + private void enterContextAsset_3_0() { enterAsset("path", "context:"); } @@ -1198,7 +1197,7 @@ push(_elementName, es, STATE_EXTENSION); } - private void enterExternalAsset3() + private void enterExternalAsset_3_0() { // External URLs get no prefix, but will have a scheme (i.e., "http:") that // fulfils much the same purpose. @@ -1206,9 +1205,9 @@ enterAsset("URL", null); } - /** A throwback to the 3.0 DTD. */ + /** A throwback to the 3.0 DTD */ - private void enterInheritedBinding3() + private void enterInheritedBinding_3_0() { String name = getAttribute("name"); String parameterName = getAttribute("parameter-name"); @@ -1248,7 +1247,7 @@ push(_elementName, null, STATE_LISTENER_BINDING, false); } - private void enterMessageBinding3() + private void enterMessageBinding_3_0() { String name = getAttribute("name"); String key = getAttribute("key"); @@ -1286,7 +1285,7 @@ PARAMETER_NAME_PATTERN, "invalid-parameter-name"); - String attributeName = _dtd40 ? "property" : "property-name"; + String attributeName = _DTD_4_0 ? "property" : "property-name"; String propertyName = getValidatedAttribute( attributeName, @@ -1307,12 +1306,12 @@ String defaultValue = getAttribute("default-value"); - if (defaultValue != null && !_dtd40) + if (defaultValue != null && !_DTD_4_0) defaultValue = BindingConstants.OGNL_PREFIX + ":" + defaultValue; ps.setDefaultValue(defaultValue); - if (!_dtd40) + if (!_DTD_4_0) { // When direction=auto (in a 3.0 DTD), turn caching off @@ -1346,7 +1345,7 @@ push(_elementName, ps, STATE_ALLOW_DESCRIPTION); } - private void enterPrivateAsset3() + private void enterPrivateAsset_3_0() { enterAsset("resource-path", "classpath:"); } @@ -1364,7 +1363,7 @@ push(_elementName, new PropertyValueSetter(ph, key, value), STATE_META, false); } - private void enterProperty3() + private void enterProperty_3_0() { String name = getAttribute("name"); String value = getAttribute("value"); @@ -1377,7 +1376,7 @@ } /** - * &tl;property> in 4.0, or <property-specification> in 3.0 . + * &tl;property> in 4.0, or <property-specification> in 3.0 */ private void enterProperty() @@ -1387,7 +1386,7 @@ String persistence = null; - if (_dtd40) + if (_DTD_4_0) persistence = getAttribute("persist"); else persistence = getBooleanAttribute("persistent", false) ? "session" : null; @@ -1444,14 +1443,14 @@ push(_elementName, null, STATE_NO_CONTENT); } - private void enterService3() + private void enterService_3_0() { _errorHandler.error(_log, ParseMessages.serviceElementNotSupported(), getLocation(), null); push(_elementName, null, STATE_NO_CONTENT); } - private void enterSetMessage3() + private void enterSetMessage_3_0() { String name = getAttribute("name"); String key = getAttribute("key"); @@ -1483,7 +1482,7 @@ push(_elementName, new BeanSetPropertySetter(bs, bi, null, reference), STATE_SET, false); } - private void enterSetProperty3() + private void enterSetProperty_3_0() { String name = getAttribute("name"); String expression = getAttribute("expression"); @@ -1498,7 +1497,7 @@ expression), STATE_SET, false); } - private void enterStaticBinding3() + private void enterStaticBinding_3_0() { String name = getAttribute("name"); String expression = getAttribute("value"); @@ -1533,7 +1532,7 @@ if (value == null) return defaultValue; - Boolean b = (Boolean) _conversionMap.get(value); + Boolean b = (Boolean) CONVERSION_MAP.get(value); return b.booleanValue(); } @@ -1545,7 +1544,7 @@ if (key == null) return defaultValue; - return _conversionMap.get(key); + return CONVERSION_MAP.get(key); } private InputSource getDTDInputSource(String name) @@ -1734,7 +1733,7 @@ protected void resetParser() { _rootObject = null; - _dtd40 = false; + _DTD_4_0 = false; _attributes.clear(); } @@ -1747,7 +1746,7 @@ { if (TAPESTRY_DTD_4_0_PUBLIC_ID.equals(publicId)) { - _dtd40 = true; + _DTD_4_0 = true; return getDTDInputSource("Tapestry_4_0.dtd"); } @@ -1769,4 +1768,4 @@ { _valueConverter = valueConverter; } -} +} \ No newline at end of file Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/TemplateParseException.java URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/TemplateParseException.java?rev=385164&r1=385163&r2=385164&view=diff ============================================================================== --- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/TemplateParseException.java (original) +++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/parse/TemplateParseException.java Sat Mar 11 12:54:27 2006 @@ -1,4 +1,4 @@ -// Copyright 2004, 2005, 2006 The Apache Software Foundation +// 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. @@ -18,18 +18,18 @@ import org.apache.hivemind.Location; /** - * Exception thrown indicating a problem parsing an HTML template. + * Exception thrown indicating a problem parsing an HTML template. + * + * @author Howard Ship * - * @author Howard Ship - */ + **/ public class TemplateParseException extends Exception implements Locatable { - private static final long serialVersionUID = 3741503276431589982L; - - private final Location _location; - private final Throwable _rootCause; + + private Location _location; + private Throwable _rootCause; public TemplateParseException(String message) { @@ -61,4 +61,4 @@ return _rootCause; } -} +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
