You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2005/09/14 18:21:05 UTC
svn commit: r280879 [12/16] - in /struts/sandbox/trunk/ti: ./
jars/compiler-apt/ jars/compiler-apt/src/ jars/compiler-apt/src/java/
jars/compiler-apt/src/java/org/ jars/compiler-apt/src/java/org/apache/
jars/compiler-apt/src/java/org/apache/ti/ jars/co...
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidationModel.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidationModel.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidationModel.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidationModel.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,378 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.model.validation;
+
+import org.apache.ti.compiler.internal.FatalCompileTimeException;
+import org.apache.ti.compiler.internal.JpfLanguageConstants;
+import org.apache.ti.schema.validator11.FormValidationDocument;
+import org.apache.ti.schema.validator11.FormsetDocument;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlDocumentProperties;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+public abstract class ValidationModel
+ implements JpfLanguageConstants {
+
+ private Map _localeSets = new HashMap();
+ private LocaleSet _defaultLocaleSet = new LocaleSet();
+ private List _rulesToAddForAllLocales = new ArrayList(); // list of RuleAdd
+ private boolean _empty = true;
+ private ValidatorVersion _validatorVersion = ValidatorVersion.oneOne;
+
+ public static class ValidatorVersion {
+
+ private static final int INT_ONE_ZERO = 0;
+ private static final int INT_ONE_ONE = 1;
+
+ private int _val;
+
+ private ValidatorVersion(int val) {
+ _val = val;
+ }
+
+ public boolean equals(ValidatorVersion vv) {
+ return _val == vv._val;
+ }
+
+ public static final ValidatorVersion oneZero = new ValidatorVersion(INT_ONE_ZERO);
+ public static final ValidatorVersion oneOne = new ValidatorVersion(INT_ONE_ONE);
+ }
+
+ public static class RuleInfo {
+
+ private String _entityName;
+ private String _fieldName;
+ private String _fieldDisplayName;
+ private String _fieldDisplayNameKey;
+
+ public RuleInfo(String entityName, String fieldName, String fieldDisplayName, String fieldDisplayNameKey) {
+ _entityName = entityName;
+ _fieldName = fieldName;
+ _fieldDisplayName = fieldDisplayName;
+ _fieldDisplayNameKey = fieldDisplayNameKey;
+ }
+
+ public String getEntityName() {
+ return _entityName;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+
+ public String getFieldDisplayName() {
+ return _fieldDisplayName;
+ }
+
+ public String getFieldDisplayNameKey() {
+ return _fieldDisplayNameKey;
+ }
+ }
+
+ private static class RuleAdd {
+
+ public RuleAdd(RuleInfo ruleInfo, ValidatorRule rule) {
+ this.ruleInfo = ruleInfo;
+ this.rule = rule;
+ }
+
+ public RuleInfo ruleInfo;
+ public ValidatorRule rule;
+ }
+
+ public ValidatorVersion getValidatorVersion() {
+ return _validatorVersion;
+ }
+
+ public void setValidatorVersion(String validatorVersion) {
+ //
+ // default to the least common denominator (validator v1.0) unless
+ // explicitly set to v1.1.
+ //
+ if (validatorVersion != null && validatorVersion.equals(VALIDATOR_VERSION_ONE_ONE_STR)) {
+ _validatorVersion = ValidatorVersion.oneOne;
+ } else {
+ _validatorVersion = ValidatorVersion.oneZero;
+ }
+ }
+
+ public void addFieldRuleForAllLocales(RuleInfo ruleInfo, ValidatorRule rule) {
+ _rulesToAddForAllLocales.add(new RuleAdd(ruleInfo, rule));
+ }
+
+ public void addFieldRule(RuleInfo ruleInfo, ValidatorRule rule, Locale locale) {
+ LocaleSet localeSet;
+
+ if (locale == null) // default locale
+ {
+ localeSet = _defaultLocaleSet;
+ } else {
+ localeSet = (LocaleSet) _localeSets.get(locale);
+
+ if (localeSet == null) {
+ localeSet = new LocaleSet(locale);
+ _localeSets.put(locale, localeSet);
+ }
+
+ //
+ // The Commons Validator uses specific locale rules for a field only if there
+ // is a rule for the same field in the default formset. Therefor, we need to
+ // keep a place holder for each locale specific field we find in the default
+ // formset entity so that the Commons Validator will behave as desired.
+ //
+ if (getField(ruleInfo, _defaultLocaleSet) == null) {
+ //
+ // create a simple placeholder for the field, without any rules
+ //
+ addFieldRule(ruleInfo, (ValidatorRule) null, _defaultLocaleSet);
+ }
+ }
+
+ addFieldRule(ruleInfo, rule, localeSet);
+ }
+
+ private ValidatableField getField(RuleInfo ruleInfo, LocaleSet localeSet) {
+ String entityName = ruleInfo.getEntityName();
+ ValidatableEntity entity = localeSet.getEntity(entityName);
+ if (entity == null) {
+ return null;
+ }
+
+ String fieldName = ruleInfo.getFieldName();
+ return entity.getField(fieldName);
+ }
+
+ private boolean hasFieldRule(RuleInfo ruleInfo, ValidatorRule rule, LocaleSet localeSet) {
+ ValidatableField field = getField(ruleInfo, localeSet);
+ if (field == null) {
+ return false;
+ }
+
+ return field.hasRule(rule);
+ }
+
+ private void addFieldRule(RuleInfo ruleInfo, ValidatorRule rule, LocaleSet localeSet) {
+ String entityName = ruleInfo.getEntityName();
+ ValidatableEntity entity = localeSet.getEntity(entityName);
+ if (entity == null) localeSet.addValidatableEntity(entity = new ValidatableEntity(entityName));
+
+ String fieldName = ruleInfo.getFieldName();
+ ValidatableField field = entity.getField(fieldName);
+ if (field == null) {
+ field = ValidatableFieldFactory.getInstance(fieldName, ruleInfo.getFieldDisplayName(),
+ ruleInfo.getFieldDisplayNameKey(), getValidatorVersion());
+ entity.addField(field);
+ }
+
+ //
+ // A field element without rules is OK, but we don't want to add a null rule.
+ //
+ if (rule != null) {
+ field.addRule(rule);
+ }
+ }
+
+ public void writeXml(PrintWriter writer, File mergeFile)
+ throws XmlException, IOException, FatalCompileTimeException {
+ //
+ // First, if we haven't written the all-locale rules to each locale, do so now.
+ // However, before we add a rule, check that it does not already exist. We don't
+ // want to overload a rule explicitly defined for a specific locale with
+ // an all-locale rule of the same name.
+ //
+ if (_rulesToAddForAllLocales != null) {
+ for (int i = 0; i < _rulesToAddForAllLocales.size(); i++) {
+ RuleAdd ruleAdd = (RuleAdd) _rulesToAddForAllLocales.get(i);
+
+ for (Iterator j = _localeSets.values().iterator(); j.hasNext();) {
+ LocaleSet localeSet = (LocaleSet) j.next();
+ if (!hasFieldRule(ruleAdd.ruleInfo, ruleAdd.rule, localeSet)) {
+ addFieldRule(ruleAdd.ruleInfo, ruleAdd.rule, localeSet);
+ }
+ }
+
+ if (!hasFieldRule(ruleAdd.ruleInfo, ruleAdd.rule, _defaultLocaleSet)) {
+ addFieldRule(ruleAdd.ruleInfo, ruleAdd.rule, _defaultLocaleSet);
+ }
+ }
+
+ _rulesToAddForAllLocales = null;
+ }
+
+ //
+ // Create and initialize the document, or parse the given one (with which we'll merge).
+ //
+ FormValidationDocument doc;
+
+ if (mergeFile != null && mergeFile.canRead()) {
+ doc = FormValidationDocument.Factory.parse(mergeFile);
+ } else {
+ doc = FormValidationDocument.Factory.newInstance();
+ }
+
+ XmlDocumentProperties dp = doc.documentProperties();
+
+ if (dp.getDoctypeName() == null) {
+ dp.setDoctypeName("form-validation"); // NOI18N
+ }
+
+ if (dp.getDoctypePublicId() == null) {
+ if (_validatorVersion.equals(ValidatorVersion.oneZero)) {
+ dp.setDoctypePublicId("-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN");
+ } else {
+ dp.setDoctypePublicId("-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1//EN");
+ }
+ }
+
+ if (dp.getDoctypeSystemId() == null) {
+ if (_validatorVersion.equals(ValidatorVersion.oneZero)) {
+ dp.setDoctypeSystemId("http://jakarta.apache.org/commons/dtds/validator_1_0.dtd");
+ } else {
+ dp.setDoctypeSystemId("http://jakarta.apache.org/commons/dtds/validator_1_1.dtd");
+ }
+ }
+
+
+ FormValidationDocument.FormValidation formValidationElement = doc.getFormValidation();
+
+ if (formValidationElement == null) {
+ formValidationElement = doc.addNewFormValidation();
+ }
+
+ //
+ // Write the "generated by" comment.
+ //
+ XmlCursor curs = formValidationElement.newCursor();
+ String headerComment = getHeaderComment(mergeFile);
+ if (headerComment != null) curs.insertComment(headerComment);
+
+ //
+ // Now write out all the LocaleSets, which contain the forms/fields/rules.
+ //
+ writeLocaleSets(formValidationElement);
+ writeLocaleSet(_defaultLocaleSet, formValidationElement);
+
+ //
+ // Write the file.
+ //
+ XmlOptions options = new XmlOptions();
+ options.setSavePrettyPrint();
+ doc.save(writer, options);
+ }
+
+ protected String getHeaderComment(File mergeFile)
+ throws FatalCompileTimeException {
+ return null;
+ }
+
+ private void writeLocaleSets(FormValidationDocument.FormValidation formValidationElement) {
+ //
+ // Commons Validator behavior is to build a key from the locale of a FormSet
+ // or uses the default Locale (Locale.getDefault() - the system locale) to
+ // track different elements. This implies that the
+ // without language or country attributes could be mapped to "en_US"
+ // if that's the default locale.
+ // See org.apache.commons.validator.ValidatorResources.buildKey()
+ //
+ // Therefor, to ensure the validator uses rules for of a specific
+ // locale before the FormSet with no language or country attributes (even
+ // if it is the locale of the system), write the most specific locales first.
+ //
+ List allLocales = new ArrayList(_localeSets.keySet());
+ List langCountryVariant = new ArrayList();
+ List langCountry = new ArrayList();
+ List lang = new ArrayList();
+
+ for (java.util.Iterator ii = allLocales.iterator(); ii.hasNext();) {
+ Locale locale = (Locale) ii.next();
+ if (locale.getCountry().length() > 0) {
+ if (locale.getVariant().length() > 0) {
+ langCountryVariant.add(locale);
+ } else {
+ langCountry.add(locale);
+ }
+ } else {
+ lang.add(locale);
+ }
+ }
+
+ writeLocaleSets(langCountryVariant, formValidationElement);
+ writeLocaleSets(langCountry, formValidationElement);
+ writeLocaleSets(lang, formValidationElement);
+ }
+
+ private void writeLocaleSets(Collection locales, FormValidationDocument.FormValidation formValidationElement) {
+ for (java.util.Iterator ii = locales.iterator(); ii.hasNext();) {
+ Locale locale = (Locale) ii.next();
+ LocaleSet localeSet = (LocaleSet) _localeSets.get(locale);
+ writeLocaleSet(localeSet, formValidationElement);
+ }
+ }
+
+ private void writeLocaleSet(LocaleSet localeSet, FormValidationDocument.FormValidation formValidationElement) {
+ FormsetDocument.Formset[] existingFormSetElements = formValidationElement.getFormsetArray();
+ FormsetDocument.Formset formSetElementToUse = null;
+ Locale locale = localeSet.getLocale();
+
+ for (int i = 0; i < existingFormSetElements.length; i++) {
+ FormsetDocument.Formset existingFormSetElement = existingFormSetElements[i];
+
+ if (locale == null && existingFormSetElement.getLanguage() == null) {
+ formSetElementToUse = existingFormSetElement;
+ break;
+ } else if (locale != null && locale.getLanguage().equals(existingFormSetElement.getLanguage())) {
+ if ((locale.getCountry().length() == 0 && existingFormSetElement.getCountry() == null)
+ || locale.getCountry().equals(existingFormSetElement.getCountry())) {
+ if ((locale.getVariant().length() == 0 && existingFormSetElement.getVariant() == null)
+ || locale.getVariant().equals(existingFormSetElement.getVariant())) {
+ formSetElementToUse = existingFormSetElement;
+ break;
+ }
+ }
+ }
+ }
+
+ if (formSetElementToUse == null) {
+ formSetElementToUse = formValidationElement.addNewFormset();
+ }
+
+ localeSet.writeToXMLBean(formSetElementToUse);
+ }
+
+ public boolean isEmpty() {
+ return _empty;
+ }
+
+ protected void setEmpty(boolean empty) {
+ _empty = empty;
+ }
+
+ public abstract String getOutputFileURI();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorConstants.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorConstants.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorConstants.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorConstants.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.model.validation;
+
+public interface ValidatorConstants {
+
+ String RULENAME_INT_RANGE = "netui_longRange";
+ String RULENAME_FLOAT_RANGE = "floatRange";
+ String RULENAME_REQUIRED = "required";
+ String RULENAME_EMAIL = "email";
+ String RULENAME_CREDIT_CARD = "creditCard";
+ String RULENAME_MINLENGTH = "minlength";
+ String RULENAME_MAXLENGTH = "maxlength";
+ String RULENAME_MASK = "mask";
+ String RULENAME_BYTE = "byte";
+ String RULENAME_SHORT = "short";
+ String RULENAME_INTEGER = "integer";
+ String RULENAME_LONG = "long";
+ String RULENAME_FLOAT = "float";
+ String RULENAME_DOUBLE = "double";
+ String RULENAME_DATE = "date";
+ String RULENAME_VALID_WHEN = "netui_validwhen";
+
+ String VARNAME_MIN = "min";
+ String VARNAME_MAX = "max";
+ String VARNAME_MINLENGTH = "minlength";
+ String VARNAME_MAXLENGTH = "maxlength";
+ String VARNAME_MASK = "mask";
+ String VARNAME_DATE_PATTERN = "datePattern";
+ String VARNAME_DATE_PATTERN_STRICT = "datePatternStrict";
+ String VARNAME_VALID_WHEN = RULENAME_VALID_WHEN;
+
+ String EXPRESSION_KEY_PREFIX = "NETUI-EXPRESSION:";
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorRule.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorRule.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorRule.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorRule.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.model.validation;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class ValidatorRule {
+
+ private Map _vars;
+ private String _ruleName;
+ private String _messageKey;
+ private String _message;
+ private String _bundle;
+ private Map _args;
+
+
+ public static class MessageArg {
+
+ private String _message;
+ private boolean _isKey;
+ private String _bundle;
+ private Integer _position;
+
+ public MessageArg(String message, boolean isKey, String bundle, Integer position) {
+ _message = message;
+ _isKey = isKey;
+ _bundle = bundle;
+ _position = position;
+ }
+
+ public String getMessage() {
+ return _message;
+ }
+
+ public boolean isKey() {
+ return _isKey;
+ }
+
+ public String getBundle() {
+ return _bundle;
+ }
+
+ public Integer getPosition() {
+ return _position;
+ }
+ }
+
+ public ValidatorRule(String ruleName) {
+ assert ruleName != null;
+ _ruleName = ruleName;
+ }
+
+ public void setVar(String name, String val) {
+ if (_vars == null) _vars = new LinkedHashMap();
+ _vars.put(name, val);
+ }
+
+ public Map getVars() {
+ return _vars;
+ }
+
+ public String getRuleName() {
+ return _ruleName;
+ }
+
+ public String getMessageKey() {
+ return _messageKey;
+ }
+
+ public void setMessageKey(String messageKey) {
+ _messageKey = messageKey;
+ }
+
+ public String getMessage() {
+ return _message;
+ }
+
+ public void setMessage(String message) {
+ assert _messageKey == null;
+ _message = message;
+ }
+
+ public String getBundle() {
+ return _bundle;
+ }
+
+ public void setBundle(String bundle) {
+ _bundle = bundle;
+ }
+
+ public void setArg(String message, boolean isKey, String bundle, Integer position) {
+ if (_args == null) {
+ _args = new LinkedHashMap();
+ }
+ _args.put(position, new MessageArg(message, isKey, bundle, position));
+ }
+
+ public MessageArg getArg(Integer position) {
+ if (_args == null) {
+ return null;
+ }
+ return (MessageArg) _args.get(position);
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorRuleRange.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorRuleRange.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorRuleRange.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/model/validation/ValidatorRuleRange.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.model.validation;
+
+public class ValidatorRuleRange
+ extends ValidatorRule
+ implements ValidatorConstants {
+
+ public ValidatorRuleRange(Double min, Double max) {
+ super(RULENAME_FLOAT_RANGE);
+ setVar(VARNAME_MIN, min.toString());
+ setVar(VARNAME_MAX, max.toString());
+ }
+
+ public ValidatorRuleRange(Long min, Long max) {
+ super(RULENAME_INT_RANGE);
+ setVar(VARNAME_MIN, min.toString());
+ setVar(VARNAME_MAX, max.toString());
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/BaseAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/BaseAnnotationProcessor.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/BaseAnnotationProcessor.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/BaseAnnotationProcessor.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.processor;
+
+import org.apache.ti.compiler.internal.BaseChecker;
+import org.apache.ti.compiler.internal.BaseGenerator;
+import org.apache.ti.compiler.internal.CompilerUtils;
+import org.apache.ti.compiler.internal.Diagnostics;
+import org.apache.ti.compiler.internal.FatalCompileTimeException;
+import org.apache.ti.compiler.internal.JpfLanguageConstants;
+import org.apache.ti.compiler.internal.SourceFileInfo;
+import org.apache.ti.compiler.internal.typesystem.declaration.AnnotationTypeDeclaration;
+import org.apache.ti.compiler.internal.typesystem.declaration.ClassDeclaration;
+import org.apache.ti.compiler.internal.typesystem.declaration.Declaration;
+import org.apache.ti.compiler.internal.typesystem.declaration.Modifier;
+import org.apache.ti.compiler.internal.typesystem.env.AnnotationProcessorEnvironment;
+import org.apache.ti.compiler.internal.typesystem.type.ClassType;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.ResourceBundle;
+
+public abstract class BaseAnnotationProcessor
+ extends TwoPhaseAnnotationProcessor
+ implements JpfLanguageConstants {
+
+ private HashMap _sourceFileInfo;
+ private SourceFileInfo _singleSourceFileInfo = null;
+ private ResourceBundle _messages;
+
+
+ protected BaseAnnotationProcessor(AnnotationTypeDeclaration[] annotationTypeDecls,
+ AnnotationProcessorEnvironment env) {
+ super(annotationTypeDecls, env);
+ _messages = ResourceBundle.getBundle(TI_PACKAGE + ".compiler.internal.diagnostics");
+ }
+
+ public void check(Declaration decl)
+ throws FatalCompileTimeException {
+ assert _sourceFileInfo != null; // process() should guarantee this.
+
+ if (decl instanceof ClassDeclaration) {
+ ClassDeclaration classDecl = (ClassDeclaration) decl;
+ BaseChecker checker = getChecker(classDecl, this);
+
+ if (checker != null) {
+ checker.check(classDecl);
+
+ //
+ // Also do a silent check on all base classes. We don't want to generate if there were errors
+ // in the base class.
+ //
+ SilentDiagnostics silentDiagnostics = new SilentDiagnostics();
+
+ for (ClassType i = classDecl.getSuperclass(); i != null; i = i.getSuperclass()) {
+ ClassDeclaration baseDecl = i.getClassTypeDeclaration();
+
+ if (CompilerUtils.getSourceFile(baseDecl, false) != null) {
+ BaseChecker silentChecker = getChecker(baseDecl, silentDiagnostics);
+ if (silentChecker != null) silentChecker.check(baseDecl);
+ }
+ }
+
+ if (silentDiagnostics.hasErrors()) setHasErrors(true);
+ }
+ }
+ }
+
+ public void generate(Declaration decl)
+ throws FatalCompileTimeException {
+ assert _sourceFileInfo != null; // process() should guarantee this.
+
+ if (decl instanceof ClassDeclaration) {
+ ClassDeclaration classDecl = (ClassDeclaration) decl;
+ BaseGenerator generator = getGenerator(classDecl, this);
+ if (generator != null) generator.generate(classDecl);
+ }
+ }
+
+ public void process() {
+ _sourceFileInfo = new HashMap();
+ super.process();
+ _sourceFileInfo = null;
+ }
+
+ protected abstract BaseChecker getChecker(ClassDeclaration decl, Diagnostics diagnostics);
+
+ protected abstract BaseGenerator getGenerator(ClassDeclaration decl, Diagnostics diagnostics);
+
+ protected SourceFileInfo getSourceFileInfo(ClassDeclaration decl) {
+ assert _sourceFileInfo != null || _singleSourceFileInfo != null;
+ assert _sourceFileInfo == null || _singleSourceFileInfo == null;
+ return _singleSourceFileInfo != null ? _singleSourceFileInfo : (SourceFileInfo) _sourceFileInfo.get(decl.getQualifiedName());
+ }
+
+ protected void setSourceFileInfo(ClassDeclaration decl, SourceFileInfo sourceFileInfo) {
+ assert _sourceFileInfo != null || _singleSourceFileInfo == null;
+
+ if (_sourceFileInfo != null) {
+ _sourceFileInfo.put(decl.getQualifiedName(), sourceFileInfo);
+ } else {
+ _singleSourceFileInfo = sourceFileInfo;
+ }
+ }
+
+ protected static boolean expectAnnotation(ClassDeclaration classDecl, String annotationBaseName,
+ String fileExtensionRequiresAnnotation, String baseClass,
+ Diagnostics diagnostics) {
+ if (CompilerUtils.getAnnotation(classDecl, annotationBaseName) != null) return true;
+
+ String fileName = classDecl.getPosition().file().getName();
+
+ if (fileExtensionRequiresAnnotation != null && fileName.endsWith(fileExtensionRequiresAnnotation)) {
+ diagnostics.addError(classDecl, "error.annotation-required",
+ fileExtensionRequiresAnnotation, ANNOTATIONS_CLASSNAME + '.' + annotationBaseName);
+ } else if (! classDecl.hasModifier(Modifier.ABSTRACT)) {
+ diagnostics.addWarning(classDecl, "warning.missing-annotation", baseClass,
+ ANNOTATIONS_CLASSNAME + '.' + annotationBaseName);
+ }
+
+ return false;
+ }
+
+ protected String getResourceString(String key, Object[] args) {
+ String message = _messages.getString(key);
+ return MessageFormat.format(message, args);
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/FormBeanAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/FormBeanAnnotationProcessor.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/FormBeanAnnotationProcessor.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/FormBeanAnnotationProcessor.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.processor;
+
+import org.apache.ti.compiler.internal.BaseChecker;
+import org.apache.ti.compiler.internal.BaseGenerator;
+import org.apache.ti.compiler.internal.CompilerUtils;
+import org.apache.ti.compiler.internal.Diagnostics;
+import org.apache.ti.compiler.internal.FormBeanChecker;
+import org.apache.ti.compiler.internal.typesystem.declaration.AnnotationTypeDeclaration;
+import org.apache.ti.compiler.internal.typesystem.declaration.ClassDeclaration;
+import org.apache.ti.compiler.internal.typesystem.env.AnnotationProcessorEnvironment;
+
+
+public class FormBeanAnnotationProcessor
+ extends BaseAnnotationProcessor {
+
+ public FormBeanAnnotationProcessor(AnnotationTypeDeclaration[] annotationTypeDecls, AnnotationProcessorEnvironment env) {
+ super(annotationTypeDecls, env);
+ }
+
+ protected BaseChecker getChecker(ClassDeclaration decl, Diagnostics diagnostics) {
+ if (CompilerUtils.getAnnotation(decl, FORM_BEAN_TAG_NAME, true) != null) {
+ return new FormBeanChecker(getAnnotationProcessorEnvironment(), diagnostics);
+ }
+
+ return null;
+ }
+
+ protected BaseGenerator getGenerator(ClassDeclaration decl, Diagnostics diagnostics) {
+ return null;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/PageFlowAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/PageFlowAnnotationProcessor.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/PageFlowAnnotationProcessor.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/PageFlowAnnotationProcessor.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.processor;
+
+import org.apache.ti.compiler.internal.*;
+import org.apache.ti.compiler.internal.typesystem.declaration.AnnotationInstance;
+import org.apache.ti.compiler.internal.typesystem.declaration.AnnotationTypeDeclaration;
+import org.apache.ti.compiler.internal.typesystem.declaration.ClassDeclaration;
+import org.apache.ti.compiler.internal.typesystem.env.AnnotationProcessorEnvironment;
+
+import java.io.File;
+
+
+public class PageFlowAnnotationProcessor
+ extends BaseAnnotationProcessor
+ implements JpfLanguageConstants {
+
+ public PageFlowAnnotationProcessor(AnnotationTypeDeclaration[] annotationTypeDecls,
+ AnnotationProcessorEnvironment env) {
+ super(annotationTypeDecls, env);
+ }
+
+ public BaseChecker getChecker(ClassDeclaration classDecl, Diagnostics diagnostics) {
+ AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
+
+ if (CompilerUtils.isAssignableFrom(JPF_BASE_CLASS, classDecl, env)) {
+ if (expectAnnotation(classDecl, CONTROLLER_TAG_NAME, JPF_FILE_EXTENSION_DOT, JPF_BASE_CLASS, diagnostics)) {
+ FlowControllerInfo fcInfo = new FlowControllerInfo(classDecl);
+ setSourceFileInfo(classDecl, fcInfo);
+
+ return new PageFlowChecker(env, diagnostics, fcInfo);
+ }
+ } else if (CompilerUtils.isAssignableFrom(SHARED_FLOW_BASE_CLASS, classDecl, env)) {
+ if (expectAnnotation(classDecl, CONTROLLER_TAG_NAME, SHARED_FLOW_FILE_EXTENSION_DOT,
+ SHARED_FLOW_BASE_CLASS, diagnostics)) {
+ FlowControllerInfo fcInfo = new FlowControllerInfo(classDecl);
+ setSourceFileInfo(classDecl, fcInfo);
+
+ return new SharedFlowChecker(env, fcInfo, diagnostics);
+ }
+ } else if (CompilerUtils.isAssignableFrom(FACES_BACKING_BEAN_CLASS, classDecl, env)) {
+ if (expectAnnotation(classDecl, FACES_BACKING_TAG_NAME, JPF_FILE_EXTENSION_DOT, JPF_BASE_CLASS, diagnostics)) {
+ File originalFile = CompilerUtils.getSourceFile(classDecl, true);
+ FacesBackingInfo fbInfo = new FacesBackingInfo(originalFile, classDecl.getQualifiedName());
+ setSourceFileInfo(classDecl, fbInfo);
+ return new FacesBackingChecker(env, fbInfo, diagnostics);
+ }
+ } else {
+ AnnotationInstance ann = CompilerUtils.getAnnotation(classDecl, CONTROLLER_TAG_NAME);
+
+ if (ann != null) {
+ diagnostics.addError(ann, "error.annotation-invalid-base-class2",
+ CONTROLLER_TAG_NAME, JPF_BASE_CLASS, SHARED_FLOW_BASE_CLASS);
+ }
+
+ ann = CompilerUtils.getAnnotation(classDecl, FACES_BACKING_TAG_NAME);
+
+ if (ann != null) {
+ diagnostics.addError(ann, "error.annotation-invalid-base-class",
+ FACES_BACKING_TAG_NAME, FACES_BACKING_BEAN_CLASS);
+ }
+ }
+
+ return null;
+ }
+
+ public BaseGenerator getGenerator(ClassDeclaration classDecl, Diagnostics diags) {
+ AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
+ SourceFileInfo sourceFileInfo = getSourceFileInfo(classDecl);
+
+ if (CompilerUtils.isAssignableFrom(JPF_BASE_CLASS, classDecl, env)) {
+ assert sourceFileInfo != null : classDecl.getQualifiedName();
+ assert sourceFileInfo instanceof FlowControllerInfo : sourceFileInfo.getClass().getName();
+ return new PageFlowGenerator(env, (FlowControllerInfo) sourceFileInfo, diags);
+ } else if (CompilerUtils.isAssignableFrom(SHARED_FLOW_BASE_CLASS, classDecl, env)) {
+ assert sourceFileInfo != null : classDecl.getQualifiedName();
+ assert sourceFileInfo instanceof FlowControllerInfo : sourceFileInfo.getClass().getName();
+ return new SharedFlowGenerator(env, (FlowControllerInfo) sourceFileInfo, diags);
+ } else if (CompilerUtils.isAssignableFrom(FACES_BACKING_BEAN_CLASS, classDecl, env)) {
+ assert sourceFileInfo != null : classDecl.getQualifiedName();
+ assert sourceFileInfo instanceof FacesBackingInfo : sourceFileInfo.getClass().getName();
+ return new FacesBackingGenerator(env, sourceFileInfo, diags);
+ }
+
+ return null;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/SilentDiagnostics.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/SilentDiagnostics.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/SilentDiagnostics.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/SilentDiagnostics.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.processor;
+
+import org.apache.ti.compiler.internal.Diagnostics;
+import org.apache.ti.compiler.internal.typesystem.declaration.AnnotationInstance;
+import org.apache.ti.compiler.internal.typesystem.declaration.AnnotationValue;
+import org.apache.ti.compiler.internal.typesystem.declaration.Declaration;
+
+public class SilentDiagnostics extends Diagnostics {
+
+ public SilentDiagnostics() {
+ super(null);
+ }
+
+ public void addErrorArrayArgs(Declaration decl, String messageKey, Object[] args) {
+ setHasErrors(true);
+ }
+
+ public void addErrorArrayArgs(AnnotationInstance ann, String messageKey, Object[] args) {
+ setHasErrors(true);
+ }
+
+ public void addErrorArrayArgs(AnnotationValue value, String messageKey, Object[] args) {
+ setHasErrors(true);
+ }
+
+ public void addWarningArrayArgs(Declaration decl, String messageKey, Object[] args) {
+ }
+
+ public void addWarningArrayArgs(AnnotationInstance ann, String messageKey, Object[] args) {
+ }
+
+ public void addWarningArrayArgs(AnnotationValue value, String messageKey, Object[] args) {
+ }
+
+ protected String getResourceString(String key, Object[] args) {
+ assert false; // this should never get called
+ return null;
+ }
+}
+
+
+
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/TwoPhaseAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/TwoPhaseAnnotationProcessor.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/TwoPhaseAnnotationProcessor.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/processor/TwoPhaseAnnotationProcessor.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.processor;
+
+import org.apache.ti.compiler.internal.Diagnostics;
+import org.apache.ti.compiler.internal.FatalCompileTimeException;
+import org.apache.ti.compiler.internal.typesystem.declaration.AnnotationTypeDeclaration;
+import org.apache.ti.compiler.internal.typesystem.declaration.Declaration;
+import org.apache.ti.compiler.internal.typesystem.env.AnnotationProcessor;
+import org.apache.ti.compiler.internal.typesystem.env.AnnotationProcessorEnvironment;
+
+import java.text.MessageFormat;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * The TwoPhaseAnnotationProcessor class is an abstract class that implements the APT
+ * AnnotationProcessor interface. It breaks the work of the process() method of the
+ * AnnotationProcessor down into two distinct phases, represented as abstract method
+ * of TwoPhaseAnnotationProcessor that are to be implemented by concrete subclasses.
+ * <p/>
+ * The two phases of processing are:
+ * <p/>
+ * The <b>check</b> phase is used to validate input Declarations that have been
+ * annotated with annotations claimed by the processor to ensure that it
+ * is semantically valid. If the presence of the input Declaration implies the need
+ * to add new files, and those files need to be visible during the check phase for
+ * other Declarations, then the AnnotationProcessorEnvironment's Filer API should be
+ * used to add those files in this phase. The adding of such files at this point
+ * should typically not result in their emission to persistent storage (i.e. disk),
+ * but rather be kept in memory to be referenced by the check phase of other
+ * Declarations.
+ * The <b>generate</b> phase will actually emit any source, binary, or class files
+ * that are derived from the input Declaration, including files added via the Filer
+ * API during the check phase. The Filer API may also be used in this phase to add
+ * new files, however, such additions will not be visible during the check phase of
+ * any Declarations.
+ * </ul>
+ * <p/>
+ * The benefits of breaking process() down into check() and generate() phases are:
+ * <p/>
+ * Makes it possible to perform the semantic validation of Declarations without
+ * necessarily resulting in code generation.
+ * Provides a clearer association between input Declarations and generator output.
+ * </ol>
+ * TwoPhaseAnnotationProcessor is intended provide a uniform mechanism for writing
+ * AnnotationProcessor implementations that can be used in tooling environments more
+ * sophisticated than command-line tools (that may not do all their work on source
+ * in a single pass). Such environments will typically also provide implementations
+ * of the AnnotationProcessorEnvironment and associated interfaces (Messager,
+ * Filer etc).
+ */
+public abstract class TwoPhaseAnnotationProcessor
+ extends Diagnostics
+ implements AnnotationProcessor {
+
+ protected TwoPhaseAnnotationProcessor(AnnotationTypeDeclaration[] atds, AnnotationProcessorEnvironment env) {
+ super(env);
+ _atds = atds;
+ _locale = Locale.getDefault();
+ }
+
+ /**
+ * Implements AnnotationProcessor.process() as two phases, "check" and "generate".
+ * "generate" will not be called if "check" emitted any errors (via printError()).
+ */
+ public void process() {
+ try {
+ check();
+
+ // Do not call generate if check resulted in errors.
+ if (! hasErrors()) generate();
+ }
+ catch (FatalCompileTimeException e) {
+ e.printDiagnostic(this);
+ }
+ }
+
+ /**
+ * Performs semantic validation of input Declarations that are annotated with
+ * annotations claimed by this AnnotationProcessor.
+ */
+ public void check()
+ throws FatalCompileTimeException {
+ HashSet declsToCheck = new HashSet();
+
+ //
+ // First, build up the Set of declarations to check. We don't want any duplicates.
+ //
+ for (int i = 0; i < _atds.length; ++i) {
+ AnnotationTypeDeclaration atd = _atds[i];
+ Declaration[] decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith(atd);
+ for (int j = 0; j < decls.length; j++) {
+ declsToCheck.add(decls[j]);
+ }
+ }
+
+ //
+ // Now, check the declarations.
+ //
+ for (Iterator i = declsToCheck.iterator(); i.hasNext();) {
+ Declaration decl = (Declaration) i.next();
+ check(decl);
+ }
+ }
+
+ /**
+ * Emits additional artifacts for input Declarations that are annotated with
+ * annotations claimed by this AnnotationProcessor.
+ */
+ public void generate() {
+ try {
+ HashSet alreadyProcessed = new HashSet();
+
+ for (int i = 0; i < _atds.length; i++) {
+ AnnotationTypeDeclaration atd = _atds[i];
+ Declaration[] decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith(atd);
+
+ for (int j = 0; j < decls.length; j++) {
+ Declaration decl = decls[j];
+ if (! alreadyProcessed.contains(decl)) generate(decl);
+ alreadyProcessed.add(decl);
+ }
+ }
+ }
+ catch (FatalCompileTimeException e) {
+ e.printDiagnostic(this);
+ }
+ }
+
+ /**
+ * The check method is responsible for all semantic validation of the input Declaration.
+ * <p/>
+ * All semantic errors/warnings associated with the input Declaration should
+ * be output during check via methods on {@link Diagnostics}.
+ * <p/>
+ * If the presence of the input Declaration implies the need to add new files,
+ * and those files need to be visible during the check phase for
+ * other Declarations, then the AnnotationProcessorEnvironment's Filer API should be
+ * used to add those files in this phase. The adding of such files at this point
+ * should typically not result in their emission to persistent storage (i.e. disk),
+ * but rather be kept in memory to be referenced by the check phase of other
+ * Declarations.
+ */
+ public abstract void check(Declaration decl)
+ throws FatalCompileTimeException;
+
+ /**
+ * The generate method is responsible for the generation of any additional artifacts
+ * (source, class, or binary) that are derived from the input Declaration.
+ */
+ public abstract void generate(Declaration decl)
+ throws FatalCompileTimeException;
+
+ //
+ // Helper functions for handling diagnostics
+ //
+
+ protected String getResourceString(String id, Object[] args) {
+ ResourceBundle rb = ResourceBundle.getBundle(getClass().getPackage().getName() + ".strings", _locale);
+ String pattern = rb.getString(id);
+ return MessageFormat.format(pattern, args);
+ }
+
+ private AnnotationTypeDeclaration[] _atds;
+ private Locale _locale;
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/TypesystemElement.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/TypesystemElement.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/TypesystemElement.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/TypesystemElement.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem;
+
+public interface TypesystemElement {
+
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationInstance.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationInstance.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationInstance.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationInstance.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+import org.apache.ti.compiler.internal.typesystem.TypesystemElement;
+import org.apache.ti.compiler.internal.typesystem.type.AnnotationType;
+import org.apache.ti.compiler.internal.typesystem.util.SourcePosition;
+
+import java.util.Map;
+
+public interface AnnotationInstance
+ extends TypesystemElement {
+
+ AnnotationType getAnnotationType();
+
+ SourcePosition getPosition();
+
+ // Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues();
+ Map getElementValues();
+
+ TypeDeclaration getContainingType();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationTypeDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationTypeDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationTypeDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationTypeDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+public interface AnnotationTypeDeclaration
+ extends InterfaceDeclaration {
+
+ AnnotationTypeElementDeclaration[] getAnnotationMembers();
+
+ public AnnotationTypeElementDeclaration getMember(String name);
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationTypeElementDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationTypeElementDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationTypeElementDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationTypeElementDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+public interface AnnotationTypeElementDeclaration
+ extends MethodDeclaration {
+
+ AnnotationValue getDefaultValue();
+
+ // --Commented out by Inspection (3/13/05 4:41 PM): AnnotationTypeDeclaration getDeclaringAnnotationType();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationValue.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationValue.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationValue.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/AnnotationValue.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+public interface AnnotationValue {
+
+ Object getValue();
+
+ org.apache.ti.compiler.internal.typesystem.util.SourcePosition getPosition();
+
+ String toString();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ClassDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ClassDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ClassDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ClassDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+import org.apache.ti.compiler.internal.typesystem.type.ClassType;
+
+public interface ClassDeclaration
+ extends TypeDeclaration {
+
+ ClassType getSuperclass();
+
+ ConstructorDeclaration[] getConstructors();
+
+ MethodDeclaration[] getMethods();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ConstructorDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ConstructorDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ConstructorDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ConstructorDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+public interface ConstructorDeclaration
+ extends ExecutableDeclaration {
+
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/Declaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/Declaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/Declaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/Declaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+import org.apache.ti.compiler.internal.typesystem.TypesystemElement;
+
+import java.util.Set;
+
+public interface Declaration
+ extends TypesystemElement {
+
+ boolean equals(Object o);
+
+ // --Commented out by Inspection (3/13/05 4:42 PM): String getDocComment();
+
+ AnnotationInstance[] getAnnotationInstances();
+
+ //<A extends Annotation> A getAnnotation( Class<A> aClass );
+
+ /**
+ * Set of Modifier
+ */
+ Set getModifiers();
+
+ String getSimpleName();
+
+ org.apache.ti.compiler.internal.typesystem.util.SourcePosition getPosition();
+
+ //void accept( DeclarationVisitor declarationVisitor );
+
+ boolean hasModifier(Modifier modifier);
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ExecutableDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ExecutableDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ExecutableDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ExecutableDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+public interface ExecutableDeclaration
+ extends MemberDeclaration {
+ // --Commented out by Inspection (3/13/05 4:42 PM): boolean isVarArgs();
+
+ //TypeParameterDeclaration[] getFormalTypeParameters();
+
+ ParameterDeclaration[] getParameters();
+
+ //ReferenceType[] getThrownTypes();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/FieldDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/FieldDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/FieldDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/FieldDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+import org.apache.ti.compiler.internal.typesystem.type.TypeInstance;
+
+public interface FieldDeclaration
+ extends MemberDeclaration {
+
+ TypeInstance getType();
+
+ // --Commented out by Inspection (3/13/05 4:42 PM): Object getConstantValue();
+
+ // --Commented out by Inspection (3/13/05 4:42 PM): String getConstantExpression();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/InterfaceDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/InterfaceDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/InterfaceDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/InterfaceDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+public interface InterfaceDeclaration
+ extends TypeDeclaration {
+
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/MemberDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/MemberDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/MemberDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/MemberDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+public interface MemberDeclaration
+ extends Declaration {
+
+ TypeDeclaration getDeclaringType();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/MethodDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/MethodDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/MethodDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/MethodDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+import org.apache.ti.compiler.internal.typesystem.type.TypeInstance;
+
+public interface MethodDeclaration
+ extends ExecutableDeclaration {
+
+ TypeInstance getReturnType();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/Modifier.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/Modifier.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/Modifier.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/Modifier.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+public class Modifier {
+
+ protected static final int INT_ABSTRACT = 0;
+ protected static final int INT_PRIVATE = 1;
+ protected static final int INT_PROTECTED = 2;
+ protected static final int INT_PUBLIC = 3;
+ protected static final int INT_STATIC = 4;
+ protected static final int INT_TRANSIENT = 5;
+ protected static final int INT_FINAL = 6;
+ protected static final int INT_SYNCHRONIZED = 7;
+ protected static final int INT_NATIVE = 8;
+
+ public static final Modifier ABSTRACT = new Modifier(INT_ABSTRACT);
+ public static final Modifier PRIVATE = new Modifier(INT_PRIVATE);
+ public static final Modifier PROTECTED = new Modifier(INT_PROTECTED);
+ public static final Modifier PUBLIC = new Modifier(INT_PUBLIC);
+ public static final Modifier STATIC = new Modifier(INT_STATIC);
+ public static final Modifier TRANSIENT = new Modifier(INT_TRANSIENT);
+ public static final Modifier FINAL = new Modifier(INT_FINAL);
+ public static final Modifier SYNCHRONIZED = new Modifier(INT_SYNCHRONIZED);
+ public static final Modifier NATIVE = new Modifier(INT_NATIVE);
+
+ private int _val;
+
+ private Modifier(int val) {
+ _val = val;
+ }
+
+ public String toString() {
+ switch (_val) {
+ case INT_ABSTRACT:
+ return "abstract";
+ case INT_PRIVATE:
+ return "private";
+ case INT_PROTECTED:
+ return "protected";
+ case INT_PUBLIC:
+ return "public";
+ case INT_STATIC:
+ return "static";
+ case INT_TRANSIENT:
+ return "transient";
+ case INT_FINAL:
+ return "final";
+ case INT_SYNCHRONIZED:
+ return "synchronized";
+ case INT_NATIVE:
+ return "native";
+ }
+
+ assert false : _val;
+ return "<unknown Modifier>";
+ }
+
+ public boolean equals(Object o) {
+ if (o == null) return false;
+ if (o == this) return true;
+ if (! (o instanceof Modifier)) return false;
+ return ((Modifier) o)._val == _val;
+ }
+
+ public int hashCode() {
+ return _val;
+ }
+
+ protected Modifier() {
+ _val = -1;
+ }
+
+ protected void setVal(int val) {
+ _val = val;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/PackageDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/PackageDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/PackageDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/PackageDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+public interface PackageDeclaration {
+
+ String getQualifiedName();
+
+ ClassDeclaration[] getClasses();
+
+ //Collection<com.sun.mirror.declaration.EnumDeclaration> getEnums();
+
+ //Collection<com.sun.mirror.declaration.InterfaceDeclaration> getInterfaces();
+
+ //Collection<com.sun.mirror.declaration.AnnotationTypeDeclaration> getAnnotationTypes();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ParameterDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ParameterDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ParameterDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/ParameterDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+import org.apache.ti.compiler.internal.typesystem.type.TypeInstance;
+
+public interface ParameterDeclaration
+ extends Declaration {
+
+ TypeInstance getType();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/TypeDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/TypeDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/TypeDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/TypeDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+import org.apache.ti.compiler.internal.typesystem.type.InterfaceType;
+
+public interface TypeDeclaration
+ extends MemberDeclaration {
+
+ PackageDeclaration getPackage();
+
+ String getQualifiedName();
+
+ //TypeParameterDeclaration[] getFormalTypeParameters();
+
+ InterfaceType[] getSuperinterfaces();
+
+ FieldDeclaration[] getFields();
+
+ MethodDeclaration[] getMethods();
+
+ TypeDeclaration[] getNestedTypes();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/TypeParameterDeclaration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/TypeParameterDeclaration.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/TypeParameterDeclaration.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/declaration/TypeParameterDeclaration.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.declaration;
+
+import org.apache.ti.compiler.internal.typesystem.type.ReferenceType;
+
+public interface TypeParameterDeclaration
+ extends Declaration {
+
+ ReferenceType[] getBounds();
+
+ // --Commented out by Inspection (3/13/05 4:43 PM): Declaration getOwner();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/AnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/AnnotationProcessor.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/AnnotationProcessor.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/AnnotationProcessor.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.env;
+
+public interface AnnotationProcessor {
+
+ void process();
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/AnnotationProcessorEnvironment.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/AnnotationProcessorEnvironment.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/AnnotationProcessorEnvironment.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/AnnotationProcessorEnvironment.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.env;
+
+import org.apache.ti.compiler.internal.typesystem.declaration.AnnotationTypeDeclaration;
+import org.apache.ti.compiler.internal.typesystem.declaration.Declaration;
+import org.apache.ti.compiler.internal.typesystem.declaration.TypeDeclaration;
+
+import java.util.Map;
+
+public interface AnnotationProcessorEnvironment {
+
+ /**
+ * Map of String -> String
+ */
+ Map getOptions();
+
+ Messager getMessager();
+
+ Filer getFiler();
+
+ TypeDeclaration[] getSpecifiedTypeDeclarations();
+
+ TypeDeclaration getTypeDeclaration(String s);
+
+ Declaration[] getDeclarationsAnnotatedWith(AnnotationTypeDeclaration annotationTypeDeclaration);
+
+ void setAttribute(String propertyName, Object value);
+
+ Object getAttribute(String propertyName);
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/Filer.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/Filer.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/Filer.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/Filer.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.env;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public interface Filer {
+
+ PrintWriter createTextFile(File file) throws IOException;
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/Messager.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/Messager.java?rev=280879&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/Messager.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/compiler/internal/typesystem/env/Messager.java Wed Sep 14 09:20:05 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2004 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.compiler.internal.typesystem.env;
+
+import org.apache.ti.compiler.internal.typesystem.util.SourcePosition;
+
+public interface Messager {
+
+ void printError(String s);
+
+ void printError(SourcePosition sourcePosition, String s);
+
+ void printWarning(String s);
+
+ void printWarning(SourcePosition sourcePosition, String s);
+
+ void printNotice(String s);
+
+ void printNotice(SourcePosition sourcePosition, String s);
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org