Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.jst.validation.sample')
-rw-r--r--tests/org.eclipse.jst.validation.sample/.classpath10
-rw-r--r--tests/org.eclipse.jst.validation.sample/.cvsignore1
-rw-r--r--tests/org.eclipse.jst.validation.sample/.project30
-rw-r--r--tests/org.eclipse.jst.validation.sample/build.properties10
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystem.bat46
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystemFWK/filesystem.properties21
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemApplication.java82
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemLoader.java62
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemManager.java220
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FullReporter.java92
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/IFilesystemHelper.java34
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/IncrementalReporter.java168
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/MessageManager.java254
-rw-r--r--tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/ValidatorMessages.java171
-rw-r--r--tests/org.eclipse.jst.validation.sample/plugin.xml78
-rw-r--r--tests/org.eclipse.jst.validation.sample/prop.bat45
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValFS/org/eclipse/jst/validation/sample/filesystemimpl/FilesystemPropertiesHelper.java203
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PluginPropertyFile.java232
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PropertiesHelper.java234
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PropertiesValidatorPlugin.java51
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/PModelEnum.java35
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/PropertiesValidator.java107
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/ValidatorPropertyFile.java115
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/APropertyFile.java728
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/CompareProperties.java377
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/IValidationConstants.java46
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/Main.java451
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/MessageMetaData.java211
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyFile.java106
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyLine.java646
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyLineComparator.java254
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/ResourceHandler.java90
-rw-r--r--tests/org.eclipse.jst.validation.sample/propertiesValidator/propertiesValidator.properties41
-rw-r--r--tests/org.eclipse.jst.validation.sample/test/test.properties67
-rw-r--r--tests/org.eclipse.jst.validation.sample/test/test2.properties24
-rw-r--r--tests/org.eclipse.jst.validation.sample/tvtplugin.xml52
36 files changed, 0 insertions, 5394 deletions
diff --git a/tests/org.eclipse.jst.validation.sample/.classpath b/tests/org.eclipse.jst.validation.sample/.classpath
deleted file mode 100644
index 202b2383..00000000
--- a/tests/org.eclipse.jst.validation.sample/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="propertiesValidator/"/>
- <classpathentry kind="src" path="propertiesValFS/"/>
- <classpathentry kind="src" path="propertiesValWB/"/>
- <classpathentry kind="src" path="filesystemFWK/"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/tests/org.eclipse.jst.validation.sample/.cvsignore b/tests/org.eclipse.jst.validation.sample/.cvsignore
deleted file mode 100644
index ba077a40..00000000
--- a/tests/org.eclipse.jst.validation.sample/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/tests/org.eclipse.jst.validation.sample/.project b/tests/org.eclipse.jst.validation.sample/.project
deleted file mode 100644
index aff2b8fb..00000000
--- a/tests/org.eclipse.jst.validation.sample/.project
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jst.validation.sample</name>
- <comment></comment>
- <projects>
- <project>com.ibm.etools.validation</project>
- <project>com.ibm.wtp.common</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/tests/org.eclipse.jst.validation.sample/build.properties b/tests/org.eclipse.jst.validation.sample/build.properties
deleted file mode 100644
index 3cf80e03..00000000
--- a/tests/org.eclipse.jst.validation.sample/build.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-source.runtime/propertiesValidator.jar = propertiesValidator/,\
- propertiesValFS/,\
- propertiesValWB/,\
- filesystemFWK/
-bin.includes = runtime/propertiesValidator.jar,\
- plugin.xml,\
- filesystem.bat,\
- prop.bat
-jars.compile.order = runtime/propertiesValidator.jar
-output.runtime/propertiesValidator.jar = bin/
diff --git a/tests/org.eclipse.jst.validation.sample/filesystem.bat b/tests/org.eclipse.jst.validation.sample/filesystem.bat
deleted file mode 100644
index 2dc85a98..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystem.bat
+++ /dev/null
@@ -1,46 +0,0 @@
-@echo off
-REM Licensed Material - Property of IBM
-REM (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
-REM US Government Users Restricted Rights - Use, duplication or disclosure
-REM restricted by GSA ADP Schedule Contract with IBM Corp.
-REM
-REM DISCLAIMER OF WARRANTIES.
-REM The following [enclosed] code is sample code created by IBM
-REM Corporation. This sample code is not part of any standard or IBM
-REM product and is provided to you solely for the purpose of assisting
-REM you in the development of your applications. The code is provided
-REM "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
-REM NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-REM FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
-REM THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
-REM for any damages arising out of your use of the sample code, even
-REM if it has been advised of the possibility of such damages.
-REM
-REM This batch file runs the "filesystem framework"'s application
-REM
-setlocal
-
-if "%JAVA_HOME%" EQU "" goto syntax
-
-set CLASSPATH=%CLASSPATH%;..\com.ibm.etools.logging.util_5.1.0\runtime\logutil.jar
-set CLASSPATH=%CLASSPATH%;..\com.ibm.etools.validation.core_5.1.0\runtime\common.jar
-set CLASSPATH=%CLASSPATH%;.\runtime\propertiesValidator.jar
-set CLASSPATH=%CLASSPATH%;.\runtime\filesystemFWK.jar
-set CLASSPATH=%CLASSPATH%;.\runtime\propertiesValWB.jar
-set CLASSPATH=%CLASSPATH%;.\runtime\propertiesValFS.jar
-
-%JAVA_HOME%\bin\java com.ibm.etools.validation.filesystem.FilesystemApplication %1
-goto :end
-
-:syntax
-echo.
-echo The JAVA_HOME environment variable must be set to the JRE directory.
-echo e.g., set JAVA_HOME=C:\JRE
-echo where JRE has a subdirectory named "bin"
-echo.
-echo.
-goto :end
-
-:end
-endlocal
-@echo on \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/filesystemFWK/filesystem.properties b/tests/org.eclipse.jst.validation.sample/filesystemFWK/filesystem.properties
deleted file mode 100644
index a7283494..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystemFWK/filesystem.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Licensed Material - Property of IBM
-# (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
-# US Government Users Restricted Rights - Use, duplication or disclosure
-# restricted by GSA ADP Schedule Contract with IBM Corp.
-#
-# DISCLAIMER OF WARRANTIES.
-# The following [enclosed] code is sample code created by IBM
-# Corporation. This sample code is not part of any standard or IBM
-# product and is provided to you solely for the purpose of assisting
-# you in the development of your applications. The code is provided
-# "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
-# NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
-# THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
-# for any damages arising out of your use of the sample code, even
-# if it has been advised of the possibility of such damages.
-#
-
-# VFFS = Validation Framework File System
-VFFS0000 = VFFS0000E: Internal error caused premature termination of validator {0}. See the stack trace below. \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemApplication.java b/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemApplication.java
deleted file mode 100644
index 4100732b..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemApplication.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.eclipse.jst.validation.sample.filesystem;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-
-import org.eclipse.wst.validation.internal.core.IFileDelta;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.core.ValidatorLauncher;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * This class is the representation of a file system based application
- * which needs to use the common validation APIs.
- */
-public class FilesystemApplication {
- /**
- * The argv[] parameter needs to be a fully-qualified list of file names
- * of files that should be validated.
- */
- public static void main(String argv[]) {
- IFileDelta[] files = FilesystemManager.getManager().getFileDeltas(argv);
- boolean fullBuild = ((files == null) || (files.length == 0));
-
- IReporter reporter = null;
- if (fullBuild) {
- reporter = new FullReporter();
- }
- else {
- reporter = new IncrementalReporter();
- }
-
- FilesystemLoader loaders[] = FilesystemManager.getManager().getLoaders(files);
- for (int i=0; i<loaders.length; i++) {
- FilesystemLoader loader = loaders[i];
- try {
- ValidatorLauncher.getLauncher().start(loader.getHelper(), loader.getValidator(), reporter);
- if (!fullBuild) {
- ((IncrementalReporter)reporter).report();
- }
- }
- catch (ValidationException exc) {
- Message message = new Message("filesystem", IMessage.HIGH_SEVERITY, "VFFS0000", new String[]{loader.getValidator().getClass().getName()}); //$NON-NLS-1$ //$NON-NLS-2$
- reporter.displaySubtask(loader.getValidator(), message);
-
- if(exc.getAssociatedMessage() != null) {
- System.out.println(exc.getAssociatedMessage());
- }
-
- exc.printStackTrace();
- if(exc.getAssociatedException() != null) {
- exc.getAssociatedException().printStackTrace();
- }
- // continue with the next validation
- }
- catch (Exception exc) {
- Message message = new Message("filesystem", IMessage.HIGH_SEVERITY, "VFFS0000", new String[]{loader.getValidator().getClass().getName()}); //$NON-NLS-1$ //$NON-NLS-2$
- reporter.displaySubtask(loader.getValidator(), message);
- // continue with the next validation
- exc.printStackTrace();
- }
- }
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemLoader.java b/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemLoader.java
deleted file mode 100644
index 9b44fc6c..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemLoader.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.eclipse.jst.validation.sample.filesystem;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This class associates a Validator with a Helper and the file extensions that
- * the validator runs on.
- */
-public class FilesystemLoader {
- private IFilesystemHelper _helper = null;
- private IValidator _validator = null;
- private String[] _fileExtensions = null;
-
- public FilesystemLoader(String[] fileExtensions, IFilesystemHelper helper, IValidator validator) {
- super();
-
- _fileExtensions = fileExtensions;
- _helper = helper;
- _validator = validator;
- }
-
- /**
- * Return the helper that the validator needs to access information
- * in the filesystem validation framework.
- */
- public IFilesystemHelper getHelper() {
- return _helper;
- }
-
- /**
- * Return the validator that checks the rules.
- */
- public IValidator getValidator() {
- return _validator;
- }
-
- /**
- * Return a list of file name extensions that this validator validates.
- */
- public String[] getFileExtensions() {
- return _fileExtensions;
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemManager.java b/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemManager.java
deleted file mode 100644
index cad383ab..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FilesystemManager.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package org.eclipse.jst.validation.sample.filesystem;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.wst.validation.internal.core.FileDelta;
-import org.eclipse.wst.validation.internal.core.IFileDelta;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This class is the heart of the filesystem validation framework.
- * It &quot;loads&quot; each validator's metadata
- */
-public class FilesystemManager {
- private static FilesystemManager _inst = null;
- private Set _loaders = null;
-
- private FilesystemManager() {
- _loaders = new HashSet();
-
- // Please pretend that this metadata, i.e., the file extension, fully-qualified
- // class name of the helper, and fully-qualified class name of the validator,
- // was loaded generically somehow. In practice, this information could be stored
- // in .xml files, in a configuration file, etc., that the framework would read
- // to find the installed validators.
- try {
- _loaders.add(new FilesystemLoader(new String[]{".properties"}, loadHelper("org.eclipse.jst.validation.sample.filesystemimpl.FilesystemPropertiesHelper"), loadValidator("org.eclipse.jst.validation.sample.PropertiesValidator"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- catch(IllegalArgumentException exc) {
- exc.printStackTrace();
- }
- catch(ClassNotFoundException exc) {
- exc.printStackTrace();
- }
- catch(IllegalAccessException exc) {
- exc.printStackTrace();
- }
- catch(InstantiationException exc) {
- exc.printStackTrace();
- }
- }
-
- /**
- * Given a fully-qualified name of a helper, return an instance of it.
- */
- private static IFilesystemHelper loadHelper(String className) throws IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InstantiationException {
- return (IFilesystemHelper)loadClass(className);
- }
-
- /**
- * Given a fully-qualified name of a validator, return an instance of it.
- */
- private static IValidator loadValidator(String className) throws IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InstantiationException {
- return (IValidator)loadClass(className);
- }
-
- /**
- * Return an instance of the class identified by the className parameter,
- * which contains the fully-qualified class name of the class.
- */
- private static Object loadClass(String className) throws IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InstantiationException {
- if(className == null) {
- throw new IllegalArgumentException("loadClass argument must not be null"); //$NON-NLS-1$
- }
-
- Class clazz = Class.forName(className);
- return clazz.newInstance();
- }
-
- /**
- * Return the FilesystemManager singleton.
- */
- public static FilesystemManager getManager() {
- if(_inst == null) {
- _inst = new FilesystemManager();
- }
- return _inst;
- }
-
- /**
- * Given an array of file names, return an array of IFileDelta
- * instances to pass to the validator instance.
- */
- public IFileDelta[] getFileDeltas(String[] fileNames) {
- if((fileNames == null) || (fileNames.length == 0)) {
- return null;
- }
-
- FileDelta[] files = new FileDelta[fileNames.length];
- for(int i=0; i<fileNames.length; i++) {
- files[i] = new FileDelta(fileNames[i], IFileDelta.CHANGED);
- }
- return files;
- }
-
- /**
- * Given an array of IFileDelta instances, return an array
- * of the IValidator instances, with their associated IValidationContext instances,
- * that validate these particular delta instances.
- */
- public FilesystemLoader[] getLoaders(IFileDelta[] deltas) {
- if(deltas == null) {
- return getAllLoaders();
- }
-
- Set loaders = new HashSet();
- for(int i=0; i<deltas.length; i++) {
- FilesystemLoader[] loaderArray = getLoadersFor(deltas[i]);
- if(loaderArray != null) {
- for(int j=0; j<loaderArray.length; j++) {
- loaders.add(loaderArray[j]);
- }
- }
- }
-
- FilesystemLoader[] result = new FilesystemLoader[loaders.size()];
- loaders.toArray(result);
- return result;
- }
-
- /**
- * Given an IValidator instance, return the IValidationContext instance that the
- * IValidator uses to load information from the filesystem validation
- * framework environment.
- */
- public IFilesystemHelper getHelper(IValidator validator) {
- if(validator == null) {
- return null;
- }
-
- Iterator iterator = _loaders.iterator();
- while(iterator.hasNext()) {
- FilesystemLoader loader = (FilesystemLoader)iterator.next();
- if(validator.equals(loader.getValidator())) {
- return loader.getHelper();
- }
- }
-
- return null;
- }
-
- /**
- * Given the fully-qualified name of the validator, return the IValidator instance.
- * null will be returned if the IValidator cannot be found.
- */
- public IValidator getValidator(String validatorClassName) {
- if(validatorClassName == null) {
- return null;
- }
-
- Iterator iterator = _loaders.iterator();
- while(iterator.hasNext()) {
- FilesystemLoader loader = (FilesystemLoader)iterator.next();
- if(validatorClassName.equals(loader.getValidator().getClass().getName())) {
- return loader.getValidator();
- }
- }
-
- return null;
- }
-
- /**
- * Return an array of all FilesystemLoader instances. Each loader has
- * one IValidator and one IValidationContext.
- */
- public FilesystemLoader[] getAllLoaders() {
- FilesystemLoader[] result = new FilesystemLoader[_loaders.size()];
- _loaders.toArray(result);
- return result;
- }
-
- /**
- * Given a file name, return the loader which contains the validator & helper
- * which can validate that file, if one exists.
- */
- public FilesystemLoader[] getLoadersFor(IFileDelta delta) {
- Iterator iterator = _loaders.iterator();
- FilesystemLoader[] tempLoaders = new FilesystemLoader[_loaders.size()];
- int count = 0;
- while(iterator.hasNext()) {
- FilesystemLoader loader = (FilesystemLoader)iterator.next();
- String[] fileExtensions = loader.getFileExtensions();
- if(fileExtensions == null) {
- continue;
- }
-
- for(int i=0; i<fileExtensions.length; i++) {
- if(delta.getFileName().endsWith(fileExtensions[i]) && (delta.getDeltaType() == IFileDelta.ADDED || delta.getDeltaType() == IFileDelta.CHANGED || delta.getDeltaType() == IFileDelta.DELETED)) {
- tempLoaders[count++] = loader;
- }
- }
- }
-
- FilesystemLoader[] result = new FilesystemLoader[count];
- System.arraycopy(tempLoaders, 0, result, 0, count);
- return result;
- }
-
-}
diff --git a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FullReporter.java b/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FullReporter.java
deleted file mode 100644
index 1959b2a5..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/FullReporter.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.eclipse.jst.validation.sample.filesystem;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.util.List;
-
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This reporter is used when full validation is needed. It doesn't cache
- * anything, so it's faster than the IncrementalReporter.
- */
-public class FullReporter implements IReporter {
- public FullReporter() {
- super();
- }
-
- /**
- * @see IReporter#addMessage(IValidator, IMessage)
- */
- public void addMessage(IValidator validator, IMessage message) {
- if (message == null) {
- return;
- }
-
- System.out.println(MessageManager.formatMessage(validator, message));
- }
-
- /**
- * @see IReporter#displaySubtask(IValidator, IMessage)
- */
- public void displaySubtask(IValidator validator, IMessage message) {
- // Flush the message to the user immediately.
- System.err.println(message.getText());
- }
-
- /**
- * @see IReporter#getMessages()
- */
- public List getMessages() {
- // this reporter does not support message access
- return null;
- }
-
- /**
- * @see IReporter#isCancelled()
- */
- public boolean isCancelled() {
- // to make things easy, do not allow the user to cancel validation.
- return false;
- }
-
- /**
- * @see IReporter#removeAllMessages(IValidator)
- */
- public void removeAllMessages(IValidator validator) {
- // since no messages are stored, there's nothing to remove
- }
-
- /**
- * @see IReporter#removeAllMessages(IValidator, Object)
- */
- public void removeAllMessages(IValidator validator, Object object) {
- // since no messages are stored, there's nothing to remove
- }
-
- /**
- * @see IReporter#removeMessageSubset(IValidator, Object, String)
- */
- public void removeMessageSubset(IValidator validator, Object obj, String groupName) {
- // Since this reporter doesn't store messages, there is no removal of any messages
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/IFilesystemHelper.java b/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/IFilesystemHelper.java
deleted file mode 100644
index 9938513a..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/IFilesystemHelper.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.eclipse.jst.validation.sample.filesystem;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-
-/**
- * To integrate a validator into this framework, an implementation of this
- * IValidationContext must be provided.
- */
-public interface IFilesystemHelper extends IValidationContext {
- /**
- * Return the fully-qualified name of the file which the IMessage is reported against.
- */
- public String getFileName(IMessage message);
-}
diff --git a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/IncrementalReporter.java b/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/IncrementalReporter.java
deleted file mode 100644
index e8e3dba4..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/IncrementalReporter.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package org.eclipse.jst.validation.sample.filesystem;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This class is the file system specific implementation of an incremental IReporter.
- * It caches validation messages, so that messages can both be added and deleted.
- */
-public class IncrementalReporter implements IReporter {
-
- public IncrementalReporter() {
- super();
- }
-
- /**
- * @see IReporter#addMessage(IValidator, IMessage)
- */
- public void addMessage(IValidator validator, IMessage message) {
- if (validator == null) {
- return;
- }
-
- if (message == null) {
- return;
- }
-
- ValidatorMessages vm = MessageManager.getManager().getMessages(validator);
- if (vm != null) {
- vm.addValidationMessage(message);
- }
- }
-
- /**
- * @see IReporter#displaySubtask(IValidator, IMessage)
- */
- public void displaySubtask(IValidator validator, IMessage message) {
- // Flush the message to the user immediately.
- System.err.println(message.getText());
- }
-
- /**
- * @see IReporter#getMessages()
- */
- public List getMessages() {
- return null;
- }
-
- /**
- * Return a Map of String fully-qualified validator class names,
- * with a value of Collection, and the Collection contains the
- * MessageMetaData reported by the validator, of the given severity.
- */
- public Map getMessages(int messageType) {
- return MessageManager.getManager().getMessages(messageType);
- }
-
- /**
- * @see IReporter#isCancelled()
- */
- public boolean isCancelled() {
- // For simplicity, never allow cancellation.
- // In a production system, this method might query another object to find out its cancellation status.
- return false;
- }
-
- /**
- * @see IReporter#removeAllMessages(IValidator)
- */
- public void removeAllMessages(IValidator validator) {
- if (validator == null) {
- return;
- }
- MessageManager.getManager().removeAllMessages(validator);
- }
-
- /**
- * @see IReporter#removeAllMessages(IValidator, Object)
- */
- public void removeAllMessages(IValidator validator, Object object) {
- if (validator == null) {
- return;
- }
-
-
- MessageManager.getManager().removeAllMessages(validator, object);
- }
-
- /**
- * @see IReporter#removeMessageSubset(IValidator, Object, String)
- */
- public void removeMessageSubset(IValidator validator, Object obj, String groupName) {
- // implement later
- }
-
- /**
- * Display a formatted list of all of the problems found while
- * validating the file.
- */
- public void report() {
- System.out.println();
- System.out.println("Error messages"); //$NON-NLS-1$
- Map messages = getMessages(IMessage.HIGH_SEVERITY);
- report(messages);
-
- System.out.println();
- System.out.println("Warning messages"); //$NON-NLS-1$
- messages = getMessages(IMessage.NORMAL_SEVERITY);
- report(messages);
-
- System.out.println();
- System.out.println("Information messages"); //$NON-NLS-1$
- messages = getMessages(IMessage.LOW_SEVERITY);
- report(messages);
- }
-
- /**
- * @see IReporter#report(Map)
- */
- protected static void report(Map messages) {
- if(messages.size() == 0) {
- return;
- }
-
- Iterator iterator = messages.keySet().iterator();
- while(iterator.hasNext()) {
- String validatorClassName = (String)iterator.next();
- IValidator validator = FilesystemManager.getManager().getValidator(validatorClassName);
- IFilesystemHelper helper = FilesystemManager.getManager().getHelper(validator);
- List mssgList = (List)messages.get(validator);
- if(mssgList == null) {
- continue;
- }
-
- Collections.sort(mssgList, MessageManager.getManager().getMessageComparator(helper));
-
- for(int i=0; i<mssgList.size(); i++) {
- IMessage mssg = (IMessage)mssgList.get(i);
- System.out.println(MessageManager.formatMessage(validator, mssg));
- }
- }
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/MessageManager.java b/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/MessageManager.java
deleted file mode 100644
index 2db1c9eb..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/MessageManager.java
+++ /dev/null
@@ -1,254 +0,0 @@
-package org.eclipse.jst.validation.sample.filesystem;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This class manages the validation messages for each validator. Each validator's
- * messages can be retrieved by using the validator's unique name as a key into the
- * table. (i.e., call getMessages with the validator's unique name as the parameter.)
- */
-public class MessageManager {
- private static MessageManager _singleton = null;
- private Comparator _comparator = null;
-
- private Map _validationMessages = null;
-
- private MessageManager() {
- super();
-
- _validationMessages = new HashMap(10);
- }
-
- /**
- * Return the MessageManager singleton.
- */
- public static MessageManager getManager() {
- if (_singleton == null) {
- _singleton = new MessageManager();
- }
- return _singleton;
- }
-
- /**
- * Return a map of all messages of the given severity. The key of the map
- * is the IValidator, the value of the IValidator is the List of IMessage
- * instances of the given severity.
- */
- public Map getMessages(int messageTypes) {
- Map messages = new HashMap();
-
- Iterator iterator = _validationMessages.values().iterator();
- while(iterator.hasNext()) {
- ValidatorMessages mssg = (ValidatorMessages) iterator.next();
-
- messages.put(mssg.getValidator().getClass().getName(), mssg.getMessages(messageTypes));
- }
- return messages;
- }
-
- /**
- * This method returns the ValidationMessage owned by the identified validator,
- * if one exists. If one doesn't exist, it is created & registered, and then
- * returned.
- */
- public ValidatorMessages getMessages(IValidator validator) {
- if (validator == null) {
- return null;
- }
-
- ValidatorMessages message = (ValidatorMessages) _validationMessages.get(validator.getClass().getName());
- if (message == null) {
- // if it doesn't exist, create it.
- message = new ValidatorMessages(validator);
- _validationMessages.put(validator.getClass().getName(), message);
- }
- return message;
- }
-
- /**
- * Remove all messages owned by the identified validator.
- */
- public void removeAllMessages(IValidator validator) {
- if (validator == null) {
- return;
- }
-
- _validationMessages.remove(validator.getClass().getName());
- }
-
- /**
- * Remove all messages, owned by the identified validator, reported
- * against the given target object.
- */
- public void removeAllMessages(IValidator validator, Object object) {
- if (validator == null) {
- return;
- }
-
- ValidatorMessages message = getMessages(validator);
- if (message != null) {
- message.removeAllMessages(object);
- }
- }
-
- /**
- * To support removal of a subset of validation messages, an IValidator
- * may assign group names to IMessages. An IMessage subset will be identified
- * by the name of its group. Default (null) means no group. This method will
- * remove only the IMessage's that are in the group identified by groupName.
- */
- public void removeMessageSubset(IValidator validator, Object object, String groupName) {
- if (validator == null) {
- return;
- }
-
- ValidatorMessages message = getMessages(validator);
- if (message != null) {
- message.removeAllMessages(object);
- }
- }
-
- /**
- * Return the IMessage as a String suitable for displaying to the user.
- */
- public static String formatMessage(IValidator validator, IMessage message) {
- if (message == null) {
- return ""; //$NON-NLS-1$
- }
-
- int severity = message.getSeverity();
- Object object = message.getTargetObject();
- StringBuffer formattedMessage = new StringBuffer();
- switch (severity) {
- case (IMessage.HIGH_SEVERITY) :
- {
- formattedMessage.append("Error: "); //$NON-NLS-1$
- break;
- }
-
- case (IMessage.LOW_SEVERITY) :
- {
- formattedMessage.append("Information: "); //$NON-NLS-1$
- break;
- }
-
- case (IMessage.NORMAL_SEVERITY) :
- default :
- {
- formattedMessage.append("Warning: "); //$NON-NLS-1$
- break;
- }
- }
-
- formattedMessage.append(message.getText());
-
- if (object != null) {
- String fileName = FilesystemManager.getManager().getHelper(validator).getFileName(message);
- int lineNumber = message.getLineNumber();
-
- if((fileName != null) || (lineNumber != IMessage.LINENO_UNSET)) {
- formattedMessage.append("["); //$NON-NLS-1$
- if(fileName != null) {
- formattedMessage.append(fileName);
- }
- if(lineNumber != IMessage.LINENO_UNSET) {
- formattedMessage.append(" line number: "); //$NON-NLS-1$
- formattedMessage.append(String.valueOf(lineNumber));
- }
- formattedMessage.append("] "); //$NON-NLS-1$
- }
- }
-
- return formattedMessage.toString();
- }
-
- /**
- * This Comparator is used to sort messages first by file name, then by line number.
- */
- public Comparator getMessageComparator(final IFilesystemHelper helper) {
- if(_comparator == null) {
- _comparator = new Comparator() {
- protected int compare(String a, String b) {
- if((a == null) && (b == null)) {
- return 0;
- }
- else if(a == null) {
- return -1;
- }
- else if(b == null) {
- return 1;
- }
-
- return a.compareTo(b);
- }
-
- protected int compare(int a, int b) {
- if((a == IMessage.LINENO_UNSET) && (b == IMessage.LINENO_UNSET)) {
- return 0;
- }
- else if(a == IMessage.LINENO_UNSET) {
- return -1;
- }
- else if(b == IMessage.LINENO_UNSET) {
- return 1;
- }
-
- return (a - b);
- }
-
- public int compare(Object a, Object b) {
- if((a == null) && (b == null)) {
- return 0;
- }
- else if(a == null) {
- return -1;
- }
- else if(b == null) {
- return 1;
- }
-
- IMessage aMssg = (IMessage)a;
- IMessage bMssg = (IMessage)b;
-
- // Sort by file name, then line number. Unset line numbers go to the start of the list.
- String aFileName = helper.getFileName(aMssg);
- String bFileName = helper.getFileName(bMssg);
- int result = compare(aFileName, bFileName);
- if(result != 0) {
- return result;
- }
-
- int aLineNumber = aMssg.getLineNumber();
- int bLineNumber = bMssg.getLineNumber();
- return compare(aLineNumber, bLineNumber);
- }
- };
- }
- return _comparator;
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/ValidatorMessages.java b/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/ValidatorMessages.java
deleted file mode 100644
index f316df09..00000000
--- a/tests/org.eclipse.jst.validation.sample/filesystemFWK/org/eclipse/jst/validation/sample/filesystem/ValidatorMessages.java
+++ /dev/null
@@ -1,171 +0,0 @@
-package org.eclipse.jst.validation.sample.filesystem;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This class manages messages for one validator. Each validator
- * can store three types of messages: error (SeverityEnum.HIGH_SEVERITY),
- * warning (SeverityEnum.NORMAL_SEVERITY), and info (SeverityEnum.LOW_SEVERITY).
- * Each message is associated with an Object (for incremental validation).
- * If a message does not apply to a particular Object, the default Object
- * is used.
- *
- * Each Object is associated with either 0, 1, or >1 messages.
- */
-public class ValidatorMessages {
- private Map _messages = null;
- private IValidator _validator = null;
- protected static final Object DEFAULT_OBJECT = new Object();
-
- public ValidatorMessages(IValidator validator) {
- _messages = new HashMap();
- _validator = validator;
- }
-
- /**
- * Return the validator that owns these messages.
- */
- public IValidator getValidator() {
- return _validator;
- }
-
- /**
- * Add an IMessage to the default group.
- */
- public void addValidationMessage(IMessage message) {
- addValidationMessage(message, null);
- }
-
- /**
- * Add an IMessage to the named group.
- */
- public void addValidationMessage(IMessage message, String groupName) {
- if (message == null) {
- return;
- }
-
- if (message.getTargetObject() == null) {
- // If object is null, the error message does not apply to a particular object.
- //
- // This value might be used if, for example, the validator experiences an internal, unrecoverable error.
- // You need to let the user know that validation terminated abnormally, but a list
- // of the validation which proceeded normally can help to narrow down what part of the
- // code caused a problem.
- //
- // Or it could be something generic, e.g. it applies to a .jar file, instead of a file in the .jar.
- message.setTargetObject(getDefaultObject());
- }
-
- if(groupName != null) {
- message.setGroupName(groupName);
- }
-
- List list = (List) _messages.get(message.getTargetObject());
- if (list == null) {
- list = new ArrayList();
- }
- list.add(message);
- _messages.put(message.getTargetObject(), list);
- }
-
- /**
- * If the IMessage does not have a target object, the object
- * returned by this method is used as the key in the Map.
- */
- public static Object getDefaultObject() {
- return DEFAULT_OBJECT;
- }
-
- /**
- * Return all messages whose severity matches the messageTypes severity.
- */
- public List getMessages(int messageTypes) {
- List messages = new ArrayList();
-
- Iterator iterator = _messages.values().iterator();
- while (iterator.hasNext()) {
- List list = (List) iterator.next();
-
- Object[] listContents = list.toArray();
- for (int i = 0; i < listContents.length; i++) {
- IMessage message = (IMessage) listContents[i];
-
- if ((messageTypes & message.getSeverity()) != 0) {
- messages.add(message);
- }
- }
- }
- return messages;
- }
-
- /**
- * Remove all messages that apply to the given object. If object is
- * null, the messages owned by the default object are removed.
- */
- public void removeAllMessages(Object object) {
- if (object == null) {
- object = getDefaultObject();
- }
-
- _messages.remove(object);
- }
-
- /**
- * Remove all messages that apply to the given object which are in
- * the named group. If Object is null, the default object is used.
- */
- public void removeMessageSubset(Object object, String groupName) {
- if (groupName == null) {
- removeAllMessages(object);
- return;
- }
-
- if (object == null) {
- object = getDefaultObject();
- }
-
- List list = (List) _messages.get(object);
- if (list == null) {
- return;
- }
-
- if (list.size() == 0) {
- return;
- }
-
- Iterator iterator = list.iterator();
- while (iterator.hasNext()) {
- IMessage msg = (IMessage) iterator.next();
- String msgGroupName = msg.getGroupName();
- if (groupName.equals(msgGroupName)) {
- list.remove(msg);
- }
- }
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/plugin.xml b/tests/org.eclipse.jst.validation.sample/plugin.xml
deleted file mode 100644
index 8f278e0b..00000000
--- a/tests/org.eclipse.jst.validation.sample/plugin.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.jst.validation.sample"
- name="Properties Validator"
- version="1.0.0"
- class="org.eclipse.jst.validation.sample.workbenchimpl.PropertiesValidatorPlugin">
-
- <runtime>
- <library name="runtime/propertiesValidator.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.wst.validation"/>
- <import plugin="org.eclipse.help"/>
- <import plugin="org.eclipse.wst.common.frameworks"/>
- <import plugin="org.eclipse.core.runtime"/>
- </requires>
-
-
-<!--=======================================-->
-<!-- Properties Validator Contributions -->
-<!--=======================================-->
- <extension
- id="PropertiesValidator"
- name="Properties Validator"
- point="org.eclipse.wst.validation.validator">
- <validator>
- <projectNature
- id="org.eclipse.jdt.core.javanature">
- </projectNature>
- <filter
- objectClass="org.eclipse.core.resources.IFile"
- nameFilter="*.properties"
- action="add, change">
- </filter>
- <run
- enabled="false"
- async="false"
- class="org.eclipse.jst.validation.sample.PropertiesValidator">
- </run>
- <helper
- class="org.eclipse.jst.validation.sample.workbenchimpl.PropertiesHelper">
- </helper>
- </validator>
- </extension>
-<!--=======================================-->
-<!-- Validation Documentation -->
-<!--=======================================-->
-<!-- -->
-<!-- Validator Developer's Guide -->
-<!-- -->
-<!--
- <extension
- point="org.eclipse.help.toc">
- <toc
- file="doc/developerGuide/toc.xml"
- primary="true">
- </toc>
- </extension>
--->
-<!-- -->
-<!-- Validation Guide -->
-<!-- -->
-<!--
- <extension
- point="org.eclipse.help.toc">
- <toc
- file="doc/guide/toc.xml"
- primary="true">
- </toc>
- </extension>
--->
-
-</plugin>
diff --git a/tests/org.eclipse.jst.validation.sample/prop.bat b/tests/org.eclipse.jst.validation.sample/prop.bat
deleted file mode 100644
index 80bf9407..00000000
--- a/tests/org.eclipse.jst.validation.sample/prop.bat
+++ /dev/null
@@ -1,45 +0,0 @@
-@echo off
-REM Licensed Material - Property of IBM
-REM (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
-REM US Government Users Restricted Rights - Use, duplication or disclosure
-REM restricted by GSA ADP Schedule Contract with IBM Corp.
-REM
-REM DISCLAIMER OF WARRANTIES.
-REM The following [enclosed] code is sample code created by IBM
-REM Corporation. This sample code is not part of any standard or IBM
-REM product and is provided to you solely for the purpose of assisting
-REM you in the development of your applications. The code is provided
-REM "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
-REM NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-REM FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
-REM THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
-REM for any damages arising out of your use of the sample code, even
-REM if it has been advised of the possibility of such damages.
-REM
-REM This batch file fires off the property file parse or comparison.
-REM
-setlocal
-
-if "%JAVA_HOME%" EQU "" goto NO_JAVA
-
-set CLASSPATH=%CLASSPATH%;..\com.ibm.etools.validation.core_5.1.0\runtime\common.jar
-set CLASSPATH=%CLASSPATH%;.\runtime\propertiesValidator.jar
-if "%1" == "" goto syntax
-
-%JAVA_HOME%\bin\java com.ibm.etools.parser.Main %1 %2 %3
-goto :end
-
-:NO_JAVA
-echo.
-echo The JAVA_HOME environment variable must be set to the JRE directory.
-echo e.g., set JAVA_HOME=C:\JRE
-echo where JRE has a subdirectory named "bin"
-echo.
-goto :end
-
-:syntax
-%JAVA_HOME%\bin\java com.ibm.etools.parser.Main
-
-:end
-endlocal
-@echo on \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValFS/org/eclipse/jst/validation/sample/filesystemimpl/FilesystemPropertiesHelper.java b/tests/org.eclipse.jst.validation.sample/propertiesValFS/org/eclipse/jst/validation/sample/filesystemimpl/FilesystemPropertiesHelper.java
deleted file mode 100644
index 5ed9040a..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValFS/org/eclipse/jst/validation/sample/filesystemimpl/FilesystemPropertiesHelper.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package org.eclipse.jst.validation.sample.filesystemimpl;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.LineNumberReader;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jst.validation.sample.PModelEnum;
-import org.eclipse.jst.validation.sample.filesystem.IFilesystemHelper;
-import org.eclipse.jst.validation.sample.parser.APropertyFile;
-import org.eclipse.jst.validation.sample.parser.PropertyLine;
-import org.eclipse.wst.validation.internal.core.FileDelta;
-import org.eclipse.wst.validation.internal.core.IFileDelta;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * This class is the IValidationContext implementation, used by the PropertiesValidator,
- * when the validator is run in the filesystem validation framework.
- */
-public class FilesystemPropertiesHelper implements IFilesystemHelper {
- public FilesystemPropertiesHelper() {
- super();
- }
-
- /**
- * @see com.ibm.etools.validation.core.IValidationContext#loadModel(String)
- */
- public Object loadModel(String symbolicName) {
- return (Object) loadModel(symbolicName, null);
- }
-
- /**
- * @see com.ibm.etools.validation.core.IValidationContext#loadModel(String, Object[])
- */
- public Object loadModel(String symbolicName, Object[] parm) {
- if ((symbolicName == null) || (symbolicName.equals(""))) { //$NON-NLS-1$
- return null;
- }
-
- if (symbolicName.equals(PModelEnum.LINEINPUTREADER) && (parm != null) && (parm.length == 1) && (parm[0] instanceof String)) {
- return loadLineNumberReader((String) parm[0]);
- }
- else if (symbolicName.equals(PModelEnum.RELEASE_LINEINPUTREADER) && (parm != null) && (parm.length == 1) && (parm[0] instanceof LineNumberReader)) {
- return releaseLineNumberReader((LineNumberReader) parm[0]);
- }
- else if (symbolicName.equals(PModelEnum.ALL_PROPERTIES_FILES)) {
- return loadAllPropertiesFiles();
- }
- else if(symbolicName.equals(PModelEnum.FILTER)) {
- // Because this environment does not copy resources into a "bin" directory,
- // the input is already filtered.
- return parm;
- }
- else {
- return null;
- }
- }
-
- /**
- * Given the file name of an existing .properties file, return
- * the LineNumberReader that will read the file.
- */
- protected Object loadLineNumberReader(String fileName) {
- File propertyFile = new File(fileName);
- if (!propertyFile.exists() || !propertyFile.isFile()) {
- return null;
- }
-
- FileReader input = null;
- try {
- input = new FileReader(propertyFile);
- }
- catch (FileNotFoundException e) {
- return null;
- }
-
- // Because we want to read in a line at a time from the file, convert the FileReader to a LineReader
- LineNumberReader lineInput = new LineNumberReader(input);
- return lineInput;
- }
-
- /**
- * This method doesn't load anything; it releases the resources allocated
- * by the loadLineNumberReader method. Its result will never be used, so always
- * return null.
- */
- protected Object releaseLineNumberReader(LineNumberReader reader) {
- if (reader == null) {
- return null;
- }
-
- try {
- reader.close();
- }
- catch (IOException e) {
- }
-
- return null;
- }
-
- /**
- * When the validator is told to perform a full validation, this
- * method returns an IFileDelta[], with one IFileDelta for every
- * .properties file in the current directory and its subdirectories.
- */
- protected Object loadAllPropertiesFiles() {
- String pwd = System.getProperty("user.dir"); //$NON-NLS-1$
- File pwdDir = new File(pwd);
- if (!pwdDir.exists()) {
- return null;
- }
-
- if (!pwdDir.isDirectory()) {
- return null;
- }
-
- Set tempSet = new HashSet();
- traverseDirectories(pwdDir, tempSet);
-
- IFileDelta[] result = new IFileDelta[tempSet.size()];
- Iterator iterator = tempSet.iterator();
- int count = 0;
- while(iterator.hasNext()) {
- File file = (File)iterator.next();
- result[count++] = new FileDelta(file.getAbsolutePath(), IFileDelta.CHANGED);
- }
- tempSet.clear();
- tempSet = null;
- iterator = null;
- return result;
- }
-
- /**
- * Traverse the directory, looking for .properties files, and if a
- * .properties file is found then add it to the Set.
- */
- protected void traverseDirectories(File directoryToSearch, Set result) {
- if (directoryToSearch == null) {
- return;
- }
-
- if (directoryToSearch.isDirectory()) {
- // Traverse into this directory's children.
- String[] children = directoryToSearch.list();
- for (int i = 0; i < children.length; i++) {
- File child = new File(directoryToSearch, children[i]);
- traverseDirectories(child, result);
- }
- }
- else if(directoryToSearch.isFile()) {
- String fileName = directoryToSearch.getName();
- if((fileName != null) && fileName.endsWith("properties")) { //$NON-NLS-1$
- result.add(directoryToSearch);
- }
- }
- }
-
- /**
- * Given an IMessage, return the file name of the .properties file that
- * the message was reported against.
- */
- public String getFileName(IMessage message) {
- Object object = message.getTargetObject();
- if(object instanceof PropertyLine) {
- PropertyLine line = (PropertyLine)object;
- APropertyFile pFile = line.getFile();
- return pFile.getQualifiedFileName(); // a ValidationPropertyFile returns the file name as its qualified name
- }
- else if(object instanceof APropertyFile) {
- APropertyFile pFile = (APropertyFile)object;
- return pFile.getQualifiedFileName(); // a ValidationPropertyFile returns the file name as its qualified name
- }
- return ""; //$NON-NLS-1$
- }
-
- public String[] getURIs() {
- // TODO Auto-generated method stub
- return null;
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PluginPropertyFile.java b/tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PluginPropertyFile.java
deleted file mode 100644
index d140f734..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PluginPropertyFile.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * (c) Copyright 2001 MyCorporation.
- * All Rights Reserved.
- */
-package org.eclipse.jst.validation.sample.workbenchimpl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Locale;
-import java.util.logging.Level;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.validation.sample.parser.APropertyFile;
-import org.eclipse.jst.validation.sample.parser.MessageMetaData;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * A PluginPropertyFile represents a resource bundle that is exported by a plugin.
- */
-public class PluginPropertyFile extends APropertyFile {
- private String _bundleName = null;
- private String _pluginId = null;
- private String _langVariant = null; // e.g., en_US vs en
- private ClassLoader _classLoader = null; // the ClassLoader used to load the bundle
-
-
- /**
- * Both the pluginId and the bundleName must not be null, must
- * refer to an existing plugin, and must refer to an existing bundle
- * exported by that plugin.
- */
- public PluginPropertyFile(String pluginId, String bundleName) {
- _pluginId = pluginId;
- _bundleName = bundleName;
-
- ClassLoader cl = null;
- InputStream inS = null;
- Plugin plugin = getPlugin(pluginId);
- if(bundleName.equals("plugin")) { //$NON-NLS-1$
- // Try loading it from the Plugin parent (a "plugin.properties")
- cl = getPluginPropertiesClassLoader(plugin);
- }
- else {
- cl = plugin.getDescriptor().getPluginClassLoader();
- }
- inS = getInputStream(cl, bundleName);
-
- InputStreamReader inR = new InputStreamReader(inS);
- LineNumberReader lineR = new LineNumberReader(inR);
- parseFile(lineR); // populate this property file
- try {
- lineR.close();
- inR.close();
- }
- catch(IOException exc) {
- Logger logger = PropertiesValidatorPlugin.getPlugin().getMsgLogger();;
- if(logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
-
- try {
- if(inS != null) {
- inS.close();
- }
- }
- catch(IOException exc) {
- Logger logger = PropertiesValidatorPlugin.getPlugin().getMsgLogger();
- if(logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
-
- _classLoader = cl; // store the ClassLoader which was used to load the bundle
- }
-
- private InputStream getInputStream(ClassLoader cl, String bundleName) {
- Locale l = Locale.getDefault();
- String language = l.getLanguage();
- String country = l.getCountry();
- String variant = l.getVariant();
-
- String lang = null;
- String lang_country = null;
- String lang_country_variant = null;
- if((language != null) && !(language.equals(""))) { //$NON-NLS-1$
- lang = "_" + language; //$NON-NLS-1$
- }
-
- if((country != null) && !(country.equals(""))) { //$NON-NLS-1$
- lang_country = lang + "_" + country; //$NON-NLS-1$
- }
-
- if((variant != null) && !(variant.equals(""))) { //$NON-NLS-1$
- lang_country_variant = lang_country + "_" + variant; //$NON-NLS-1$
- }
-
- InputStream inS = null;
- if(lang_country_variant != null) {
- inS = getResourceAsStream(cl, bundleName, lang_country_variant);
- if(inS != null) {
- _langVariant = lang_country_variant;
- return inS;
- }
- }
-
- if(lang_country != null) {
- inS = getResourceAsStream(cl, bundleName, lang_country);
- if(inS != null) {
- _langVariant = lang_country;
- return inS;
- }
- }
-
- if(lang != null) {
- inS = getResourceAsStream(cl, bundleName, lang);
- if(inS != null) {
- _langVariant = lang;
- return inS;
- }
- }
-
- if(Locale.getDefault().equals(Locale.US)) {
- // Running the TVT plugin in en_US mode, so return the default .properties file.
- inS = getResourceAsStream(cl, bundleName, ""); //$NON-NLS-1$
- if(inS != null) {
- _langVariant = ""; //$NON-NLS-1$
- return inS;
- }
- }
-
- return null;
- }
-
- private final static InputStream getResourceAsStream(final ClassLoader cl, final String bundleName, final String language) {
- String resName = bundleName.replace('.', '/') + language + ".properties"; //$NON-NLS-1$
- return cl.getResourceAsStream(resName);
- }
-
- private static ClassLoader getPluginPropertiesClassLoader(Plugin p) {
- // Copied from PluginDescriptor.java's getResourceBundle method.
- URL[] cp = ((URLClassLoader)p.getDescriptor().getPluginClassLoader()).getURLs();
- URL[] newcp = new URL[cp.length+1];
- for (int i=0; i<cp.length; i++) newcp[i+1] = cp[i];
- try {
- newcp[0] = Platform.resolve(p.getDescriptor().getInstallURL()); // always try to resolve URLs used in loaders
- } catch(IOException e) {
- newcp[0] = p.getDescriptor().getInstallURL();;
- }
- ClassLoader resourceLoader = new URLClassLoader(newcp, null);
- return resourceLoader;
- }
-
- private static Plugin getPlugin(String pluginId) {
- if (pluginId == null) {
- return null;
- }
-
- IPluginRegistry registry = Platform.getPluginRegistry();
- IPluginDescriptor pluginDesc = registry.getPluginDescriptor(pluginId);
- if(pluginDesc == null) {
- return null;
- }
-
- try {
- return pluginDesc.getPlugin();
- }
- catch(CoreException exc) {
- Logger logger = PropertiesValidatorPlugin.getPlugin().getMsgLogger();;
- if(logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- return null;
- }
-
- }
-
-
- /*
- * @see APropertyFile#report(String)
- */
- public void report(String str) {
- addParseWarning(new MessageMetaData(str));
- }
-
- public void report(IMessage message) {
- MessageMetaData mmd = new MessageMetaData(message.getBundleName(), message.getSeverity(), message.getId(), message.getParams(), message.getTargetObject(), message.getLineNumber(), message.getOffset(), message.getLength());
- addParseWarning(mmd);
- }
-
- public void report(MessageMetaData mmd) {
- addParseWarning(mmd);
- }
-
- public void addParseWarning(IMessage message) {
- MessageMetaData mmd = new MessageMetaData(message.getBundleName(), message.getSeverity(), message.getId(), message.getParams(), message.getTargetObject(), message.getLineNumber(), message.getOffset(), message.getLength());
- addParseWarning(mmd);
- }
-
- public String getPluginId() {
- return _pluginId;
- }
-
- public String getBundleName() {
- return _bundleName;
- }
-
- public String getQualifiedFileName() {
- StringBuffer buffer = new StringBuffer(getPluginId());
- buffer.append("::");
- buffer.append(getBundleName());
- buffer.append(_langVariant);
- return buffer.toString();
- }
-
- public String getLangVariant() {
- return _langVariant;
- }
-
- public ClassLoader getClassLoader() {
- return _classLoader;
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PropertiesHelper.java b/tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PropertiesHelper.java
deleted file mode 100644
index 2f970728..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PropertiesHelper.java
+++ /dev/null
@@ -1,234 +0,0 @@
-package org.eclipse.jst.validation.sample.workbenchimpl;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.validation.sample.PModelEnum;
-import org.eclipse.jst.validation.sample.parser.APropertyFile;
-import org.eclipse.jst.validation.sample.parser.PropertyLine;
-import org.eclipse.wst.validation.internal.core.IFileDelta;
-import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
-import org.eclipse.wst.validation.internal.operations.WorkbenchFileDelta;
-
-/**
- * This class implements the WebSphere Studio IValidationContext for the
- * Properties Validator.
- */
-public class PropertiesHelper extends WorkbenchContext {
- public PropertiesHelper() {
- super();
-
- registerModel(PModelEnum.LINEINPUTREADER, "loadLineNumberReader", new Class[]{java.lang.String.class}); //$NON-NLS-1$
- registerModel(PModelEnum.RELEASE_LINEINPUTREADER, "releaseLineNumberReader", new Class[]{java.io.LineNumberReader.class}); //$NON-NLS-1$
- registerModel(PModelEnum.ALL_PROPERTIES_FILES, "loadAllPropertiesFiles"); //$NON-NLS-1$
- registerModel(PModelEnum.MSGLOGGER, "getMsgLogger"); //$NON-NLS-1$
- registerModel(PModelEnum.FILTER, "filter", new Class[]{IFileDelta[].class}); //$NON-NLS-1$
- }
-
- /**
- * @see com.ibm.etools.validate.IWorkbenchContext#getTargetObjectName(Object)
- */
- public String getTargetObjectName(Object object) {
- return null;
- }
-
- /**
- * @see com.ibm.etools.validate.IWorkbenchContext#getResource(Object)
- */
- public IResource getResource(Object object) {
- IFile file = null;
- if(object instanceof PropertyLine) {
- PropertyLine line = (PropertyLine)object;
- APropertyFile pFile = line.getFile();
- String fileName = pFile.getQualifiedFileName(); // a ValidationPropertyFile returns the file name as its qualified name
- file = getFile(fileName);
- }
- else if(object instanceof APropertyFile) {
- APropertyFile pFile = (APropertyFile)object;
- String fileName = pFile.getQualifiedFileName(); // a ValidationPropertyFile returns the file name as its qualified name
- file = getFile(fileName);
- }
-
- if((file == null) || (!file.exists())) {
- return super.getResource(object);
- }
- return file;
- }
-
- /**
- * When a full validation is performed, this method returns an
- * IFileDelta[] containing one IFileDelta for each .properties
- * file in the IProject.
- */
- public IFileDelta[] loadAllPropertiesFiles() {
- IProject project = getProject();
-
- final Set files = new HashSet();
- IResourceVisitor visitor = new IResourceVisitor() {
- public boolean visit(IResource res) throws CoreException {
- if(!res.isAccessible()) {
- return false; // if the resource isn't accessible then neither are its children
- }
-
- if(isSrcFile(res)) { //$NON-NLS-1$
- WorkbenchFileDelta newFileDelta = new WorkbenchFileDelta(res.getFullPath().toString(), IFileDelta.CHANGED, res);
- files.add(newFileDelta);
- }
-
- return true; // visit the resource's children as well
- }
- };
-
- try {
- project.accept(visitor, IResource.DEPTH_INFINITE, true); // true means include phantom resources
- }
- catch(CoreException e) {
- Logger logger = getMsgLogger();
- if(logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(e);
- }
- }
-
- IFileDelta[] result = new IFileDelta[files.size()];
- files.toArray(result);
- return result;
- }
-
- /**
- * Return the IFile handle for the file identified by fileName.
- * null will be returned if the file does not exist.
- */
- public IFile getFile(String fileName) {
- IFile file = (IFile)ResourcesPlugin.getWorkspace().getRoot().findMember(fileName);
- return file;
- }
-
- /**
- * Given the file name of an existing .properties file, return
- * the LineNumberReader that will read the file.
- */
- public LineNumberReader loadLineNumberReader(String fileName) {
- try {
- IFile file = getFile(fileName);
- InputStream in = file.getContents();
- InputStreamReader reader = new InputStreamReader(in);
-
- // Because we want to read in a line at a time from the file, convert the InputStreamReader to a LineReader
- LineNumberReader lineInput = new LineNumberReader(reader);
- return lineInput;
- }
- catch(CoreException exc) {
- Logger logger = getMsgLogger();
- if(logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(exc);
- }
- return null;
- }
- }
-
- /**
- * This method doesn't load anything; it releases the resources allocated
- * by the loadLineNumberReader method. Its result will never be used, so always
- * return null.
- */
- public LineNumberReader releaseLineNumberReader(LineNumberReader reader) {
- if(reader == null) {
- return null;
- }
-
- try {
- reader.close();
- }
- catch (IOException exc) {
- Logger logger = getMsgLogger();
- if(logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(exc);
- }
- }
-
- return null;
- }
-
- /**
- * The MsgLogger from this method can be used to log exceptions.
- * This method will never return null.
- */
- public Logger getMsgLogger() {
- return PropertiesValidatorPlugin.getPlugin().getMsgLogger();
- }
-
- // package visibility for performance reasons (synthetic accessor method)
- boolean isSrcFile(IResource res) {
- // Want to filter out the copies in the "bin" directory.
- if(res == null) {
- return false;
- }
-
- if(!(res instanceof IFile)) {
- return false;
- }
-
- if(!res.getFileExtension().equals("properties")) { //$NON-NLS-1$
- return false;
- }
-
- if(res.isDerived()) {
- // Created by eclipse
- return false;
- }
-
- return true;
- }
-
- public IFileDelta[] filter(IFileDelta[] changedFiles) {
- IFileDelta[] temp = new IFileDelta[changedFiles.length];
- int count = 0;
- for(int i=0; i<changedFiles.length; i++) {
- IFileDelta fd = changedFiles[i];
- IResource resource = ((WorkbenchFileDelta)fd).getResource();
- if(isSrcFile(resource)) {
- temp[count++] = fd;
- }
- }
-
- if(count == changedFiles.length) {
- return changedFiles;
- }
-
- IFileDelta[] result = new IFileDelta[count];
- System.arraycopy(temp, 0, result, 0, count);
- return result;
- }
-
-}
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PropertiesValidatorPlugin.java b/tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PropertiesValidatorPlugin.java
deleted file mode 100644
index 5f326d2a..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValWB/org/eclipse/jst/validation/sample/workbenchimpl/PropertiesValidatorPlugin.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.eclipse.jst.validation.sample.workbenchimpl;
-/*
- * Licensed Material - Property of IBM (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved. US
- * Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP
- * Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES. The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM product and is provided to you
- * solely for the purpose of assisting you in the development of your applications. The code is
- * provided "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE
- * FUNCTION OR PERFORMANCE OF THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable for
- * any damages arising out of your use of the sample code, even if it has been advised of the
- * possibility of such damages.
- *
- */
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.common.frameworks.internal.WTPPlugin;
-/**
- * This class is the Plugin class identified by the com.ibm.etools.validation.core.prop's plugin.xml
- * file (i.e., the &lt;plugin <br><br>
- * class=&quot;class="com.ibm.etools.validation.core.properties.workbenchimpl.PropertiesValidatorPlugin"&quot&gt;
- */
-public class PropertiesValidatorPlugin extends WTPPlugin {
- private static PropertiesValidatorPlugin _inst = null;
- public static final String PLUGIN_ID = "org.eclipse.jst.validation.sample"; //$NON-NLS-1$
- private static Logger _logger;
- public PropertiesValidatorPlugin() {
- super();
- if (_inst == null) {
- _inst = this;
- }
- }
- public static PropertiesValidatorPlugin getPlugin() {
- return _inst;
- }
- public Logger getMsgLogger() {
- if (_logger == null)
- _logger = Logger.getLogger();
- return _logger;
- }
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.wtp.common.WTPPlugin#getPluginID()
- */
- public String getPluginID() {
- return PLUGIN_ID;
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/PModelEnum.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/PModelEnum.java
deleted file mode 100644
index 5616eede..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/PModelEnum.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.eclipse.jst.validation.sample;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-/**
- * This class contains the constants that uniquely identify each
- * model that the Properties Validator's helper must load. All of
- * these models must be supported by the IValidationContext implementation
- * or the helper cannot be used to support the Properties Validator.
- */
-public interface PModelEnum {
- public static final String LINEINPUTREADER = "get a LineInputReader for a .properties file"; //$NON-NLS-1$
- public static final String RELEASE_LINEINPUTREADER = "relase (close) the LineInputReader"; //$NON-NLS-1$
- public static final String ALL_PROPERTIES_FILES = "return an IFileDelta[] of all of the .properties files in the project"; //$NON-NLS-1$
- public static final String MSGLOGGER = "get the MsgLogger needed to log messages. This MsgLogger must never be null."; //$NON-NLS-1$
- public static final String FILTER = "get only the .properties files that are in src dir; filter out the .properties files that are in bin dir (i.e., don't validate the same file twice"; //$NON-NLS-1$
-
-}
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/PropertiesValidator.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/PropertiesValidator.java
deleted file mode 100644
index 2ebfb288..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/PropertiesValidator.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.eclipse.jst.validation.sample;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.io.LineNumberReader;
-import java.util.logging.Level;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.validation.sample.parser.IValidationConstants;
-import org.eclipse.wst.validation.internal.core.IFileDelta;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This class checks that the .properties files has no syntax or
- * or problems. This validator can run in any validation framework
- * implementation.
- */
-public class PropertiesValidator implements IValidator {
-
- /*
- * @see IValidator#cleanup(IReporter)
- */
- public void cleanup(IReporter reporter) {
- // This validator doesn't cache anything so it doesn't need to clean anything up.
- }
-
- /*
- * @see IValidator#validate(IValidationContext, IReporter, IFileDelta[])
- */
- public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
- IFileDelta[] fileURIs = null;
- if((fileURIs == null) || (fileURIs.length == 0)) {
- fileURIs = (IFileDelta[])helper.loadModel(PModelEnum.ALL_PROPERTIES_FILES);
- }
- else {
- // Filter out the files that are in the "bin" directory.
- fileURIs = (IFileDelta[])helper.loadModel(PModelEnum.FILTER, new Object[]{helper.getURIs()});
- }
- if(fileURIs == null) {
- // Problem loading the files.
- Logger logger = (Logger)helper.loadModel(PModelEnum.MSGLOGGER);
- if(logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE,"changedFiles == null; terminating validation"); //$NON-NLS-1$
- return;
- }
- }
- String[] uris = helper.getURIs();
- for (int i = 0; i < uris.length; i++) {
- // Load the reader for the file
- LineNumberReader reader = null;
- try {
- reader = (LineNumberReader)helper.loadModel(PModelEnum.LINEINPUTREADER, new Object[]{uris[i]});
- if(reader == null) {
- // Either:
- // 1. The file doesn't exist or
- // 2. The file isn't a .properties file or
- // 3. The file can't be read
- IMessage message = new Message(IValidationConstants.BUNDLENAME, IMessage.NORMAL_SEVERITY, IValidationConstants.ABCD0090, new String[]{uris[i]});
- reporter.addMessage(this, message);
- continue;
- }
-
- // If we can get a reader then we can get a PropertyFile
- ValidatorPropertyFile propFile = new ValidatorPropertyFile(reader, uris[i], reporter, this);
- propFile.printSyntaxWarnings();
- propFile.printDuplicateMessageId();
- propFile.printDuplicateMessagePrefix();
- }
- finally {
- // Don't catch Throwable, MessageLimitException, OperationCanceledException, or ValidationException.
- // Let them travel up to the framework and the framework will log or cleanup as appropriate.
- if(reader != null) {
- // Release the reader for the file.
- // Because different validation frameworks may allocate LineNumberReaders
- // differently, don't close the reader in the validator. Instead, pass the
- // reader back to the helper, and regardless of whether the reader should
- // be closed or reused, the helper knows the right thing to do for its
- // framework environment.
- helper.loadModel(PModelEnum.RELEASE_LINEINPUTREADER, new Object[]{reader});
- }
- }
- }
- }
-
-}
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/ValidatorPropertyFile.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/ValidatorPropertyFile.java
deleted file mode 100644
index d1dd36ea..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/ValidatorPropertyFile.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.eclipse.jst.validation.sample;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.io.LineNumberReader;
-
-import org.eclipse.jst.validation.sample.parser.APropertyFile;
-import org.eclipse.jst.validation.sample.parser.MessageMetaData;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This class represents an APropertyFile that is instantiated by a validator.
- */
-public class ValidatorPropertyFile extends APropertyFile {
- private IReporter _reporter = null;
- private IValidator _validator = null;
- private String _fileName = null; // if this is created from a reader instead of a file name, we only have the bundle name
-
- public ValidatorPropertyFile(LineNumberReader reader, String fileName, IReporter reporter, IValidator validator) {
- super();
- setFileName(fileName);
- _reporter = reporter;
- _validator = validator;
- parseFile(reader);
- }
-
- public void setFileName(String bundleName) {
- _fileName = bundleName;
- }
-
- /**
- * Return the name of the .properties file (or bundle).
- */
- public String getFileName() {
- return _fileName;
- }
-
- /*
- * @see APropertyFile#report(String)
- */
- public void report(String str) {
- // Never print titles like "DUPLICATE MESSAGE IDS". Print only the IMessage.
- }
-
- /*
- * @see APropertyFile#report(MessageMetaData)
- */
- public void report(MessageMetaData mmd) {
- IMessage message = new Message();
- message.setBundleName(mmd.getBundleName());
- message.setSeverity(getSeverity(mmd.getSeverity()));
- message.setId(mmd.getId());
- message.setParams(mmd.getParams());
- message.setTargetObject(mmd.getTargetObject());
- message.setLineNo(mmd.getLineNumber());
- message.setLength(mmd.getLength());
- message.setOffset(mmd.getOffset());
- message.setLength(mmd.getLength());
- _reporter.addMessage(getValidator(), message);
- }
-
- /**
- * Given the severity of the MessageMetaData, return the corresponding
- * severity of the validation framework.
- */
- private static int getSeverity(int mmdSeverity) {
- switch(mmdSeverity) {
- case(MessageMetaData.ERROR): {
- return IMessage.HIGH_SEVERITY;
- }
-
- case(MessageMetaData.INFO): {
- return IMessage.LOW_SEVERITY;
- }
-
- default: {
- return IMessage.NORMAL_SEVERITY;
- }
- }
- }
-
- /**
- * Return the IValidator instance that is checking this file.
- */
- public IValidator getValidator() {
- return _validator;
- }
-
- /**
- * Return the name of this file that identifies this file uniquely.
- */
- public String getQualifiedFileName() {
- return getFileName();
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/APropertyFile.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/APropertyFile.java
deleted file mode 100644
index 2dc8b9e3..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/APropertyFile.java
+++ /dev/null
@@ -1,728 +0,0 @@
-package org.eclipse.jst.validation.sample.parser;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.LineNumberReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * This class represents a .properties file; extensions of this class implement
- * environment-specific messages, such as how to report the known problems. This
- * class, and every class in the org.eclipse.jst.validation.sample.parser package, is independent
- * of the framework environment.
- */
-public abstract class APropertyFile {
- private static final String EQUALS = "="; //$NON-NLS-1$
-
- private List _propertyLines = null; // The List of PropertyLine instances.
- private List _parseWarnings = null; // The List of MessageMetaData warnings found when parsing the .properties file.
- private boolean _debug = false;
-
- /**
- * Return a name that identifies this file uniquely.
- */
- public abstract String getQualifiedFileName();
-
- /**
- * Tell the user that there is a problem - in WebSphere Studio, this
- * shows up as a row in the Task View; in the sample filesystem framework,
- * this appears as a message to System.out.
- */
- public abstract void report(String str);
-
- /**
- * Tell the user that there is a problem - in WebSphere Studio, this
- * shows up as a row in the Task View; in the sample filesystem framework,
- * this appears as a message to System.out.
- */
- public abstract void report(MessageMetaData mmd);
-
- protected APropertyFile() {
- _propertyLines = new ArrayList();
- _parseWarnings = new ArrayList();
- }
-
- /**
- * Add the List of MessageMetaData to the list of warning messages.
- */
- public void addParseWarnings(List list) {
- _parseWarnings.addAll(list);
- }
-
- /**
- * Add a single warning message to the list of parse warnings.
- */
- public void addParseWarning(MessageMetaData mmd) {
- _parseWarnings.add(mmd);
- }
-
- /**
- * Return the List of warning messages that report problems found
- * while parsing the .properties file.
- */
- public List getParseWarnings() {
- return _parseWarnings;
- }
-
-
- public String toString() {
- return getQualifiedFileName();
- }
-
- /**
- * Should debug information be printed when parsing?
- */
- public boolean debug() {
- return _debug;
- }
-
- protected void setDebug(boolean d) {
- _debug = d;
- }
-
- public boolean equals(Object o) {
- if(o == null) {
- return false;
- }
-
- if(!(o instanceof PropertyFile)) {
- return false;
- }
-
- PropertyFile file = (PropertyFile)o;
- return getQualifiedFileName().equals(file.getQualifiedFileName());
- }
-
- public int hashCode() {
- return getQualifiedFileName().hashCode();
- }
-
- /**
- * Return the number of messages in the file, including duplicates & blanks.
- */
- public int getNumProperties() {
- return _propertyLines.size();
- }
-
- /**
- * Excluding message ids and error ids, output the number of words in the
- * .properties file.
- */
- public int getNumWords() {
- // NOT a fast method....how to optimize?
- Iterator iterator = _propertyLines.iterator();
- int count = 0;
- while (iterator.hasNext()) {
- PropertyLine line = (PropertyLine) iterator.next();
- count += line.getNumWords();
- }
- return count;
- }
-
- /**
- * Return a count of the number of unique message prefixes in the file.
- * (A message prefix starts the message text, e.g., ABCD0000E.)
- */
- public int getNumUniquePrefixes() {
- Set uniqueIds = new HashSet();
- Iterator iterator = getPropertyLines().iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
- if(line.hasMessagePrefix()) {
- uniqueIds.add(line.getMessagePrefix());
- }
- }
- return uniqueIds.size();
- }
-
- /**
- * Return a count of the number of message prefixes used in the file.
- * Usually this is the same as the number of unique prefixes, but if
- * a .properties file has variations of a message (slightly different
- * wording for a different context), then the number of prefixes will
- * be larger than the number of unique prefixess.
- */
- public int getNumPrefixes() {
- int count = 0;
- Iterator iterator = getPropertyLines().iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
- if(line.hasMessagePrefix()) {
- count++;
- }
- }
- return count;
- }
-
- /**
- * Return a count of the number of messages that do not use prefixes in the file.
- */
- public int getNumWithoutPrefixes() {
- int count = 0;
- Iterator iterator = getPropertyLines().iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
- if(!line.hasMessagePrefix()) {
- count++;
- }
- }
- return count;
- }
-
- /**
- * Return a List of the PropertyLine instances contained in this file.
- */
- public List getPropertyLines() {
- return _propertyLines;
- }
-
- /**
- * Return the PropertyLine instance that is identified by the
- * given messageId.
- */
- public PropertyLine getPropertyLine(String messageId) {
- Collections.sort(_propertyLines, PropertyLineComparator.getMessageIdComparator());
- int index = Collections.binarySearch(_propertyLines, messageId, PropertyLineComparator.getMessageIdComparator());
- if(index < 0) {
- return null;
- }
-
- PropertyLine result = (PropertyLine)_propertyLines.get(index);
- return result;
- }
-
- /**
- * Parse the file to create a collection of uniquely identified
- * keys with their associated values. If there are any duplicate
- * keys, the last value is the one that is stored. Store the
- * value of the duplicate keys, and the line number on which
- * each instance of the key (and its value) are located.
- */
- protected void parseFile(File propertyFile) {
- FileReader input = null;
- LineNumberReader lineInput = null;
- try {
- input = new FileReader(propertyFile);
- }
- catch (FileNotFoundException e) {
- // We can ignore this exception because we have already checked in the constructor that the
- // file exists.
- }
-
- // Because we want to read in a line at a time from the file, convert the FileReader to a LineReader
- lineInput = new LineNumberReader(input);
-
- parseFile(lineInput);
-
- try {
- lineInput.close();
- }
- catch (IOException e) {
- }
- input = null;
- lineInput = null;
- }
-
- /**
- * Given a LineNumberReader on a .properties file, read the
- * file and note any problems that may need to be reported to
- * the user.
- */
- protected void parseFile(LineNumberReader lineInput) {
- _propertyLines.clear();
- _parseWarnings.clear();
-
- boolean isNewKey = true;
- String key = null;
- int lineNumber = 0;
- String value = null;
- int offset = 0; // each .properties line needs to know its offset so that columns in the line can be calculated.
- int messageOffset = 0; // the offset, relative to the start of the line, where the message prefix starts
- String line = null;
- while (true) {
- try {
- line = lineInput.readLine(); // calculate the offset in the finally block
- if (line == null)
- break;
- line = line.trim();
-
- // ignore blank lines
- if (line.equals("")) //$NON-NLS-1$
- continue;
-
- // strip off lines that begin with '#'
- if (line.startsWith("#")) //$NON-NLS-1$
- continue;
-
- // strip off lines that begin with '/'
- if (line.startsWith("/")) //$NON-NLS-1$
- continue;
-
- if (isNewKey) {
- // We know that the line is of the form
- //
- // KEYNAME = VALUE
- //
- if (line.indexOf(EQUALS) != -1) {
- // Make sure the line is not of the form " = Message" (i.e., missing the message id).
- if(line.indexOf(EQUALS) == 0) {
- throw new java.util.NoSuchElementException();
- }
-
- // The user may or may not put spaces between the key
- // name, the equals sign, and the value. This gives us four cases:
- // 1. keyname=value
- // 2. keyname= value
- // 3. keyname =value
- // 4. keyname = value
- // The way to deal with all four cases is to find the index of the
- // '=' sign, and the value is the remainder of the line after the
- // sign.
- //
- key = line.substring(0, line.indexOf(EQUALS));
- key = key.trim();
-
- // add 1 to the EQUALS index because '=' is one character long
- value = line.substring(line.indexOf(EQUALS) + 1);
- value = value.trim();
-
- messageOffset = line.indexOf(value);
-
- lineNumber = lineInput.getLineNumber();
- }
- else {
- // error in line syntax
- throw new java.util.NoSuchElementException();
- }
- }
- else {
- // need to read in the multiple lines to get the multi-line value
- value += line;
- }
-
- if (value.endsWith("\\")) { //$NON-NLS-1$
- // multi-line value
- // read in every line from the file until you reach an end-of-line
- isNewKey = false;
- }
- else {
- // end of multi-line value, or end of single-line value
- isNewKey = true;
- PropertyLine pline = new PropertyLine(this, offset, messageOffset, key, value, lineNumber);
- _propertyLines.add(pline);
- }
- }
- catch (IOException e) {
- // When there is an IOException, we have reached the end of the file.
- break;
- }
- catch (NullPointerException e) {
- // If a line is not of the form KEYNAME = VALUE, there might be a null exception.
- // Just continue onto the next line in the file
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.ERROR, IValidationConstants.ABCD0080, null, this, lineInput.getLineNumber());
- report(mmd);
- break;
- }
- catch (java.util.NoSuchElementException e) {
- // If a line is not of the form KEYNAME = VALUE, there might be a NoSuchElement exception.
- // Just continue onto the next line in the file
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.ERROR, IValidationConstants.ABCD0080, null, this, lineInput.getLineNumber());
- report(mmd);
- }
- finally {
- if(line != null) {
- offset += line.length() + 2; // hack.
- // Can't get offset from BufferedReader, and since the reader strips
- // the '\n' and '\r' from the line before the line is returned, the
- // true length of the line can't be ascertained. This hack will not
- // work on Unix because unix's EOL char is different than Windows.
- //
- // When there's time, need to find an alternative to LineNumberReader.
- }
- }
- }
- }
-
- /**
- * Print a list of all message prefixes, e.g., ABCD0000E, that are used
- * in the .properties file.
- */
- public void printAllMessagePrefixes() {
- report("Line Number\tMessage prefix\tMessage id"); //$NON-NLS-1$
- Collections.sort(_propertyLines, PropertyLineComparator.getMessagePrefixComparator());
- Iterator iterator = _propertyLines.iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
- if((line.getMessagePrefix() != null) && (!line.getMessagePrefix().equals(""))) { //$NON-NLS-1$
- StringBuffer buffer = new StringBuffer(String.valueOf(line.getLineNumber()));
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(line.getMessagePrefix());
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(line.getMessageId());
- report(buffer.toString());
- }
- }
- }
-
- /**
- * Print a list of all of the message prefixes, e.g., ABCD1111E,
- * that are not used in the file. A message prefix is considered
- * &quot;missing&quot; if a message prefix that precedes it,
- * e.g. ABCD0000E, and a message prefix that follows it,
- * e.g. ABCD2222E, are contained in the file, but the prefix is not.
- * This list is useful when adding a new message to the file;
- * the prefixes printed by this method are unused and one can be
- * selected for the new method.
- */
- public void printAllMissingMessagePrefixes() {
- int lastNumber = -1;
-
- Collections.sort(_propertyLines, PropertyLineComparator.getMessagePrefixComparator());
- Iterator iterator = _propertyLines.iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
- String prefix = line.getMessagePrefix();
- int prefixNumber = 0;
- if(prefix == null) {
- continue;
- }
-
- if(prefix.equals("")) { //$NON-NLS-1$
- continue;
- }
-
- String prefixLetters = prefix.substring(0, 4); // "ABCD" of "ABCD0000W"
- try {
- // Re: magic numbers "4" and "8" below.
- // Since the message prefix is of the form ABCD0000E,
- // strip off the first four characters up to (and excluding) the
- // eighth character, "E".
- prefixNumber = Integer.parseInt(prefix.substring(4, 8));
- }
- catch(NumberFormatException e) {
- // just continue
- continue;
- }
- if(lastNumber != -1) {
- if(prefixNumber != (lastNumber + 1)) {
- // Start at lastNumber + 1 because lastNumber exists.
- // Exclude prefixNumber because prefixNumber exists.
- for(int i=lastNumber+1; i<prefixNumber; i++) {
- report(prefixLetters + i);
- }
- }
- }
- lastNumber = prefixNumber;
- }
- }
-
- /**
- * Print all of the messages in the .properties file that use
- * a message prefix, e.g. ABCD0000E.
- */
- public void printAllMessagesWithAMessagePrefix() {
- report("MESSAGES WITH PREFIXES"); //$NON-NLS-1$
- Collections.sort(_propertyLines, PropertyLineComparator.getLineNoComparator());
- Iterator iterator = _propertyLines.iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
- if(line.hasMessagePrefix()) {
- report(line.toString());
- }
- }
- }
-
- /**
- * Print all of the messages in the .properties file whose message
- * text does not begin with a message prefix, e.g., ABCD0000E.
- */
- public void printAllMessagesWithoutAMessagePrefix() {
- report("BLANK MESSAGE PREFIX"); //$NON-NLS-1$
- Collections.sort(_propertyLines, PropertyLineComparator.getLineNoComparator());
- Iterator iterator = _propertyLines.iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
- if(!line.hasMessagePrefix()) {
- report(line.toString());
- }
- }
- }
-
- /**
- * Print a list of all messages whose text is the empty string (&quot;&quot;).
- */
- public void printAllMessagesWhichAreBlank() {
- report("BLANK MESSAGES"); //$NON-NLS-1$
- Collections.sort(_propertyLines, PropertyLineComparator.getLineNoComparator());
- Iterator iterator = _propertyLines.iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
- if(line.getMessage().equals("")) { //$NON-NLS-1$
- StringBuffer buffer = new StringBuffer("line number "); //$NON-NLS-1$
- buffer.append(line.getLineNumber());
- buffer.append(", message id "); //$NON-NLS-1$
- buffer.append(line.getMessageId());
- report(buffer.toString());
- }
- }
- }
-
- /**
- * Print a list of the lines that have syntax errors, for example,
- * missing the equals sign between the message id and the message
- * text.
- */
- public void printSyntaxWarnings() {
- List parseWarnings = getParseWarnings();
- Iterator iterator = parseWarnings.iterator();
- while (iterator.hasNext()) {
- report((MessageMetaData)iterator.next());
- }
- }
-
- /**
- * Print a list of all of the messages in the .properties file that
- * use the same message id. If more than one message uses the same
- * id, when the ResourceBundle is asked for that message id, it will
- * return the last message (i.e., the largest line number) with that
- * id in the file.
- */
- public void printDuplicateMessageId() {
- printDuplicateMessageId(true);
- }
-
- /**
- * Print a list of all of the messages in the .properties file that
- * use the same message id. If more than one message uses the same
- * id, when the ResourceBundle is asked for that message id, it will
- * return the last message (i.e., the largest line number) with that
- * id in the file.
- *
- * The boolean parameter is used to determine whether or not
- * the &quot;DUPLICATE MESSAGE IDS&quot; title is emitted before
- * the list of duplicates.
- */
- public void printDuplicateMessageId(boolean printTitle) {
- if(printTitle) {
- report("DUPLICATE MESSAGE IDS"); //$NON-NLS-1$
- }
- Comparator c = PropertyLineComparator.getMessageIdComparator();
- String messageId = IValidationConstants.ABCD0060;
- Collections.sort(_propertyLines, c);
- Iterator iterator = _propertyLines.iterator();
- PropertyLine lastLine = null;
- PropertyLine line = null;
- boolean needToPrintLast = false;
- while(iterator.hasNext()) {
- lastLine = line;
- line = (PropertyLine)iterator.next();
-
- if(c.compare(lastLine, line) == 0) {
- needToPrintLast = true;
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.WARNING, messageId, new String[]{lastLine.getMessageId()}, lastLine, lastLine.getLineNumber());
- report(mmd);
- }
- else if(needToPrintLast) {
- // The last duplicate line needs to be printed, because lastLine is always printed but line needs to be printed too.
- needToPrintLast = false;
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.WARNING, messageId, new String[]{lastLine.getMessageId()}, lastLine, lastLine.getLineNumber());
- report(mmd);
- }
- }
-
- if(needToPrintLast) {
- // The last duplicate line needs to be printed, because lastLine is always printed but line needs to be printed too.
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.WARNING, messageId, new String[]{line.getMessageId()}, line, line.getLineNumber());
- report(mmd);
- }
- }
-
- /**
- * Print a list of all of the messages in the .properties file that
- * do not use a unique message prefix (e.g., ABCD0000E), with the
- * exception of all messages which are intended to be duplicates.
- * Generally, users expect one message prefix per problem, so
- * reused message prefixes can be confusing. Any message which
- * deliberately reuses a message prefix must use a message id
- * that starts with that prefix.
- */
- public void printDuplicateMessagePrefix() {
- printDuplicateMessagePrefix(true);
- }
-
- /**
- * Print a list of all of the messages in the .properties file that
- * do not use a unique message prefix (e.g., ABCD0000E), with the
- * exception of all messages which are intended to be duplicates.
- * Generally, users expect one message prefix per problem, so
- * reused message prefixes can be confusing. Any message which
- * deliberately reuses a message prefix must use a message id
- * that starts with that prefix.
- *
- * The boolean parameter is used to determine whether or not
- * the &quot;DUPLICATE MESSAGE PREFIXESS&quot; title is emitted
- * before the list of duplicates.
- */
- public void printDuplicateMessagePrefix(boolean printTitle) {
- if(printTitle) {
- report("DUPLICATE MESSAGE PREFIXES"); //$NON-NLS-1$
- }
- Comparator c = PropertyLineComparator.getMessagePrefixComparator();
- Collections.sort(_propertyLines, c);
- String messageId = IValidationConstants.ABCD0070;
- Iterator iterator = _propertyLines.iterator();
- PropertyLine lastLine = null;
- PropertyLine line = null;
- boolean needToPrintLast = false;
- while(iterator.hasNext()) {
- lastLine = line;
- line = (PropertyLine)iterator.next();
-
- if(lastLine != null) {
- if(!lastLine.getMessageId().startsWith(lastLine.getShortMessagePrefix())) {
- if(c.compare(lastLine, line) == 0) {
- needToPrintLast = true;
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.WARNING, messageId, new String[]{lastLine.getMessagePrefix()}, lastLine, lastLine.getLineNumber());
- report(mmd);
- }
- else if(needToPrintLast) {
- // The last duplicate line needs to be printed, because lastLine is always printed but line needs to be printed too.
- needToPrintLast = false;
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.WARNING, messageId, new String[]{lastLine.getMessagePrefix()}, lastLine, lastLine.getLineNumber());
- report(mmd);
- }
- }
- }
- }
-
- if(lastLine != null) {
- if(!lastLine.getMessageId().startsWith(lastLine.getShortMessagePrefix())) {
- if(needToPrintLast) {
- // The last duplicate line needs to be printed, because lastLine is always printed but line needs to be printed too.
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.WARNING, messageId, new String[]{line.getMessagePrefix()}, line, line.getLineNumber());
- report(mmd);
- }
- }
- }
- }
-
- /**
- * Print a list of message prefixes whose first characters match
- * the prefix parameter. This method is useful when you want to see
- * if a range of prefixes is in use or not.
- */
- public void printMessagePrefixStartingWith(final String prefix) {
- report("Find all error prefixes starting with " + prefix); //$NON-NLS-1$
- Comparator c = PropertyLineComparator.getMessagePrefixComparator();
- Collections.sort(_propertyLines, c);
- Iterator iterator = _propertyLines.iterator();
- PropertyLine line = null;
- while(iterator.hasNext()) {
- line = (PropertyLine)iterator.next();
- if (line.getMessagePrefix().startsWith(prefix)) {
- StringBuffer buffer = new StringBuffer(String.valueOf(line.getLineNumber()));
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(line.getMessagePrefix());
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(line.getMessageId());
- report(buffer.toString());
- }
- }
- }
-
- /**
- * Print the last prefix (i.e., the one with the largest number,
- * e.g. ABCD2222 is larger than ABCD1111 or ABCD0000) in the file
- * whose first characters match the prefix parameter.
- */
- public void printLastMessagePrefixStartingWith(final String prefix) {
- report("Find last error prefix starting with " + prefix); //$NON-NLS-1$
- Comparator c = PropertyLineComparator.getMessagePrefixComparator();
- Collections.sort(_propertyLines, c);
- PropertyLine[] lines = new PropertyLine[_propertyLines.size()];
- _propertyLines.toArray(lines);
- boolean found = false;
- for(int i=lines.length; i>-1; i--) {
- PropertyLine line = lines[i];
- if (line.getMessagePrefix().startsWith(prefix)) {
- report(line.toString());
- found = true;
- break;
- }
- }
- if(!found) {
- report("No error ids were found that started with " + prefix); //$NON-NLS-1$
- }
- }
-
- /**
- * Given an estimate of the number of characters in a substitution parameter,
- * print a list of the number of characters in a given message, if each
- * parameter is replaced with &quot;length&quot; characters.
- */
- public void printExpectedStringLength(final int length) {
- report("EXPECTED LENGTH OF MESSAGE WITH PARAMETERS " + length + " LONG"); //$NON-NLS-1$ //$NON-NLS-2$
- Comparator c = PropertyLineComparator.getStringLengthComparator(length);
- Collections.sort(_propertyLines, c);
- Iterator iterator = _propertyLines.iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
-
- StringBuffer buffer = new StringBuffer("Length: "); //$NON-NLS-1$
- buffer.append(line.getExpectedLength(length));
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(line.toStringWithExpectedLength(length));
- report(buffer.toString());
- }
- }
-
- /**
- * Print the number of characters in each message.
- */
- public void printStringLength() {
- // "0" means no substitution
- printExpectedStringLength(0);
- }
-
- /**
- * Print the contents of the .properties file, sorted by message id.
- */
- public void printContents() {
- report("CONTENTS OF .properties FILE, SORTED BY MESSAGE ID"); //$NON-NLS-1$
- Comparator c = PropertyLineComparator.getMessageIdComparator();
- Collections.sort(_propertyLines, c);
- Iterator iterator = _propertyLines.iterator();
- while(iterator.hasNext()) {
- PropertyLine line = (PropertyLine)iterator.next();
- report(line.toString());
- }
- }
-
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/CompareProperties.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/CompareProperties.java
deleted file mode 100644
index f3e87d43..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/CompareProperties.java
+++ /dev/null
@@ -1,377 +0,0 @@
-package org.eclipse.jst.validation.sample.parser;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-/**
- * This class compares two .properties file and outputs a list
- * of the differences. This class is used to count the number
- * of words that have changed.
- */
-public class CompareProperties {
- public static final String lineSeparator = java.lang.System.getProperty("line.separator"); //$NON-NLS-1$
- private TreeSet _deleted = null;
- private TreeMap _changed = null;
- private TreeSet _added = null;
- private PropertyFile _oldFile = null;
- private PropertyFile _newFile = null;
-
- /**
- * This class is used to store PropertyLine instances which have the same
- * message id, but different values. When the list of differences is output,
- * all values are output so that the user can compare the lines manually, to
- * see what's different.
- */
- class CompareLine implements Comparable {
- private ArrayList _lines;
- private final String _messageId;
-
- public CompareLine(String messageId) {
- _messageId = messageId;
- _lines = new ArrayList();
- }
-
- public void add(PropertyLine oldLine, PropertyLine newLine) {
- _lines.add(new PropertyLine[]{oldLine, newLine});
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- Iterator iterator = _lines.iterator();
- while (iterator.hasNext()) {
- buffer.append(lineSeparator);
- buffer.append("\t"); //$NON-NLS-1$
- PropertyLine[] lines = (PropertyLine[])iterator.next();
-
- buffer.append(lines[0]);
- buffer.append("\n"); //$NON-NLS-1$
- buffer.append(lines[1]);
- }
- return buffer.toString();
- }
-
- /**
- * Since this is a changed string, return the absolute difference of words between the strings.
- */
- public int getNumWords() {
- int numWords = 0;
- Iterator iterator = _lines.iterator();
- while (iterator.hasNext()) {
- PropertyLine[] lines = (PropertyLine[])iterator.next();
- numWords = numWords + compare(lines[0], lines[1]);
- }
- return numWords;
- }
-
- private int compare(PropertyLine oldLine, PropertyLine newLine) {
- // For every word in the old string, see if it exists in the new
- // string. The position of the word doesn't matter - if the word
- // exists in the new, then the word is not counted as a "changed"
- // word.
- // 1. If the word exists, remove the word from the newLine and
- // advance to the next old token. (Remove word from newLine
- // in case the word existed twice in the old string but only
- // once in the new. The second oldWord should be counted as
- // a changed word.)
- // 2. If the word doesn't exist, numChanged++ and advance to the
- // next old token.
- // 3. Once all of the oldWords have been checked, tokenize the
- // remaining newWord and count the number of words in the string.
- // These words have been added and each one counts as a
- // changed word.
- int numChangedWords = 0;
- StringTokenizer oldTokenizer = new StringTokenizer(oldLine.getMessage());
-
- // Need to be careful...want the entire word, not oldWord="on" mistaken for newWord="one" or newWord="bond"
- // Easier to create a list of new words to compare against.
- StringTokenizer newTokenizer = new StringTokenizer(newLine.getMessage());
- List newWords = new ArrayList(); // Can't use a set in case the newLine uses a word, e.g. "the", more than once.
- while(newTokenizer.hasMoreTokens()) {
- newWords.add(newTokenizer.nextToken());
- }
-
- while(oldTokenizer.hasMoreTokens()) {
- String oldWord = oldTokenizer.nextToken();
- if(newWords.contains(oldWord)) {
- newWords.remove(oldWord);
- }
- else {
- numChangedWords++;
- }
- }
-
- // Can count the tokens but not the elments.
- numChangedWords += newWords.size();
- return numChangedWords;
- }
-
- public String getMessageId() {
- return _messageId;
- }
-
- public int compareTo(Object o) {
- // by default, sort by message id
- if (!(o instanceof CompareLine)) {
- // then how on earth did this method get called??
- // put it at the end of the list
- return 1;
- }
-
- return getMessageId().compareTo(((CompareLine) o).getMessageId());
- }
- }
-
- /**
- * Compare the two PropertyFile and print out a list of the differences;
- * the first parameter is the older .properties file, and the second
- * parameter is the newer .properties file.
- */
- public CompareProperties(PropertyFile oldFile, PropertyFile newFile) {
- _deleted = new TreeSet();
- _changed = new TreeMap();
- _added = new TreeSet();
-
- _oldFile = oldFile;
- _newFile = newFile;
-
- compare(oldFile, newFile);
- }
-
- /**
- * In the older PropertyFile, the message text was different; cache the
- * older version of the PropertyLine and the newer version of the PropertyLine.
- */
- private void addChanged(PropertyLine oldLine, PropertyLine newLine) {
- CompareLine cl = (CompareLine) _changed.get(oldLine.getMessageId());
- if (cl == null) {
- cl = new CompareLine(oldLine.getMessageId());
- }
- cl.add(oldLine, newLine);
- _changed.put(oldLine.getMessageId(), cl);
- }
-
- /**
- * Compare the two property files and build the collections of variable names with
- * their associated values.
- */
- public void compare(PropertyFile oldFile, PropertyFile newFile) {
- _added.clear();
- _deleted.clear();
- _changed.clear();
-
- // For each element in file 1, see if it exists in file 2
- // a) if it doesn't exist, add it to the list of "deleted" strings
- // b) if it exists, and if the value is different, add it to the list of "changed" strings
- // c) if it exists, and if the value is the same, add it to the list of "not changed" strings
- // d) delete the entry, if it exists, from file 2's hashtable so we don't check it twice.
- // For each element in file 2 not checked already, it cannot exist in file 1, so add it to the list of "new" strings
- //
- // Need some way to abort comparison if either of the files contains duplicate
- // message ids.
- //
- List oldKeys = new ArrayList(oldFile.getPropertyLines());
- List newKeys = new ArrayList(newFile.getPropertyLines());
- Collections.sort(oldKeys, PropertyLineComparator.getMessageIdComparator());
- Collections.sort(newKeys, PropertyLineComparator.getMessageIdComparator());
- Iterator oldIterator = oldKeys.iterator();
- Iterator newIterator = newKeys.iterator();
- PropertyLine oldLine = (oldIterator.hasNext()) ? (PropertyLine) oldIterator.next() : null;
- PropertyLine newLine = (newIterator.hasNext()) ? (PropertyLine) newIterator.next() : null;
- while ((oldLine != null) && (newLine != null)) {
- // oldLine message id is either <, =, or > newLine message id.
- // if <, message id has been deleted.
- // if =, see if changed (or just compare message ids.)
- // if >, new line is a new message id.
- // to increment, increment only the < (whether it's oldLine or newLine).
- int compare = oldLine.getMessageId().compareTo(newLine.getMessageId());
- if (compare < 0) {
- // deleted
- _deleted.add(oldLine);
- if (oldIterator.hasNext()) {
- oldLine = (PropertyLine) oldIterator.next();
- }
- else {
- oldLine = null;
- }
- }
- else if (compare == 0) {
- // existed before. Check if changed.
- if (!oldLine.getMessage().equals(newLine.getMessage())) {
- // changed
- addChanged(oldLine, newLine);
- }
- if (oldIterator.hasNext() && newIterator.hasNext()) {
- oldLine = (PropertyLine) oldIterator.next();
- newLine = (PropertyLine) newIterator.next();
- }
- else {
- oldLine = null;
- newLine = null;
- }
-
- }
- else {
- // added
- _added.add(newLine);
- if (newIterator.hasNext()) {
- newLine = (PropertyLine) newIterator.next();
- }
- else {
- newLine = null;
- }
- }
- }
-
- if (oldLine != null) {
- _deleted.add(oldLine);
- }
-
- if (newLine != null) {
- _added.add(newLine);
- }
-
- while (oldIterator.hasNext()) {
- // all of the rest have been deleted
- _deleted.add(oldIterator.next());
- }
-
- while (newIterator.hasNext()) {
- // all of the rest have been added
- _added.add(newIterator.next());
- }
- }
-
- /**
- * Return a Collction of PropertyLine instances that exist in
- * the newer PropertyFile that aren't in the older PropertyFile.
- */
- public Set getAdded() {
- return _added;
- }
-
- /**
- * Return a Collection of CompareLine instances that represent
- * the two PropertyLine instances; one from the older PropertyFile,
- * and one from the newer PropertyFile.
- */
- public Collection getChanged() {
- return _changed.values();
- }
-
- /**
- * Return a Collection of PropertyLine instances that do not
- * exist in the newer PropertyFile yet that exist in the older
- * PropertyFile.
- */
- public Set getDeleted() {
- return _deleted;
- }
-
- /**
- * Print out all of the collections of variable strings.
- */
- public void printResults() {
- // create an output log in the current directory, and in it list the strings in a section each.
- int numNew = printStrings("NEW PROPERTIES", _added); //$NON-NLS-1$
-
- int numWordsDeleted = printStrings("DELETED PROPERTIES", _deleted); //$NON-NLS-1$
- int numWordsChanged = printStrings("CHANGED PROPERTIES", _changed.values()); //$NON-NLS-1$
- float totalChange = numNew + numWordsDeleted + numWordsChanged;
- float numWords = _newFile.getNumWords();
- float percent = totalChange / numWords * 100;
-
- System.out.println();
- System.out.println("Number of new words: " + numNew); //$NON-NLS-1$
- System.out.println("Number of words in deleted messages: " + numWordsDeleted); //$NON-NLS-1$
- System.out.println("Number of changed words in modified messages: " + numWordsChanged); //$NON-NLS-1$
- System.out.println("Number of words in file " + _newFile.getQualifiedFileName() + ": " + numWords); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("Total change of words: " + totalChange + ", which is a " + percent + "% change."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void printResultsForTranslation() {
- // create an output log in the current directory, and in it list the strings in a section each.
- printStringsForTranslation("DELETED PROPERTIES", _deleted); //$NON-NLS-1$
- printStringsForTranslation("NEW PROPERTIES", _added); //$NON-NLS-1$
- printStringsForTranslation("CHANGED PROPERTIES", _changed.values()); //$NON-NLS-1$
- }
-
- /**
- * Print the number of lines in the .properties file.
- */
- private int printStrings(String header, Collection lines) {
- System.out.println();
- System.out.println(header);
- int count = 0;
- int numWords = 0;
- Iterator iterator = lines.iterator();
- while (iterator.hasNext()) {
- Object line = iterator.next();
- if(line instanceof PropertyLine) {
- numWords += ((PropertyLine)line).getNumWords();
- }
- else {
- // must be a compare line
- numWords += ((CompareLine)line).getNumWords();
- }
-
- count++;
- System.out.println(line);
- }
- System.out.println("Number of properties: " + count); //$NON-NLS-1$
- System.out.println();
- return numWords;
- }
-
- /**
- * Print the contents of the sorted collection of lines from the .properties file.
- */
- private void printStringsForTranslation(String header, Collection lines) {
- System.out.println();
- System.out.println(header);
- int count = 0;
- Iterator iterator = lines.iterator();
- while (iterator.hasNext()) {
- count++;
- Object line = iterator.next();
- if (line instanceof PropertyLine) {
- PropertyLine propline = (PropertyLine) line;
- System.out.println(propline.getMessageId());
- }
- else if (line instanceof CompareLine) {
- CompareLine propline = (CompareLine) line;
- System.out.println(propline.getMessageId());
- }
- else {
- System.out.println("instance of " + line.getClass().getName()); //$NON-NLS-1$
- }
- }
- System.out.println("Total: " + count); //$NON-NLS-1$
- System.out.println();
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/IValidationConstants.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/IValidationConstants.java
deleted file mode 100644
index c8ae9e48..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/IValidationConstants.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.jst.validation.sample.parser;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-/**
- * This interface contains the message ids of all of the Properties
- * Validator's messages, and the name of the resource bundle that
- * contains those messages.
- */
-public interface IValidationConstants {
- /*package*/ static final String BUNDLENAME = "propertiesValidator"; //$NON-NLS-1$
-
- /*package*/ static final String ABCD0000 = "ABCD0000"; //$NON-NLS-1$
- /*package*/ static final String ABCD0010E = "ABCD0010E"; //$NON-NLS-1$
- /*package*/ static final String ABCD0010W = "ABCD0010W"; //$NON-NLS-1$
- /*package*/ static final String ABCD0020 = "ABCD0020"; //$NON-NLS-1$
- /*package*/ static final String ABCD0030 = "ABCD0030"; //$NON-NLS-1$
- /*package*/ static final String ABCD0040 = "ABCD0040"; //$NON-NLS-1$
- /*package*/ static final String ABCD0050 = "ABCD0050"; //$NON-NLS-1$
- /*package*/ static final String ABCD0060 = "ABCD0060"; //$NON-NLS-1$
- /*package*/ static final String ABCD0070 = "ABCD0070"; //$NON-NLS-1$
- /*package*/ static final String ABCD0080 = "ABCD0080"; //$NON-NLS-1$
- /*package*/ static final String ABCD0090 = "ABCD0090"; //$NON-NLS-1$
- /*package*/ static final String ABCD0110 = "ABCD0110"; //$NON-NLS-1$
- /*package*/ static final String ABCD0120 = "ABCD0120"; //$NON-NLS-1$
- /*package*/ static final String ABCD0130 = "ABCD0130"; //$NON-NLS-1$
-
- /*package*/ static final String LINE_LOC = "LINE_LOC"; //$NON-NLS-1$
-}
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/Main.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/Main.java
deleted file mode 100644
index a4d6ee1a..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/Main.java
+++ /dev/null
@@ -1,451 +0,0 @@
-package org.eclipse.jst.validation.sample.parser;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.io.File;
-
-/**
- * This class is used to perform validation or .properties file queries
- * without using an IValidator.
- */
-public class Main {
- public static void main(String[] argv) {
- if(argv.length < 1) {
- System.out.println("prop -tr [-a | -ac | -am | -an | -al PREFIX | -ap PREFIX | -au | -b | -di | -dp | -l | -le <positive integer> | -p ] f:\\dir1\\dir2\\myPropertiesFile.properties"); //$NON-NLS-1$
- System.out.println("or "); //$NON-NLS-1$
- System.out.println("prop [-c|-ct] f:\\dir1\\dir2\\myPropertiesFile.properties f:\\dir1\\dir2\\myNewPropertiesFile.properties"); //$NON-NLS-1$
- System.out.println(" -a: print all error/warning/info prefixes in the file"); //$NON-NLS-1$
- System.out.println(" -ac: print a count of messages with and without prefixes in the file"); //$NON-NLS-1$
- System.out.println(" -am: print all messages with a prefix"); //$NON-NLS-1$
- System.out.println(" -an: print all messages without an error prefix"); //$NON-NLS-1$
- System.out.println(" -al: print the last error/warning/info prefix, starting with PREFIX, in the file"); //$NON-NLS-1$
- System.out.println(" -ap: print any error/warning/info prefixes, starting with PREFIX, in the file"); //$NON-NLS-1$
- System.out.println(" -au: print all error/warning/info prefixes that are not used in the file"); //$NON-NLS-1$
- System.out.println(" -b: print any blank messages in the properties file"); //$NON-NLS-1$
- System.out.println(" -c: compare the two property files listed. The first is the older, and the second is the newer."); //$NON-NLS-1$
- System.out.println(" -ct: compare the two property files listed. The first is the older, and the second is the newer. Output a list of the added, deleted, and changed strings, but print only the message id."); //$NON-NLS-1$
- System.out.println(" -di: print any duplicate message ids and syntax errors in the properties file"); //$NON-NLS-1$
- System.out.println(" -dp: print any duplicate error/warning/info prefixes in the file"); //$NON-NLS-1$
- System.out.println(" -l: print the length of each message in the file"); //$NON-NLS-1$
- System.out.println(" -le: print the length of each message in the file if each parameter is <positive integer> characters long."); //$NON-NLS-1$
- System.out.println(" -n: print the number of words in the file, including message prefixes and parameters"); //$NON-NLS-1$
- System.out.println(" -p: print the contents of the property file, sorted by message id"); //$NON-NLS-1$
- System.out.println(" -tr: print trace information while parsing the .properties file"); //$NON-NLS-1$
- System.out.println();
- System.out.println("The default action is to print the syntax errors, duplicates, and other types of errors in the given .properties file."); //$NON-NLS-1$
- System.exit(-1);
- }
-
- // This is not robust error-checking by any stretch of the imagination!
- int index = 0;
- String option = argv[index++].toLowerCase();
- boolean trace = false;
- if(option.equals("-tr")) { //$NON-NLS-1$
- trace = true;
- option = argv[index++].toLowerCase();
- }
-
- if (option.equals("-a") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printAllErrorPrefix(trace, files);
- }
- else if (option.equals("-ac") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printPrefixCount(trace, files);
- }
- else if (option.equals("-al") && (argv.length >= 3)) { //$NON-NLS-1$
- String[] files = new String[argv.length-2];
- System.arraycopy(argv, 2, files, 0, files.length);
- printErrorPrefix(trace, argv[index], files);
- }
- else if (option.equals("-am") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printErrorMessages(trace, files);
- }
- else if (option.equals("-an") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printMessagesWithoutPrefixes(trace, files);
- }
- else if (option.equals("-ap") && (argv.length >= 3)) { //$NON-NLS-1$
- String[] files = new String[argv.length-2];
- System.arraycopy(argv, 2, files, 0, files.length);
- printErrorPrefixRange(trace, argv[index], files);
- }
- else if (option.equals("-au") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printAllMissingErrorPrefix(trace, files);
- }
- else if (option.equals("-b") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printBlanks(trace, files);
- }
- else if (option.equals("-c") && (argv.length == 3)) { //$NON-NLS-1$
- File oldFile = new File(argv[index++]);
- File newFile = new File(argv[index]);
- compareFiles(trace, oldFile, newFile);
- }
- else if (option.equals("-ct") && (argv.length == 3)) { //$NON-NLS-1$
- File oldFile = new File(argv[index++]);
- File newFile = new File(argv[index]);
- compareFilesForTranslation(trace, oldFile, newFile);
- }
- else if (option.equals("-di") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printDuplicateIds(trace, files);
- }
- else if (option.equals("-dp") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printDuplicatePrefixes(trace, files);
- }
- else if (option.equals("-l") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printStringLength(trace, files);
- }
- else if (option.equals("-le") && (argv.length >= 3)) { //$NON-NLS-1$
- String[] files = new String[argv.length-2];
- System.arraycopy(argv, 2, files, 0, files.length);
- printExpectedStringLength(trace, argv[index], files);
- }
- else if (option.equals("-n") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printWordCount(trace, files);
- }
- else if (option.equals("-p") && (argv.length >= 2)) { //$NON-NLS-1$
- String[] files = new String[argv.length-1];
- System.arraycopy(argv, 1, files, 0, files.length);
- printFileContents(trace, files);
- }
- else {
- printDefault(trace, argv);
- }
- }
-
- public static void printAllErrorPrefix(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printAllMessagePrefixes();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printAllMissingErrorPrefix(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printAllMissingMessagePrefixes();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printBlanks(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printAllMessagesWhichAreBlank();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printMessagesWithoutPrefixes(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printAllMessagesWithoutAMessagePrefix();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void compareFiles(boolean trace, File oldFile, File newFile) {
- if(oldFile.isFile() && newFile.isFile()) {
- try {
- PropertyFile oldPropFile = new PropertyFile(oldFile.getAbsolutePath(), trace);
- PropertyFile newPropFile = new PropertyFile(newFile.getAbsolutePath(), trace);
- CompareProperties cp = new CompareProperties(oldPropFile, newPropFile);
- cp.printResults();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- else if(oldFile.isDirectory() && newFile.isDirectory()) {
- String[] oldChildren = oldFile.list();
- for(int i=0; i<oldChildren.length; i++) {
- File newChild = new File(newFile, oldChildren[i]);
- if(newChild.exists()) {
- // Found a file or directory that is named the same in the old & new. Compare.
- compareFiles(trace, new File(oldFile, oldChildren[i]), newChild);
- }
- }
- }
- else {
- System.out.println("Compare two files or two directories. Do not compare a file to a directory (" + oldFile.getName() + ", " + newFile.getName() + ")."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- public static void compareFilesForTranslation(boolean trace, File oldFile, File newFile) {
- if(oldFile.isFile() && newFile.isFile()) {
- try {
- PropertyFile oldPropFile = new PropertyFile(oldFile.getAbsolutePath(), trace);
- PropertyFile newPropFile = new PropertyFile(newFile.getAbsolutePath(), trace);
- CompareProperties cp = new CompareProperties(oldPropFile, newPropFile);
- cp.printResultsForTranslation();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- else if(oldFile.isDirectory() && newFile.isDirectory()) {
- String[] oldChildren = oldFile.list();
- for(int i=0; i<oldChildren.length; i++) {
- File newChild = new File(newFile, oldChildren[i]);
- if(newChild.exists()) {
- // Found a file or directory that is named the same in the old & new. Compare.
- compareFilesForTranslation(trace, new File(oldFile, oldChildren[i]), newChild);
- }
- }
- }
- else {
- System.out.println("Compare two files or two directories. Do not compare a file to a directory (" + oldFile.getName() + ", " + newFile.getName() + ")."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- public static void printDuplicateIds(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printDuplicateMessageId();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printErrorPrefix(boolean trace, String prefix, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printLastMessagePrefixStartingWith(prefix);
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printErrorPrefixRange(boolean trace, String prefix, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printMessagePrefixStartingWith(prefix);
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printDuplicatePrefixes(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printDuplicateMessagePrefix();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printStringLength(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printStringLength();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printExpectedStringLength(boolean trace, String slength, String[] files) {
- int length = 0;
-
- try {
- length = new Integer(slength).intValue();
- }
- catch(NumberFormatException exc) {
- System.out.println();
- System.out.println("Parameter must be an integer."); //$NON-NLS-1$
- System.out.println();
- return;
- }
-
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printExpectedStringLength(length);
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printErrorMessages(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printAllMessagesWithAMessagePrefix();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printWordCount(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- System.out.println(propFile.getQualifiedFileName() + ":: Number of words :: " + propFile.getNumWords()); //$NON-NLS-1$
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printPrefixCount(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- System.out.println("Usually the number of unique prefixes and the number of prefixes is the same, but if a .properties file has variations of a message (slightly different wording for a different context), then the number of prefix messages will be larger than the number of unique prefixes."); //$NON-NLS-1$
- System.out.println(propFile.getQualifiedFileName() + ":: Number of unique prefixes :: " + propFile.getNumUniquePrefixes()); //$NON-NLS-1$
- System.out.println(propFile.getQualifiedFileName() + ":: Number of messages with prefixes :: " + propFile.getNumPrefixes()); //$NON-NLS-1$
- System.out.println(propFile.getQualifiedFileName() + ":: Number of messages without prefixes :: " + propFile.getNumWithoutPrefixes()); //$NON-NLS-1$
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
- public static void printFileContents(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printContents();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void printDefault(boolean trace, String[] files) {
- for (int i = 0; i < files.length; i++) {
- try {
- // print all errors, warnings, etc.
- System.out.println("******************************************"); //$NON-NLS-1$
- PropertyFile propFile = new PropertyFile(files[i], trace);
- propFile.printSyntaxWarnings();
- propFile.printDuplicateMessageId();
- propFile.printDuplicateMessagePrefix();
- System.out.println("******************************************"); //$NON-NLS-1$
- System.out.println();
- }
- catch (java.io.IOException e) {
- System.out.println(e.getMessage());
- }
- }
- }
-
- public static void print(String[] argv) {
- for(int i =0;i<argv.length; i++) {
- System.out.println(i + ". " + argv[i]); //$NON-NLS-1$
- }
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/MessageMetaData.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/MessageMetaData.java
deleted file mode 100644
index 907e5586..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/MessageMetaData.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package org.eclipse.jst.validation.sample.parser;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-
-/**
- * This class holds the metadata for an IMessage that must be
- * reported to the user (i.e., a validation error, warning,
- * or information message).
- */
-public class MessageMetaData {
- public static final int INT_UNSET = -1;
- public static final int ERROR = 1;
- public static final int WARNING = 2;
- public static final int INFO = 3;
-
- private String _bundleName = null;
- private int _severity = INT_UNSET;
- private String _messageId = null;
- private String[] _parms = null;
- private Object _targetObject = null;
- private int _lineNumber = INT_UNSET;
- private int _offset = INT_UNSET;
- private int _length = INT_UNSET;
- private String _text = null;
-
- /**
- * This constructor should be used if the message text has already
- * been translated.
- */
- public MessageMetaData(String messageText) {
- _text = messageText;
- }
-
- /**
- * This constructor should be used if the message text is not translated
- * until just before the text should be shown to the user.
- *
- * @param bundleName - The name of the resource bundle in which the message is contained
- * @param severity - One of the com.ibm.etools.validation.core.SeverityEnum constants; this parameter represents the severity of the IMessage.
- * @param messageId - The message id that uniquely identifies the message to be retrieved from the bundle.
- * @param parms - The parameters to be substituted into the java.text.MessageText's patterns.
- * @param targetObject - The target object of the IMessage (see com.ibm.etools.validation.core.IMessage).
- * @param lineNumber - The line number where the problem can be found.
- */
- public MessageMetaData(String bundleName, int severity, String messageId, String[] parms, Object targetObject, int lineNumber) {
- this(bundleName, severity, messageId, parms, targetObject, lineNumber, INT_UNSET, INT_UNSET);
- }
-
- /**
- * This constructor should be used if the message text is not translated
- * until just before the text should be shown to the user.
- *
- * @param bundleName - The name of the resource bundle in which the message is contained
- * @param severity - One of the com.ibm.etools.validation.core.SeverityEnum constants; this parameter represents the severity of the IMessage.
- * @param messageId - The message id that uniquely identifies the message to be retrieved from the bundle.
- * @param parms - The parameters to be substituted into the java.text.MessageText's patterns.
- * @param targetObject - The target object of the IMessage (see com.ibm.etools.validation.core.IMessage).
- * @param lineNumber - The line number where the problem can be found.
- * @param offset - In number of characters, how many characters from the start of the .properties file to the location of the problem.
- * @param length - In number of characters, how many characters from the offset to the end of the problem.
- */
- public MessageMetaData(String bundleName, int severity, String messageId, String[] parms, Object targetObject, int lineNumber, int offset, int length) {
- _bundleName = bundleName;
- _severity = severity;
- _messageId = messageId;
- _parms = parms;
- _targetObject = targetObject;
- _lineNumber = lineNumber;
- _offset = offset;
- _length = length;
- }
-
- public String getBundleName() {
- return _bundleName;
- }
-
- public int getSeverity() {
- return _severity;
- }
-
- public String getId() {
- return _messageId;
- }
-
- public String[] getParams() {
- return _parms;
- }
-
- public Object getTargetObject() {
- return _targetObject;
- }
-
- public int getLineNumber() {
- return _lineNumber;
- }
-
- public int getOffset() {
- return _offset;
- }
-
- public int getLength() {
- return _length;
- }
-
- /**
- * Use the given ClassLoader to load this message's text
- * from the resource bundle.
- */
- public String getText(ClassLoader classLoader) {
- if(_text == null) {
- return getText(Locale.getDefault(), classLoader);
- }
- return _text;
- }
-
- /**
- * Use the given ClassLoader to load this message's text,
- * for the Locale, from the resource bundle.
- */
- public String getText(Locale locale, ClassLoader classLoader) {
- if(_text == null) {
- return getText(getBundleName(), locale, classLoader, getId(), getParams());
- }
-
- return _text;
- }
-
- /**
- * Return the translated message.
- *
- * @param bundleName The name of the resource bundle to search for the message.
- * @param locale The Locale for which the message should be loaded.
- * @param classLoader The ClassLoader which can locate the resource bundle.
- * @param messageId The unique id, in the resource bundle, that identifies the message.
- * @param parms The parameters to substitute into the pattern of the java.text.MessageFormat message.
- */
- public static java.lang.String getText(String bundleName, Locale locale, ClassLoader classLoader, String messageId, String[] parms) {
- String message = ""; //$NON-NLS-1$
-
- if (locale == null) {
- return message;
- }
-
- ResourceBundle bundle = getBundle(bundleName, locale, classLoader);
- if (bundle == null) {
- return message;
- }
-
- try {
- message = bundle.getString(messageId);
-
- if (parms != null) {
- message = java.text.MessageFormat.format(message, parms);
- }
- }
- catch (MissingResourceException exc) {
- System.err.println(exc.getMessage());
- System.err.println(messageId);
- }
- catch (NullPointerException exc) {
- System.err.println(exc.getMessage());
- System.err.println(messageId);
- }
-
- return message;
- }
-
- /**
- * Return the resource bundle which contains the messages, as identified by
- * @link #getBundleName()
- */
- public static ResourceBundle getBundle(String bundleName, Locale locale, ClassLoader classLoader) {
- ResourceBundle bundle = null;
- try {
- if (classLoader == null) {
- bundle = ResourceBundle.getBundle(bundleName, locale);
- }
- else {
- bundle = ResourceBundle.getBundle(bundleName, locale, classLoader);
- }
- }
- catch (MissingResourceException e) {
- e.printStackTrace();
- }
- return bundle;
- }
-
-}
-
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyFile.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyFile.java
deleted file mode 100644
index 8b60b140..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyFile.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.jst.validation.sample.parser;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.io.File;
-
-/**
- * This PropertyFile is instantiated by code that isn't an IValidator.
- */
-public class PropertyFile extends APropertyFile {
- private String _enclosingZipFileName = null;
- private String _propertyFileName = null;
- private String _fileName = null;
-
- public PropertyFile(String fileName) throws java.io.IOException {
- this(fileName, false);
- }
-
- public PropertyFile(String fileName, boolean trace) throws java.io.IOException {
- this(new File(fileName), trace);
- }
-
- public PropertyFile(File propertyFile) throws java.io.IOException {
- this(propertyFile, false);
- }
-
- public PropertyFile(File propertyFile, boolean trace) throws java.io.IOException {
- this(null, propertyFile, trace);
- }
-
- public PropertyFile(String enclosingZipFileName, File propertyFile) throws java.io.IOException {
- this(enclosingZipFileName, propertyFile, false);
- }
-
- public PropertyFile(String enclosingZipFileName, File propertyFile, boolean debug) throws java.io.IOException {
- if (!propertyFile.exists())
- throw new java.io.IOException("Cannot find file " + propertyFile.getName()); //$NON-NLS-1$
- if (!propertyFile.isFile())
- throw new java.io.IOException(propertyFile.getName() + " is not a file"); //$NON-NLS-1$
- if (!propertyFile.canRead())
- throw new java.io.IOException("Cannot read " + propertyFile.getName()); //$NON-NLS-1$
- if (!propertyFile.getName().endsWith("properties")) //$NON-NLS-1$
- throw new java.io.IOException("Can parse only .properties files; ignoring " + propertyFile.getName()); //$NON-NLS-1$
-
- setDebug(debug);
-
- _enclosingZipFileName = enclosingZipFileName;
-
- _fileName = propertyFile.getName();
-
- report("File name: " + _fileName); //$NON-NLS-1$
- parseFile(propertyFile);
- report(""); //$NON-NLS-1$
-
- propertyFile = null;
- }
-
- /*
- * @see APropertyFile#report(String)
- */
- public void report(String str) {
- System.out.println(str);
- }
-
- /*
- * @see APropertyFile#report(MessageMetaData)
- */
- public void report(MessageMetaData message) {
- StringBuffer buffer = new StringBuffer(message.getText(getClass().getClassLoader()));
- buffer.append(ResourceHandler.getExternalizedMessage(IValidationConstants.BUNDLENAME, IValidationConstants.LINE_LOC, new String[]{String.valueOf(message.getLineNumber()), getQualifiedFileName()}));
- report(buffer.toString());
- }
-
- public String getQualifiedFileName() {
- if (_propertyFileName == null) {
- if (_enclosingZipFileName == null) {
- _propertyFileName = _fileName;
- }
- else {
- _propertyFileName = _enclosingZipFileName + "::" + _fileName; //$NON-NLS-1$
- }
- }
- return _propertyFileName;
- }
-
- public String getFileName() {
- return _fileName;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyLine.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyLine.java
deleted file mode 100644
index aae4429a..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyLine.java
+++ /dev/null
@@ -1,646 +0,0 @@
-package org.eclipse.jst.validation.sample.parser;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * PropertyLine represents a line in a PropertyFile. It has a message id,
- * a message value (the text of the property; this is the text which is
- * translated), a line number, and, optionally, an unique error id (of the
- * form ABCD1234{E|W|I}).
- */
-public class PropertyLine implements Comparable {
- private String _messageId; // the message id (not translated)
- private String _message = null; // the message value with the error id (translated)
- private String _messagePrefix = null; // the prefix (e.g. ABCD1234{E|W|I}
- private String _shortMessage = null; // the message value without the error id (translated)
- private int _lineNumber = -1; // the line number of this message value
- private int _numWords = -1;
- private final String EMPTY = ""; //$NON-NLS-1$
- private APropertyFile _file = null;
- private int _offset = -1; // the offset, in the .properties file, where this line begins
- private int _messageOffset = -1; // the offset in the line, after the EQUALS, where the message prefix begins
-
- private static final char QUOTE = '\'';
- private static final char OBRACKET = '{';
- private static final char CBRACKET = '}';
-
- // The Enum for the message severity can be one of these four values. If there is an error id,
- // UNASSIGNED indicates an invalid value.
- public final static int UNASSIGNED = 0;
- public final static int ERROR = 0x1;
- public final static int WARNING = 0x2;
- public final static int INFO = 0x3;
-
- private int _severity = UNASSIGNED; // the severity of the message, if this message has an error id. UNASSIGNED means either that the severity was an invalid severity (not info, warn, or error), or that the message has no error id. Check the value of the error id to find out which of the two is the case.
- private int _numParms = 0;
-
- private static final char[] BLANK = " ".toCharArray(); // this string is 100 characters long. It's used to quickly get a blank string in the getBlank(int) method. Hopefully the user will never want more than 100 char in a given parameter. //$NON-NLS-1$
-
- public PropertyLine(APropertyFile file, int offset, int messageOffset, String messageId, String message, int lineNumber) {
- // Comment on the use of intern().
- // Because it's likely that we'll be comparing this string a lot,
- // load it into the Java constants space through intern(). Since we won't
- // be modifying this string, it's safe to load it into the constants space.
- //
- _offset = offset; // the offset in the .properties file where this line begins
- _messageOffset = messageOffset; // the offset in the line, after the EQUALS, where the message prefix begins
- _messageId = messageId;
- _message = message; // re: intern(). Ditto.
- _lineNumber = lineNumber;
- _file = file;
-
- parse(message);
- }
-
- public int compareTo(Object o) {
- // by default, sort by message id
- if (!(o instanceof PropertyLine)) {
- // then how on earth did this method get called??
- // put it at the end of the list
- return 1;
- }
-
- return getMessageId().compareTo(((PropertyLine) o).getMessageId());
- }
-
- public APropertyFile getFile() {
- return _file;
- }
-
- public String getMessagePrefix() {
- return _messagePrefix;
- }
-
- public boolean hasMessagePrefix() {
- if(_messagePrefix == null) {
- return false;
- }
-
- if(_messagePrefix.equals(EMPTY)) {
- return false;
- }
-
- return true;
- }
-
- public int getLineNumber() {
- return _lineNumber;
- }
- public String getMessage() {
- return _message;
- }
- public String getMessageId() {
- return _messageId;
- }
- public String getShortMessage() {
- return _shortMessage;
- }
-
- /**
- * This method returns the number of words in the message excluding
- * the message error id prefix.
- */
- public int getNumWords() {
- if(_numWords == -1) {
- _numWords = 0;
- StringTokenizer tokenizer = new StringTokenizer(getShortMessage());
- _numWords = tokenizer.countTokens();
- }
- return _numWords;
- }
-
- /**
- * This method returns the number of characters in the
- * message including the message prefix and parameters. (i.e., {0} would
- * be counted as three characters.)
- */
- public int getLength() {
- return getMessage().length();
- }
-
- /**
- * This method returns the number of characters in the
- * message including the message prefix and the expected
- * number of characters. (That is, the lengthParm parameter
- * is used as an approximation of the length of each parameter
- * in the message.)
- */
- public int getExpectedLength(int lengthParm) {
- if(hasParameters() && (lengthParm > 0)) {
- return getExpectedMessage(lengthParm).length();
- }
- else {
- return getLength();
- }
- }
-
- /**
- * This method substitutes a blank stub of the given length
- * every place in the string where there is a parm.
- */
- public String getExpectedMessage(int lengthParm) {
- if(hasParameters() && (lengthParm > 0)) {
- // message cannot be null or blank or it wouldn't have parameters
- String blank = getBlank(lengthParm);
-
- int numParm = getNumParameters();
- String[] parm = new String[numParm];
- for(int i=0; i<parm.length; i++) {
- parm[i] = blank;
- }
-
- try {
- return java.text.MessageFormat.format(getMessage(), parm);
- }
- catch(IllegalArgumentException exc) {
- if(getFile().debug()) {
- getFile().report(exc.getMessage());
- getFile().report(getFile().getQualifiedFileName() + "::" + getMessageId()); //$NON-NLS-1$
- }
- return getMessage();
- }
- }
- else {
- return getMessage();
- }
- }
-
- /**
- * Return a blank string of the given length.
- */
- public static String getBlank(int length) {
- char[] blank = new char[length];
- if(length > BLANK.length) {
- for(int i=0; i<length; i++) {
- blank[i] = ' ';
- }
- }
- else {
- System.arraycopy(BLANK, 0, blank, 0, length);
- }
- return new String(blank);
- }
-
- /**
- * Return true if the line has java.text.MessageFormat patterns.
- */
- public boolean hasParameters() {
- return getNumParameters() > 0;
- }
-
- /**
- * Return the number of java.text.MessageFormat patterns in the property line.
- */
- public int getNumParameters() {
- return _numParms;
- }
-
- /**
- * Return the number of characters, from the start of the file, to
- * the beginning of the message.
- */
- public int getMessageOffset() {
- return _messageOffset;
- }
-
- /**
- * The offset, in the .properties file, where this line begins.
- */
- public int getOffset() {
- return _offset;
- }
-
- /**
- * The severity of the message, if this message has an error id.
- * UNASSIGNED means either that the severity was an invalid severity
- * (not info, warn, or error), or that the message has no error id. Check
- * the value of the error id to find out which of the two is the case.
- */
- public int getSeverity() {
- return _severity;
- }
-
- /**
- * Parse the message value to extract the unique error id, if any exists.
- * This method initializes some of the fields in this class.
- */
- public void parse(String message) {
- // To see why it's safe to call intern(), read the comment in the
- // constructor.
-
- // Case 1: ABCD0000E: Blah Blah Blah
- // Case 2: ABCD0000E Blah Blah Blah
- // Case 3: ABCD0000E : Blah Blah Blah
- // Case 4: ABCD0000E Blah:Blah Blah
- // Case 5: ABCD0000E :
- // Case 6: Blah Blah Blah (i.e., no prefix)
- // Case 7: ABCD0000E: Blah
- // Case 8: ABCD0000E Blah
- // Case 9: ABCD0000E : Blah
- // Case 10: ABCD0000E Blah
- // Case 11: ABCD0000E
-
- if (message == null) {
- _messagePrefix = EMPTY;
- _shortMessage = EMPTY;
- return;
- }
-
- StringTokenizer tokenizer = new StringTokenizer(message);
- int numTokens = tokenizer.countTokens();
- if (numTokens == 0) {
- _messagePrefix = EMPTY;
- _shortMessage = message;
- }
- else {
- String errorId = tokenizer.nextToken();
- boolean prefixExists = false;
-
- // Sometimes the ':' isn't there or isn't in the right place, so don't determine the message prefix based on that.
- String afterPrefix = null;
- if(errorId.length() >= 9) {
- afterPrefix = errorId.substring(0, 9); // Must be of the form ABCD1234E, which is 9 char long
- char[] temp = afterPrefix.toCharArray();
- prefixExists = Character.isLetter(temp[0]) && Character.isUpperCase(temp[0]);
- prefixExists = prefixExists && Character.isLetter(temp[1]) && Character.isUpperCase(temp[0]);
- prefixExists = prefixExists && Character.isLetter(temp[2]) && Character.isUpperCase(temp[0]);
- prefixExists = prefixExists && Character.isLetter(temp[3]) && Character.isUpperCase(temp[0]);
- prefixExists = prefixExists && Character.isDigit(temp[4]);
- prefixExists = prefixExists && Character.isDigit(temp[5]);
- prefixExists = prefixExists && Character.isDigit(temp[6]);
- prefixExists = prefixExists && Character.isDigit(temp[7]);
- prefixExists = prefixExists && Character.isLetter(temp[8]) && Character.isUpperCase(temp[0]);
-
- if (prefixExists) {
- switch (temp[8]) {
- case ('E') :
- {
- _severity = ERROR;
- break;
- }
- case ('W') :
- {
- _severity = WARNING;
- break;
- }
- case ('I') :
- {
- _severity = INFO;
- break;
- }
-
- default :
- {
- _severity = UNASSIGNED;
- break;
- }
- }
- _messagePrefix = afterPrefix;
-
- int colonIndex = errorId.indexOf(':');
- boolean noColon = (colonIndex == -1);
-
- int shortMessageIndex = 10; // assume that only the ABCD0000E prefix will be stripped (i.e., no colon)
- if(noColon) {
- // No colon following message prefix immediately.
- // Is there whitespace before the colon?
- if (numTokens > 1) {
- String nextToken = tokenizer.nextToken();
- colonIndex = nextToken.indexOf(':');
- noColon = ((colonIndex == -1) || (nextToken.trim().indexOf(':') != 0)); // case 4 trim condition will be true
-
- // ":" should follow the message prefix immediately
- // Know there's a prefix, and that's 9 char
- if(noColon) {
- // Case 2, 4, 8 or 10
-// MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.INFO, IValidationConstants.ABCD0120, new String[]{}, this, getLineNumber());
-// getFile().addParseWarning(mmd);
- shortMessageIndex = 10;
- }
- else {
-// MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.INFO, IValidationConstants.ABCD0130, new String[]{}, this, getLineNumber());
-// getFile().addParseWarning(mmd);
-
- if(numTokens > 2) {
- // Case 3 or 9
- nextToken = tokenizer.nextToken();
- shortMessageIndex = message.indexOf(nextToken);
- }
- else {
- // Case 5
- shortMessageIndex = colonIndex + 1;
- }
- }
- _shortMessage = message.substring(shortMessageIndex, message.length());
- }
- else {
- // Case 11
- _shortMessage = EMPTY;
- }
- }
- else {
- // Case 1 or 7
- shortMessageIndex = colonIndex + 1;
- _shortMessage = message.substring(shortMessageIndex, message.length());
- }
- }
-
- }
-
- if (!prefixExists) {
- // Case 6
- _messagePrefix = EMPTY;
- _shortMessage = message;
- }
- }
-
- getFile().addParseWarnings(parseMessage());
- }
-
- /**
- * Once the field that holds the message text has been set (i.e., parse(String)
- * has been called), this method parses the message text, finds any syntax or
- * other problems, and returns a List of MessageMetaData, with one MessageMetaData
- * for each problem.
- */
- public List parseMessage() {
- // now parse to see if all apostrophes are in pairs, if there are parameters or not, etc.
- ArrayList intList = new ArrayList();
- int numObrackets = 0;
- int numCbrackets = 0;
- int index = 0;
- char token;
- int singleQuoteIndex = -1;
- int doubleQuoteIndex = -1;
- int missingTerminatingQuoteIndex = -1;
- boolean parmExists = false;
- int numCharBeforeShort = getMessageOffset() + getMessage().indexOf(getShortMessage());
-
- while (index < getShortMessage().length()) {
- token = getShortMessage().charAt(index++);
- if (token == QUOTE) {
- if (index < getShortMessage().length()) {
- token = getShortMessage().charAt(index++);
- }
- else {
- token = ' ';
- }
-
- if ((token == OBRACKET) || (token == CBRACKET)){
- if (index < getShortMessage().length()) {
- token = getShortMessage().charAt(index++);
- }
- else {
- token = ' ';
- }
-
- // Does the { or } character have a terminating single quote?
- if(token != QUOTE) {
- missingTerminatingQuoteIndex = (numCharBeforeShort + index-1);
- }
- }
- else if ((token == QUOTE)) {
- doubleQuoteIndex = (numCharBeforeShort + index-1);
- }
- else {
- // '{' means that a { will be output,
- // '}' means that a } will be output,
- // '' means that a ' will be output.
-
- // Since the quote is a special character, and the opening bracket is a
- // special character, keep track of the number of open brackets. If the
- // following character isn't a quote or opening bracket, warn the user
- // that it takes two apostrophes to see one apostrophe.
- singleQuoteIndex = (numCharBeforeShort + index-1);
- }
-
- }
- else if (token == OBRACKET) {
- numObrackets++;
- parmExists = true;
- StringBuffer numBuffer = null;
- if (index < getShortMessage().length()) {
- numBuffer = new StringBuffer();
- while (index < getShortMessage().length()) {
- char digit = getShortMessage().charAt(index);
- if ((Character.isDigit(digit)) || (digit == '-') || (digit == '+')) {
- numBuffer.append(digit);
- index++;
- }
- else {
- break;
- }
- }
- }
- else {
- // not an error; just not a number. Could be one of the other
- // ChoiceFormat, or whatever, formats. Do not get the next
- // token, because we still need to process this one.
- continue;
- }
-
- try {
- if ((numBuffer != null) && (numBuffer.length() > 0)) {
- Integer parmNum = Integer.valueOf(numBuffer.toString());
- intList.add(parmNum);
- }
- }
- catch (NumberFormatException exc) {
- // not an error; just not a number. Could be one of the other
- // ChoiceFormat, or whatever, formats. Do not get the next
- // token, because we still need to process this one.
- }
- }
- else if (token == CBRACKET) {
- numCbrackets++;
- }
- }
-
- _numParms = Math.max(numObrackets, numCbrackets);
-
- // find parse warnings
- List messages = new ArrayList();
- if (numObrackets != numCbrackets) {
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.ERROR, IValidationConstants.ABCD0000, new String[]{String.valueOf(numObrackets), String.valueOf(numCbrackets)}, this, getLineNumber());
- messages.add(mmd);
- }
-
- if(missingTerminatingQuoteIndex != -1) {
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.INFO, IValidationConstants.ABCD0110, new String[]{String.valueOf(missingTerminatingQuoteIndex)}, this, getLineNumber(), getOffset() + missingTerminatingQuoteIndex, 1); // magic number 1 because a quote is one character long
- messages.add(mmd);
- }
-
- // Now sort the list, to see if there's any numbers missing, duplicated, or negative
- Collections.sort(intList, new Comparator() {
- public int compare(Object a, Object b) {
- // negative = b before a
- // zero = a = b
- // positive = a before b
- return ((Integer) a).intValue() - ((Integer) b).intValue();
- }
- });
- Iterator iterator = intList.iterator();
- int parmCount = 0;
- int lastNumber = -1;
- int largestNumber = -1;
- while (iterator.hasNext()) {
- Integer parm = (Integer) iterator.next();
- if (parm.intValue() < 0) {
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.ERROR, IValidationConstants.ABCD0010E, new String[]{String.valueOf(parm.intValue())}, this, getLineNumber());
- messages.add(mmd);
- }
- else if (parm.intValue() == lastNumber) {
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.INFO, IValidationConstants.ABCD0020, new String[]{String.valueOf(lastNumber)}, this, getLineNumber());
- messages.add(mmd);
- }
- else if (parm.intValue() != parmCount) {
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.INFO, IValidationConstants.ABCD0030, new String[]{String.valueOf(parmCount)}, this, getLineNumber());
- messages.add(mmd);
- }
- else {
- parmCount++;
- }
- lastNumber = parm.intValue();
- largestNumber = Math.max(largestNumber, parm.intValue());
- }
- if(largestNumber > 0) {
- // Not a choice format.
- //
- // Although the first default (counting the number of
- // brackets) is okay in most cases, sometimes a parameter
- // is missing, and so the number of paramters passed into
- // the MessageFormat needs to be larger. (e.g. {0} {2},
- // need String[] to be {"", "", ""}, not {"", ""}).
-
- // Need to add "1" to it because the numbers start at a 0 index.
- _numParms = largestNumber + 1;
- }
-
- if(largestNumber > 9) {
- // MessageFormat will not substitute in parameters after the 10 parameter (i.e., number 9).
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.WARNING, IValidationConstants.ABCD0010W, new String[]{String.valueOf(largestNumber)}, this, getLineNumber());
- messages.add(mmd);
- }
-
- if ((singleQuoteIndex > -1) && parmExists) {
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.INFO, IValidationConstants.ABCD0040, new String[]{String.valueOf(singleQuoteIndex)}, this, getLineNumber(), getOffset() + singleQuoteIndex, 1); // magic number 1 because a quote is one character long
- messages.add(mmd);
- }
- else if ((doubleQuoteIndex > -1) && !parmExists) {
- MessageMetaData mmd = new MessageMetaData(IValidationConstants.BUNDLENAME, MessageMetaData.INFO, IValidationConstants.ABCD0050, new String[]{String.valueOf(doubleQuoteIndex)}, this, getLineNumber(), getOffset() + doubleQuoteIndex, 1); // magic number 1 because a quote is one character long
- messages.add(mmd);
- }
-
- return messages;
- }
-
- /**
- * Format this .properties line for display.
- */
- public String toString() {
- StringBuffer buffer = null;
- if(getFile() == null) {
- buffer = new StringBuffer();
- }
- else {
- buffer = new StringBuffer(getFile().getQualifiedFileName());
- }
- buffer.append("\tLine number: "); //$NON-NLS-1$
- buffer.append(String.valueOf(getLineNumber()));
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(getMessageId());
- buffer.append(" = "); //$NON-NLS-1$
- buffer.append(getMessage());
- return buffer.toString();
- }
-
- /**
- * Format this .properties line for display, and substitute a stub,
- * of the specified length, into each java.text.MessageFormat pattern.
- */
- public String toStringWithExpectedLength(int length) {
- StringBuffer buffer = null;
- if(getFile() == null) {
- buffer = new StringBuffer();
- }
- else {
- buffer = new StringBuffer(getFile().getQualifiedFileName());
- }
- buffer.append("\tLine number: "); //$NON-NLS-1$
- buffer.append(String.valueOf(getLineNumber()));
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(getMessageId());
- buffer.append(" = "); //$NON-NLS-1$
- buffer.append(getExpectedMessage(length));
- return buffer.toString();
- }
-
- /**
- * Return the message prefix without the severity, e.g.,
- * ABCD0000 instead of ABCD0000E.
- */
- public String getShortMessagePrefix() {
- String prefix = getMessagePrefix();
- if(prefix.equals("")) { //$NON-NLS-1$
- return ""; //$NON-NLS-1$
- }
-
- char prefixEnd = prefix.charAt(prefix.length() - 1);
- if ((prefixEnd == 'E') || (prefixEnd == 'W') || (prefixEnd == 'I')) {
- prefix = prefix.substring(0, prefix.length() - 1);
- }
- return prefix;
- }
-
- /**
- * A PropertyLine is equal if it is in the same file and on the same line number.
- */
- public boolean equals(Object o) {
- if(o == null) {
- return false;
- }
-
- if(!(o instanceof PropertyLine)) {
- return false;
- }
-
- PropertyLine oLine = (PropertyLine)o;
- if(!(getLineNumber() == oLine.getLineNumber())) {
- return false;
- }
-
- if(!getFile().equals(oLine.getFile())) {
- return false;
- }
-
- return true;
- }
-
- public int hashCode() {
- return (getFile().hashCode() + getLineNumber());
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyLineComparator.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyLineComparator.java
deleted file mode 100644
index 7daad29a..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/PropertyLineComparator.java
+++ /dev/null
@@ -1,254 +0,0 @@
-package org.eclipse.jst.validation.sample.parser;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.util.Comparator;
-
-/**
- * This class contains all of the Comparator classes that can be used
- * to sort PropertyLine instances in an APropertyFile. (For example,
- * to find duplicate message ids, the MessageIdComparator would be used
- * to sort the lines according to message id. The sorted list is
- * traversed to find out if one line has an identical message id
- * to the line that follows it, and if so, a parse warning is reported.)
- */
-public class PropertyLineComparator {
- private static PropertyLineComparator inst = new PropertyLineComparator();
-
- private static final Comparator _messagePrefixComparator = inst.new MessagePrefixComparator();
- private static final Comparator _messageIdComparator = inst.new MessageIdComparator();
- private static Comparator _stringLengthComparator = new StringLengthComparator();
- private static final Comparator _valueComparator = inst.new ValueComparator();
- private static final Comparator _lineNoComparator = inst.new LineNoComparator();
-
- private PropertyLineComparator() {
- }
-
- /**
- * This class compares PropertyLine instances and sorts them according to
- * their message prefix (e.g., ABCD0000E).
- */
- private class MessagePrefixComparator implements java.util.Comparator {
- public int compare(Object a, Object b) {
- if((a == null) && (b == null)) {
- return 0;
- }
- else if(a == null) {
- return -1;
- }
- else if(b == null) {
- return 1;
- }
-
- // Can't just look to see if they're the same; need to mark
- // them as the same even if the last letter (E|W|I) is different.
- String aid = ((PropertyLine) a).getMessagePrefix();
- String bid = ((PropertyLine) b).getMessagePrefix();
- if((aid == null) && (bid == null)) {
- return 0;
- }
- else if(aid == null) {
- return -1;
- }
- else if(bid == null) {
- return 1;
- }
-
- aid = aid.toUpperCase().trim();
- bid = bid.toUpperCase().trim();
-
- if((aid.equals("")) && (bid.equals(""))) { //$NON-NLS-1$ //$NON-NLS-2$
- return 0;
- }
- else if(aid.equals("")) { //$NON-NLS-1$
- return -1;
- }
- else if(bid.equals("")) { //$NON-NLS-1$
- return 1;
- }
-
- return ((PropertyLine)a).getShortMessagePrefix().toUpperCase().compareTo(((PropertyLine)b).getShortMessagePrefix().toUpperCase());
- }
- }
-
- /**
- * This comparator sorts PropertyLine by their message id.
- */
- private class MessageIdComparator implements java.util.Comparator {
- public int compare(Object a, Object b) {
- if((a == null) && (b == null)) {
- return 0;
- }
- else if(a == null) {
- return -1;
- }
- else if(b == null) {
- return 1;
- }
-
- String aMessageId = null;
- String bMessageId = null;
- if(a instanceof PropertyLine) {
- aMessageId = ((PropertyLine)a).getMessageId();
- }
- else {
- aMessageId = (String)a;
- }
-
- if(b instanceof PropertyLine) {
- bMessageId = ((PropertyLine)b).getMessageId();
- }
- else {
- bMessageId = (String)b;
- }
-
-
- if((aMessageId == null) && (bMessageId == null)) {
- return 0;
- }
- else if(aMessageId == null) {
- return -1;
- }
- else if(bMessageId == null) {
- return 1;
- }
- else {
- return aMessageId.compareTo(bMessageId);
- }
- }
- }
-
- /**
- * Sort the PropertyLine by the length of characters in the message text;
- * if you want to substitute characters for the message parameters,
- * set the length field.
- */
- static class StringLengthComparator implements java.util.Comparator {
- public static int length = 0;
-
- public int compare(Object a, Object b) {
- // return a negative number if object a is less than object b
- // return a zero if the objects are equal
- // return a positive number if object a is greater than object b
- if((a == null) && (b == null)) {
- return 0;
- }
- else if(a == null) {
- return -1;
- }
- else if(b == null) {
- return 1;
- }
-
- int aLength = ((PropertyLine)a).getExpectedLength(length);
- int bLength = ((PropertyLine)b).getExpectedLength(length);
-
- return (aLength - bLength);
- }
- }
-
- /**
- * Alphabetize the message text of the PropertyLine.
- */
- private class ValueComparator implements java.util.Comparator {
- public int compare(Object a, Object b) {
- if((a == null) && (b == null)) {
- return 0;
- }
- else if(a == null) {
- return -1;
- }
- else if(b == null) {
- return 1;
- }
-
- String aMessage = ((PropertyLine)a).getMessage();
- String bMessage = ((PropertyLine)b).getMessage();
- if((aMessage == null) && (bMessage == null)) {
- return 0;
- }
- else if(aMessage == null) {
- return -1;
- }
- else if(bMessage == null) {
- return 1;
- }
-
- return aMessage.compareTo(bMessage);
- }
- }
-
- /**
- * Sort by line number of the PropertyLine, with the smallest line
- * number first in the list.
- */
- private class LineNoComparator implements java.util.Comparator {
- public int compare(Object a, Object b) {
- // return a negative number if object a is less than object b
- // return a zero if the objects are equal
- // return a positive number if object a is greater than object b
- if((a == null) && (b == null)) {
- return 0;
- }
- else if(a == null) {
- return -1;
- }
- else if(b == null) {
- return 1;
- }
-
- int aLineNo = ((PropertyLine)a).getLineNumber();
- int bLineNo = ((PropertyLine)b).getLineNumber();
- if((aLineNo < 0) && (bLineNo < 0)) {
- return 0;
- }
- else if(aLineNo < 0) {
- return -1;
- }
- else if(bLineNo < 0) {
- return 1;
- }
-
- return (aLineNo - bLineNo);
- }
- }
-
- public static Comparator getMessagePrefixComparator() {
- return _messagePrefixComparator;
- }
-
- public static Comparator getMessageIdComparator() {
- return _messageIdComparator;
- }
-
- public static Comparator getStringLengthComparator(int length) {
- StringLengthComparator.length = length;
- return _stringLengthComparator;
- }
-
- public static Comparator getValueComparator() {
- return _valueComparator;
- }
-
- public static Comparator getLineNoComparator() {
- return _lineNoComparator;
- }
-}
-
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/ResourceHandler.java b/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/ResourceHandler.java
deleted file mode 100644
index 4dd7b557..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/org/eclipse/jst/validation/sample/parser/ResourceHandler.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.eclipse.jst.validation.sample.parser;
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * DISCLAIMER OF WARRANTIES.
- * The following [enclosed] code is sample code created by IBM
- * Corporation. This sample code is not part of any standard or IBM
- * product and is provided to you solely for the purpose of assisting
- * you in the development of your applications. The code is provided
- * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
- * THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
- * for any damages arising out of your use of the sample code, even
- * if it has been advised of the possibility of such damages.
- *
- */
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * This class retrieves the Strings from the .properties file appropriate
- * for the machine's Locale.
- */
-public final class ResourceHandler {
- private static ResourceBundle _bundle = null;
-
- private ResourceHandler() {
- super();
- }
-
- /**
- * Return the resource bundle which contains the messages
- * in the resource identified by bundleName.
- */
- private static ResourceBundle getBundle(String bundleName) {
- if (_bundle == null) {
- try {
- _bundle = ResourceBundle.getBundle(bundleName);
- }
- catch (MissingResourceException exc) {
- _bundle = null;
- exc.printStackTrace();
- }
- }
- return _bundle;
- }
-
- /**
- * Given the name of the bundle and the message id (key) into the
- * bundle, return the message text identified by the id.
- */
- public static String getExternalizedMessage(String bundleName, String key) {
- try {
- ResourceBundle bundle = getBundle(bundleName);
- if (bundle == null) {
- return key;
- }
-
- return bundle.getString(key);
- }
- catch (NullPointerException exc) {
- exc.printStackTrace();
- }
- return key;
- }
-
- /**
- * Given the name of the bundle, the message id (key) into the
- * bundle, and parameters to be substituted into the java.text.MessageFormat's
- * patterns, return the message with the parameters substituted in.
- */
- public static String getExternalizedMessage(String bundleName, String key, String[] parms) {
- String res = ""; //$NON-NLS-1$
- try {
- res = java.text.MessageFormat.format(getExternalizedMessage(bundleName, key), parms);
- }
- catch (MissingResourceException exc) {
- exc.printStackTrace();
- }
- catch (NullPointerException exc) {
- exc.printStackTrace();
- }
- return res;
- }
-}
diff --git a/tests/org.eclipse.jst.validation.sample/propertiesValidator/propertiesValidator.properties b/tests/org.eclipse.jst.validation.sample/propertiesValidator/propertiesValidator.properties
deleted file mode 100644
index 43a5bdec..00000000
--- a/tests/org.eclipse.jst.validation.sample/propertiesValidator/propertiesValidator.properties
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Licensed Material - Property of IBM
-# (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
-# US Government Users Restricted Rights - Use, duplication or disclosure
-# restricted by GSA ADP Schedule Contract with IBM Corp.
-#
-# DISCLAIMER OF WARRANTIES.
-# The following [enclosed] code is sample code created by IBM
-# Corporation. This sample code is not part of any standard or IBM
-# product and is provided to you solely for the purpose of assisting
-# you in the development of your applications. The code is provided
-# "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
-# NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
-# THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
-# for any damages arising out of your use of the sample code, even
-# if it has been advised of the possibility of such damages.
-#
-
-ABCD0000 = ABCD0000E: Match the braces in the message. There are {0} '{' and {1} '}'. MessageFormat will throw a NullPointerException when there are mismatching braces.
-ABCD0010E = ABCD0010E: Change argument ('{'{0}'}') to an integer between 0 and 9 inclusive in the message. MessageFormat cannot process an integer parameter that is less than 0.
-ABCD0010W = ABCD0010W: Change argument ('{'{0}'}') to an integer between 0 and 9 inclusive in the message. MessageFormat ignores any parameters larger than 9.
-ABCD0020 = ABCD0020I: Remove redundant parameter '{'{0}'}' from the message. Make messages succinct.
-ABCD0030 = ABCD0030I: Check that argument '{'{0}'}' was omitted from the message deliberately. If it was omitted accidentally, and the code does not provide enough parameters, MessageFormat will throw a NullPointerException.
-ABCD0040 = ABCD0040I: Use two apostrophes in the message at column {0}. MessageFormat removes single apostrophes; for the message to display an apostrophe, two apostrophes must exist in the string. (An apostrophe is a reserved character of MessageFormat.)
-ABCD0050 = ABCD0050I: Use one apostrophe in the message at column {0}. MessageFormat processes only messages with parameters; without MessageFormat, the extra apostrophe will not be removed.
-
-ABCD0060 = ABCD0060W: Make {0} unique. When an id is used more than once in a file, ResourceBundle will use the value of the last message id.
-ABCD0070 = ABCD0070W: {0} may need to be unique. Conventionally, a message prefix applies to only one error condition.
-
-ABCD0080 = ABCD0080E: Fix the syntax error; each line must form MESSAGE_ID = MESSAGE.
-ABCD0090 = ABCD0090W: Check the read permissions of file {0}. The PropertiesValidator either cannot read or cannot find the file.
-
-ABCD0110 = ABCD0110I: Add a terminating apostrophe at column {0}. The '{' and '}' characters must be enclosed in apostrophes.
-
-ABCD0120 = ABCD0120I: Terminate message prefix {0} with a '':''. The IBM standard requires that message prefixes end with a colon.
-ABCD0130 = ABCD0130I: Remove the whitespace between {0} and the '':''. The IBM standard requires an absence of whitespace between the alphanumeric characters and the colon.
-
-# Outside WSAD, append the line number and file name to the end of the message.
-LINE_LOC = Line {0}, file {1}.
-
diff --git a/tests/org.eclipse.jst.validation.sample/test/test.properties b/tests/org.eclipse.jst.validation.sample/test/test.properties
deleted file mode 100644
index 90bc982b..00000000
--- a/tests/org.eclipse.jst.validation.sample/test/test.properties
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# Licensed Material - Property of IBM
-# (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
-# US Government Users Restricted Rights - Use, duplication or disclosure
-# restricted by GSA ADP Schedule Contract with IBM Corp.
-#
-# DISCLAIMER OF WARRANTIES.
-# The following [enclosed] code is sample code created by IBM
-# Corporation. This sample code is not part of any standard or IBM
-# product and is provided to you solely for the purpose of assisting
-# you in the development of your applications. The code is provided
-# "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
-# NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
-# THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
-# for any damages arising out of your use of the sample code, even
-# if it has been advised of the possibility of such damages.
-#
-
-# This file is used to test the Properties Validator.
-#
-
-MISMATCHED_BRACES = This line has '{0}' mismatching braces.
-MISMATCHED_BRACES_2 = This line has { a mismatching brace.
-MISMATCHED_BRACES_3 = This line has } a mismatching brace.
-MISMATCHED_BRACES_OKAY = This line has no '{' mismatching braces '}'.
-MISMATCHED_BRACES_OKAY2 = This line also has no mismatching braces {0} '{' '}'.
-
-TOO_MANY_ARGUMENTS = MessageFormat formats only 10 parameters {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}.
-TOO_MANY_ARGUMENTS_2 = MessageFormat formats only 10 parameters {10}.
-
-NEGATIVE_ARGUMENT = This line uses a negative {-1} argument.
-B = okay
-REDUNDANT_ARGUMENT = This line uses a redundant {0} {0} argument.
-MISSED_PARM = This line uses {0} and {2} but not (1).
-NEEDS_DOUBLE_APOS = This line uses a single apostrophe (') but should use two {0}.
-NEEDS_SINGLE_APOS = This line uses a double apostrophe ('') but should use one.
-A = okay
-SYM
-DUPLICATE_ID = This line uses a duplicate message id.
-DUPLICATE_ID = This line also uses a duplicate message id.
-DUPLICATE_PREFIX = AAAA0000W: This line uses a duplicate message prefix.
-= jjj
-
-DUPLICATE_PREFIX2 = AAAA0000W: This line also uses a duplicate message prefix.
-Z_DUPLICATE = jjj
-Z_DUPLICATE = mmm
-
-# This is a comment
-Z_DUPLICATE = nnn
-C = okay
-F = a \
-b \
-c
-D = okay
-
-CASE1 = ABCD0000E: Blah Blah Blah
-CASE2 = ABCD0000E Blah Blah Blah
-CASE3 = ABCD0000E : Blah Blah Blah
-CASE4 = ABCD0000E Blah:Blah Blah
-CASE5 = ABCD0000E :
-CASE6 = Blah Blah Blah (i.e., no prefix)
-CASE7 = ABCD0000E: Blah
-CASE8 = ABCD0000E Blah
-CASE9 = ABCD0000E : Blah
-CASE10 = ABCD0000E Blah
-CASE11 = ABCD0000E
diff --git a/tests/org.eclipse.jst.validation.sample/test/test2.properties b/tests/org.eclipse.jst.validation.sample/test/test2.properties
deleted file mode 100644
index fdc0f329..00000000
--- a/tests/org.eclipse.jst.validation.sample/test/test2.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed Material - Property of IBM
-# (C) Copyright IBM Corp. 2002, 2003 - All Rights Reserved.
-# US Government Users Restricted Rights - Use, duplication or disclosure
-# restricted by GSA ADP Schedule Contract with IBM Corp.
-#
-# DISCLAIMER OF WARRANTIES.
-# The following [enclosed] code is sample code created by IBM
-# Corporation. This sample code is not part of any standard or IBM
-# product and is provided to you solely for the purpose of assisting
-# you in the development of your applications. The code is provided
-# "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
-# NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
-# THIS CODE. THIS CODE MAY CONTAIN ERRORS. IBM shall not be liable
-# for any damages arising out of your use of the sample code, even
-# if it has been advised of the possibility of such damages.
-#
-
-#
-# This file is used to test the Properties Validator.
-#
-
-ID1 = This file has no errors in it. \ No newline at end of file
diff --git a/tests/org.eclipse.jst.validation.sample/tvtplugin.xml b/tests/org.eclipse.jst.validation.sample/tvtplugin.xml
deleted file mode 100644
index a5250a3c..00000000
--- a/tests/org.eclipse.jst.validation.sample/tvtplugin.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<plugin
- id="com.ibm.etools.validation.prop"
- name="Properties Validator"
- version="5.1.0"
- class="com.ibm.etools.validation.properties.workbenchimpl.PropertiesValidatorPlugin">
-
- <!--=================================================================-->
- <!-- When testing TVT in EJBDeploy, because org.eclipse.help isn't -->
- <!-- packaged with EJBDeploy, this plugin is deactivated. However, -->
- <!-- because the TVT plugin doesn't ship the documentation, all -->
- <!-- references to the help can be removed. -->
- <!--=================================================================-->
-
- <runtime>
- <library name="runtime/propertiesValidator.jar">
- <export name="*"/>
- </library>
- <library name="runtime/propertiesValFS.jar">
- <export name="*"/>
- </library>
- <library name="runtime/propertiesValWB.jar">
- <export name="*"/>
- </library>
- <library name="runtime/filesystemFWK.jar">
- <export name="*"/>
- </library>
- </runtime>
-
- <requires>
- <import plugin="org.eclipse.core.runtime" version="2.1" match="equivalent"/>
- <import plugin="org.eclipse.core.resources" version="2.1" match="equivalent"/>
- <import plugin="org.eclipse.jdt.core" version="2.1" match="equivalent"/>
- <import plugin="com.ibm.etools.validation" export="true" version="5.1" match="equivalent"/>
- <import plugin="com.ibm.etools.logging.util" version="5.1" match="equivalent"/>
- </requires>
-
- <!--=======================================-->
- <!-- Properties Validator Contributions -->
- <!--=======================================-->
- <extension
- id="PropertiesValidator"
- name="Properties Validator"
- point="com.ibm.etools.validation.validator">
- <validator>
- <projectNature id="org.eclipse.jdt.core.javanature"/>
- <filter objectClass="org.eclipse.core.resources.IFile" nameFilter="*.properties" action="add, change"/>
- <run class="com.ibm.etools.validation.properties.PropertiesValidator" enabled="false" async="true"/>
- <helper class="com.ibm.etools.validation.properties.workbenchimpl.PropertiesHelper"/>
- </validator>
- </extension>
-</plugin>

Back to the top