You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by ma...@apache.org on 2006/07/25 02:17:33 UTC
svn commit: r425260 [4/7] - in
/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins:
maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/io/
maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin...
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Filter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/FilteredIterator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/FilteredIterator.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/FilteredIterator.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/FilteredIterator.java Mon Jul 24 19:17:31 2006
@@ -13,58 +13,58 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces.util;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-public class FilteredIterator implements Iterator
-{
- public FilteredIterator(
- Iterator iter,
- Filter filter)
- {
- _iter = iter;
- _filter = filter;
- _advance();
- }
-
- public boolean hasNext()
- {
- return (_next != null);
- }
-
- public Object next()
- {
- if (_next == null)
- throw new NoSuchElementException();
-
- Object obj = _next;
- _advance();
- return obj;
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- private void _advance()
- {
- while (_iter.hasNext())
- {
- Object obj = _iter.next();
- if (_filter.accept(obj))
- {
- _next = obj;
- return;
- }
- }
-
- _next = null;
- }
-
- private final Iterator _iter;
- private final Filter _filter;
- private Object _next;
-}
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+public class FilteredIterator implements Iterator
+{
+ public FilteredIterator(
+ Iterator iter,
+ Filter filter)
+ {
+ _iter = iter;
+ _filter = filter;
+ _advance();
+ }
+
+ public boolean hasNext()
+ {
+ return (_next != null);
+ }
+
+ public Object next()
+ {
+ if (_next == null)
+ throw new NoSuchElementException();
+
+ Object obj = _next;
+ _advance();
+ return obj;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private void _advance()
+ {
+ while (_iter.hasNext())
+ {
+ Object obj = _iter.next();
+ if (_filter.accept(obj))
+ {
+ _next = obj;
+ return;
+ }
+ }
+
+ _next = null;
+ }
+
+ private final Iterator _iter;
+ private final Filter _filter;
+ private Object _next;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/FilteredIterator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/PropertyFilter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/PropertyFilter.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/PropertyFilter.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/PropertyFilter.java Mon Jul 24 19:17:31 2006
@@ -13,18 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces.util;
-
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
-
-abstract public class PropertyFilter implements Filter
-{
- final public boolean accept(
- Object obj)
- {
- return accept((PropertyBean)obj);
- }
-
- abstract protected boolean accept(
- PropertyBean property);
-}
+
+abstract public class PropertyFilter implements Filter
+{
+ final public boolean accept(
+ Object obj)
+ {
+ return accept((PropertyBean)obj);
+ }
+
+ abstract protected boolean accept(
+ PropertyBean property);
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/PropertyFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/RendererFilter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/RendererFilter.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/RendererFilter.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/RendererFilter.java Mon Jul 24 19:17:31 2006
@@ -13,18 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces.util;
-
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.RendererBean;
-
-abstract public class RendererFilter implements Filter
-{
- final public boolean accept(
- Object obj)
- {
- return accept((RendererBean)obj);
- }
-
- abstract protected boolean accept(
- RendererBean renderer);
-}
+
+abstract public class RendererFilter implements Filter
+{
+ final public boolean accept(
+ Object obj)
+ {
+ return accept((RendererBean)obj);
+ }
+
+ abstract protected boolean accept(
+ RendererBean renderer);
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/RendererFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SortedIterator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SortedIterator.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SortedIterator.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SortedIterator.java Mon Jul 24 19:17:31 2006
@@ -13,46 +13,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Collections;
-
-/**
- * SortedIterator presents the elements of another iterator in a sorted order.
- */
-public class SortedIterator implements Iterator
-{
- public SortedIterator(
- Iterator unsorted)
- {
- // this implementation just pulls the entire contents into a list --
- // it will be awkward if the unsorted iterator is infinite
- ArrayList sortedList = new ArrayList();
- while(unsorted.hasNext())
- {
- sortedList.add(unsorted.next());
- }
- Collections.sort(sortedList);
- _sorted = sortedList.iterator();
- }
-
- public boolean hasNext()
- {
- return _sorted.hasNext();
- }
-
- public Object next()
- {
- return _sorted.next();
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- private final Iterator _sorted;
-
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Collections;
+
+/**
+ * SortedIterator presents the elements of another iterator in a sorted order.
+ */
+public class SortedIterator implements Iterator
+{
+ public SortedIterator(
+ Iterator unsorted)
+ {
+ // this implementation just pulls the entire contents into a list --
+ // it will be awkward if the unsorted iterator is infinite
+ ArrayList sortedList = new ArrayList();
+ while(unsorted.hasNext())
+ {
+ sortedList.add(unsorted.next());
+ }
+ Collections.sort(sortedList);
+ _sorted = sortedList.iterator();
+ }
+
+ public boolean hasNext()
+ {
+ return _sorted.hasNext();
+ }
+
+ public Object next()
+ {
+ return _sorted.next();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private final Iterator _sorted;
+
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SortedIterator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java Mon Jul 24 19:17:31 2006
@@ -13,147 +13,147 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces.util;
-
-import java.io.BufferedReader;
-import java.io.EOFException;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Writer;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-public class SourceTemplate
-{
- public SourceTemplate(File file)
- {
- _file = file;
- }
-
- public void substitute(String in, String out)
- {
- _substitutions.put(in, out);
- }
-
- public Set getImports()
- {
- return Collections.unmodifiableSet(_imports);
- }
-
- public Set getImplements()
- {
- return Collections.unmodifiableSet(_implements);
- }
-
- public void readPreface() throws IOException
- {
- _reader = new BufferedReader(new FileReader(_file));
- while (true)
- {
- String line = _reader.readLine();
- if (line == null)
- throw new EOFException("File " + _file + " ended prematurely");
-
- if (line.equals("{"))
- break;
-
- if (line.startsWith("import "))
- {
- line = line.trim();
- String imported = line.substring("import ".length(),
- line.length() - 1);
- _imports.add(imported);
- _fqcnMap.put(Util.getClassFromFullClass(imported), imported);
- }
-
- int index = line.indexOf(" implements ");
- if (index != -1)
- {
- String clause = line.substring(index + " implements ".length());
- String[] interfaces = clause.split(", ");
- for (int i=0; i < interfaces.length; i++)
- {
- String className = interfaces[i];
- if (!Util.isFullClass(className))
- {
- String importedName = (String)_fqcnMap.get(className);
- if (importedName != null)
- className = importedName;
- }
- _implements.add(className);
- }
- }
- }
- }
-
-
- public void writeContent(Writer out) throws IOException
- {
- while (true)
- {
- String line = _reader.readLine();
- if (line == null)
- throw new EOFException("File " + _file + " ended prematurely");
-
- if (line.startsWith(_IGNORE_PREFIX))
- continue;
-
- if (line.equals("}"))
- break;
-
- line = _substitute(line);
- out.write(line);
- out.write("\n");
- }
- }
-
- public void close() throws IOException
- {
- _reader.close();
- }
-
- private String _substitute(String in)
- {
- Iterator keys = _substitutions.keySet().iterator();
- while (keys.hasNext())
- {
- String key = (String) keys.next();
- String value = (String) _substitutions.get(key);
- in = _substitute(in, key, value);
- }
-
- return in;
- }
-
- static private String _substitute(String in, String from, String to)
- {
- int index = in.indexOf(from);
- if (index < 0)
- return in;
-
- StringBuffer buffer = new StringBuffer(in.length() +
- to.length() - from.length());
- buffer.append(in.substring(0, index));
- buffer.append(to);
- String suffix = in.substring(index + from.length());
- buffer.append(_substitute(suffix, from, to));
-
- return buffer.toString();
- }
-
- private File _file;
- private BufferedReader _reader;
- private Set _imports = new HashSet();
- private Map _fqcnMap = new HashMap();
- private Set _implements = new HashSet();
- private Map _substitutions = new HashMap();
-
- // Magic syntax indicating "please ignore this line"
- static private final String _IGNORE_PREFIX = "/**/";
-}
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
+import java.io.BufferedReader;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Writer;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+public class SourceTemplate
+{
+ public SourceTemplate(File file)
+ {
+ _file = file;
+ }
+
+ public void substitute(String in, String out)
+ {
+ _substitutions.put(in, out);
+ }
+
+ public Set getImports()
+ {
+ return Collections.unmodifiableSet(_imports);
+ }
+
+ public Set getImplements()
+ {
+ return Collections.unmodifiableSet(_implements);
+ }
+
+ public void readPreface() throws IOException
+ {
+ _reader = new BufferedReader(new FileReader(_file));
+ while (true)
+ {
+ String line = _reader.readLine();
+ if (line == null)
+ throw new EOFException("File " + _file + " ended prematurely");
+
+ if (line.equals("{"))
+ break;
+
+ if (line.startsWith("import "))
+ {
+ line = line.trim();
+ String imported = line.substring("import ".length(),
+ line.length() - 1);
+ _imports.add(imported);
+ _fqcnMap.put(Util.getClassFromFullClass(imported), imported);
+ }
+
+ int index = line.indexOf(" implements ");
+ if (index != -1)
+ {
+ String clause = line.substring(index + " implements ".length());
+ String[] interfaces = clause.split(", ");
+ for (int i=0; i < interfaces.length; i++)
+ {
+ String className = interfaces[i];
+ if (!Util.isFullClass(className))
+ {
+ String importedName = (String)_fqcnMap.get(className);
+ if (importedName != null)
+ className = importedName;
+ }
+ _implements.add(className);
+ }
+ }
+ }
+ }
+
+
+ public void writeContent(Writer out) throws IOException
+ {
+ while (true)
+ {
+ String line = _reader.readLine();
+ if (line == null)
+ throw new EOFException("File " + _file + " ended prematurely");
+
+ if (line.startsWith(_IGNORE_PREFIX))
+ continue;
+
+ if (line.equals("}"))
+ break;
+
+ line = _substitute(line);
+ out.write(line);
+ out.write("\n");
+ }
+ }
+
+ public void close() throws IOException
+ {
+ _reader.close();
+ }
+
+ private String _substitute(String in)
+ {
+ Iterator keys = _substitutions.keySet().iterator();
+ while (keys.hasNext())
+ {
+ String key = (String) keys.next();
+ String value = (String) _substitutions.get(key);
+ in = _substitute(in, key, value);
+ }
+
+ return in;
+ }
+
+ static private String _substitute(String in, String from, String to)
+ {
+ int index = in.indexOf(from);
+ if (index < 0)
+ return in;
+
+ StringBuffer buffer = new StringBuffer(in.length() +
+ to.length() - from.length());
+ buffer.append(in.substring(0, index));
+ buffer.append(to);
+ String suffix = in.substring(index + from.length());
+ buffer.append(_substitute(suffix, from, to));
+
+ return buffer.toString();
+ }
+
+ private File _file;
+ private BufferedReader _reader;
+ private Set _imports = new HashSet();
+ private Map _fqcnMap = new HashMap();
+ private Set _implements = new HashSet();
+ private Map _substitutions = new HashMap();
+
+ // Magic syntax indicating "please ignore this line"
+ static private final String _IGNORE_PREFIX = "/**/";
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java Mon Jul 24 19:17:31 2006
@@ -13,300 +13,300 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces.util;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.Set;
-import java.util.TreeSet;
-
-public class Util
-{
- static public String convertClassToSourcePath(
- String className,
- String fileExtension)
- {
- return (className.replace('.', File.separatorChar) + fileExtension);
- }
-
- static public boolean isFullClass(
- String className)
- {
- return (className != null && className.indexOf('.') != -1);
- }
-
- static public String getClassFromFullClass(
- String fullClass)
- {
- if (fullClass == null)
- return null;
-
- int lastSep = fullClass.lastIndexOf('.');
-
- // Note: this code also works for the empty package
- return (fullClass.substring(lastSep + 1));
- }
-
- static public String getPackageFromFullClass(
- String fullClass)
- {
- if (fullClass == null)
- return null;
-
- int lastSep = fullClass.lastIndexOf('.');
-
- // detect the empty package
- if (lastSep == -1)
- return "";
-
- return (fullClass.substring(0, lastSep));
- }
-
- static public String getConstantNameFromProperty(
- String propertyName)
- {
- return getConstantNameFromProperty(propertyName, null);
- }
-
- static public String getConstantNameFromProperty(
- String propertyName,
- String constantSuffix)
- {
- StringBuffer constantName = new StringBuffer();
-
- for (int i=0; i < propertyName.length(); i++)
- {
- char ch = propertyName.charAt(i);
- if (i > 0 &&
- Character.isUpperCase(ch) &&
- Character.isLowerCase(propertyName.charAt(i-1)))
- {
- constantName.append('_');
- }
- ch = Character.toUpperCase(ch);
- constantName.append(ch);
- }
-
- if (constantSuffix != null)
- constantName.append(constantSuffix);
-
- return constantName.toString();
- }
-
- static public String getPrefixedPropertyName(
- String prefix,
- String propertyName)
- {
- return prefix + Character.toUpperCase(propertyName.charAt(0)) +
- propertyName.substring(1);
- }
-
- static public String getMethodNameFromEvent(
- String methodPrefix,
- String eventName,
- String methodSuffix)
- {
- return methodPrefix +
- Character.toUpperCase(eventName.charAt(0)) +
- eventName.substring(1) +
- methodSuffix;
- }
-
- static public String getMethodReaderFromProperty(
- String propertyName,
- String propertyClass)
- {
- String methodPrefix = ("boolean".equals(propertyClass) ? "is" : "get");
- return getPrefixedPropertyName(methodPrefix, propertyName);
- }
-
- static public String getEventNameFromEventType(
- String eventFullClass)
- {
- String eventName = getClassFromFullClass(eventFullClass);
- return Character.toLowerCase(eventName.charAt(0)) +
- eventName.substring(1, eventName.length());
- }
-
- static public boolean isPrimitiveClass(
- String className)
- {
- return "boolean".equals(className) ||
- "byte".equals(className) ||
- "char".equals(className) ||
- "double".equals(className) ||
- "float".equals(className) ||
- "int".equals(className) ||
- "long".equals(className) ||
- "short".equals(className);
- }
-
- static public String getBoxedClass(
- String className)
- {
- if ("boolean".equals(className))
- return "Boolean";
- else if ("byte".equals(className))
- return "Byte";
- else if ("char".equals(className))
- return "Character";
- else if ("double".equals(className))
- return "Double";
- else if ("float".equals(className))
- return "Float";
- else if ("int".equals(className))
- return "Integer";
- else if ("long".equals(className))
- return "Long";
- else if ("short".equals(className))
- return "Short";
- else
- return className;
- }
-
- static public String fill(
- String base,
- int length)
- {
- if (base == null || base.length() > length)
- return base;
-
- StringBuffer filled = new StringBuffer(base);
- for (int i=base.length(); i < length; i++)
- {
- filled.append(' ');
- }
- return filled.toString();
- }
-
- static public String getVariableFromClass(
- String className)
- {
- if (className == null)
- return null;
-
- for (int i=0; i < className.length(); i++)
- {
- char ch = className.charAt(i);
- if (Character.isLowerCase(ch))
- {
- if (i > 0)
- {
- return Character.toLowerCase(className.charAt(i - 1)) +
- className.substring(i);
- }
- break;
- }
- }
-
- throw new IllegalStateException("Class name \"" + className +
- "\" does not use initcaps");
- }
-
- static public String getVariableFromName(
- String name)
- {
- if (name == null)
- return null;
-
- if (RESERVED_WORDS.contains(name))
- name = name + "Param";
-
- return name;
- }
-
- static private Set _createPrimitiveTypesSet()
- {
- Set primitives = new TreeSet();
- for (int i=0; i < _PRIMITIVE_TYPES.length; i++)
- {
- String type = _PRIMITIVE_TYPES[i];
- primitives.add(type);
- primitives.add(type + "[]");
- }
- return Collections.unmodifiableSet(primitives);
- }
-
- static private Set _createReservedWordsSet()
- {
- Set reserved = new TreeSet();
- for (int i=0; i < _RESERVED_WORDS.length; i++)
- {
- String keyword = _RESERVED_WORDS[i];
- reserved.add(keyword);
- }
- return Collections.unmodifiableSet(reserved);
- }
-
- static private final String[] _PRIMITIVE_TYPES = new String[]
- {
- "boolean",
- "byte",
- "char",
- "float",
- "double",
- "int",
- "short",
- "long",
- };
-
- static private final String[] _RESERVED_WORDS = new String[]
- {
- "abstract",
- "assert",
- "boolean",
- "break",
- "byte",
- "case",
- "catch",
- "char",
- "class",
- "const",
- "continue",
- "default",
- "do",
- "double",
- "else",
- "extends",
- "final",
- "finally",
- "float",
- "for",
- "goto",
- "if",
- "implements",
- "import",
- "instanceof",
- "int",
- "interface",
- "long",
- "native",
- "new",
- "package",
- "private",
- "protected",
- "public",
- "return",
- "short",
- "static",
- "super",
- "switch",
- "synchronized",
- "this",
- "throw",
- "throws",
- "transient",
- "try",
- "void",
- "volatile",
- "while",
- };
-
- static public final Set RESERVED_WORDS = _createReservedWordsSet();
- static public final Set PRIMITIVE_TYPES = _createPrimitiveTypesSet();
-
- // no instances
- private Util()
- {
- }
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Set;
+import java.util.TreeSet;
+
+public class Util
+{
+ static public String convertClassToSourcePath(
+ String className,
+ String fileExtension)
+ {
+ return (className.replace('.', File.separatorChar) + fileExtension);
+ }
+
+ static public boolean isFullClass(
+ String className)
+ {
+ return (className != null && className.indexOf('.') != -1);
+ }
+
+ static public String getClassFromFullClass(
+ String fullClass)
+ {
+ if (fullClass == null)
+ return null;
+
+ int lastSep = fullClass.lastIndexOf('.');
+
+ // Note: this code also works for the empty package
+ return (fullClass.substring(lastSep + 1));
+ }
+
+ static public String getPackageFromFullClass(
+ String fullClass)
+ {
+ if (fullClass == null)
+ return null;
+
+ int lastSep = fullClass.lastIndexOf('.');
+
+ // detect the empty package
+ if (lastSep == -1)
+ return "";
+
+ return (fullClass.substring(0, lastSep));
+ }
+
+ static public String getConstantNameFromProperty(
+ String propertyName)
+ {
+ return getConstantNameFromProperty(propertyName, null);
+ }
+
+ static public String getConstantNameFromProperty(
+ String propertyName,
+ String constantSuffix)
+ {
+ StringBuffer constantName = new StringBuffer();
+
+ for (int i=0; i < propertyName.length(); i++)
+ {
+ char ch = propertyName.charAt(i);
+ if (i > 0 &&
+ Character.isUpperCase(ch) &&
+ Character.isLowerCase(propertyName.charAt(i-1)))
+ {
+ constantName.append('_');
+ }
+ ch = Character.toUpperCase(ch);
+ constantName.append(ch);
+ }
+
+ if (constantSuffix != null)
+ constantName.append(constantSuffix);
+
+ return constantName.toString();
+ }
+
+ static public String getPrefixedPropertyName(
+ String prefix,
+ String propertyName)
+ {
+ return prefix + Character.toUpperCase(propertyName.charAt(0)) +
+ propertyName.substring(1);
+ }
+
+ static public String getMethodNameFromEvent(
+ String methodPrefix,
+ String eventName,
+ String methodSuffix)
+ {
+ return methodPrefix +
+ Character.toUpperCase(eventName.charAt(0)) +
+ eventName.substring(1) +
+ methodSuffix;
+ }
+
+ static public String getMethodReaderFromProperty(
+ String propertyName,
+ String propertyClass)
+ {
+ String methodPrefix = ("boolean".equals(propertyClass) ? "is" : "get");
+ return getPrefixedPropertyName(methodPrefix, propertyName);
+ }
+
+ static public String getEventNameFromEventType(
+ String eventFullClass)
+ {
+ String eventName = getClassFromFullClass(eventFullClass);
+ return Character.toLowerCase(eventName.charAt(0)) +
+ eventName.substring(1, eventName.length());
+ }
+
+ static public boolean isPrimitiveClass(
+ String className)
+ {
+ return "boolean".equals(className) ||
+ "byte".equals(className) ||
+ "char".equals(className) ||
+ "double".equals(className) ||
+ "float".equals(className) ||
+ "int".equals(className) ||
+ "long".equals(className) ||
+ "short".equals(className);
+ }
+
+ static public String getBoxedClass(
+ String className)
+ {
+ if ("boolean".equals(className))
+ return "Boolean";
+ else if ("byte".equals(className))
+ return "Byte";
+ else if ("char".equals(className))
+ return "Character";
+ else if ("double".equals(className))
+ return "Double";
+ else if ("float".equals(className))
+ return "Float";
+ else if ("int".equals(className))
+ return "Integer";
+ else if ("long".equals(className))
+ return "Long";
+ else if ("short".equals(className))
+ return "Short";
+ else
+ return className;
+ }
+
+ static public String fill(
+ String base,
+ int length)
+ {
+ if (base == null || base.length() > length)
+ return base;
+
+ StringBuffer filled = new StringBuffer(base);
+ for (int i=base.length(); i < length; i++)
+ {
+ filled.append(' ');
+ }
+ return filled.toString();
+ }
+
+ static public String getVariableFromClass(
+ String className)
+ {
+ if (className == null)
+ return null;
+
+ for (int i=0; i < className.length(); i++)
+ {
+ char ch = className.charAt(i);
+ if (Character.isLowerCase(ch))
+ {
+ if (i > 0)
+ {
+ return Character.toLowerCase(className.charAt(i - 1)) +
+ className.substring(i);
+ }
+ break;
+ }
+ }
+
+ throw new IllegalStateException("Class name \"" + className +
+ "\" does not use initcaps");
+ }
+
+ static public String getVariableFromName(
+ String name)
+ {
+ if (name == null)
+ return null;
+
+ if (RESERVED_WORDS.contains(name))
+ name = name + "Param";
+
+ return name;
+ }
+
+ static private Set _createPrimitiveTypesSet()
+ {
+ Set primitives = new TreeSet();
+ for (int i=0; i < _PRIMITIVE_TYPES.length; i++)
+ {
+ String type = _PRIMITIVE_TYPES[i];
+ primitives.add(type);
+ primitives.add(type + "[]");
+ }
+ return Collections.unmodifiableSet(primitives);
+ }
+
+ static private Set _createReservedWordsSet()
+ {
+ Set reserved = new TreeSet();
+ for (int i=0; i < _RESERVED_WORDS.length; i++)
+ {
+ String keyword = _RESERVED_WORDS[i];
+ reserved.add(keyword);
+ }
+ return Collections.unmodifiableSet(reserved);
+ }
+
+ static private final String[] _PRIMITIVE_TYPES = new String[]
+ {
+ "boolean",
+ "byte",
+ "char",
+ "float",
+ "double",
+ "int",
+ "short",
+ "long",
+ };
+
+ static private final String[] _RESERVED_WORDS = new String[]
+ {
+ "abstract",
+ "assert",
+ "boolean",
+ "break",
+ "byte",
+ "case",
+ "catch",
+ "char",
+ "class",
+ "const",
+ "continue",
+ "default",
+ "do",
+ "double",
+ "else",
+ "extends",
+ "final",
+ "finally",
+ "float",
+ "for",
+ "goto",
+ "if",
+ "implements",
+ "import",
+ "instanceof",
+ "int",
+ "interface",
+ "long",
+ "native",
+ "new",
+ "package",
+ "private",
+ "protected",
+ "public",
+ "return",
+ "short",
+ "static",
+ "super",
+ "switch",
+ "synchronized",
+ "this",
+ "throw",
+ "throws",
+ "transient",
+ "try",
+ "void",
+ "volatile",
+ "while",
+ };
+
+ static public final Set RESERVED_WORDS = _createReservedWordsSet();
+ static public final Set PRIMITIVE_TYPES = _createPrimitiveTypesSet();
+
+ // no instances
+ private Util()
+ {
+ }
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ValidatorFilter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ValidatorFilter.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ValidatorFilter.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ValidatorFilter.java Mon Jul 24 19:17:31 2006
@@ -13,18 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces.util;
-
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ValidatorBean;
-
-abstract public class ValidatorFilter implements Filter
-{
- final public boolean accept(
- Object obj)
- {
- return accept((ValidatorBean)obj);
- }
-
- abstract protected boolean accept(
- ValidatorBean validator);
-}
+
+abstract public class ValidatorFilter implements Filter
+{
+ final public boolean accept(
+ Object obj)
+ {
+ return accept((ValidatorBean)obj);
+ }
+
+ abstract protected boolean accept(
+ ValidatorBean validator);
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ValidatorFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XIncludeFilter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XIncludeFilter.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XIncludeFilter.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XIncludeFilter.java Mon Jul 24 19:17:31 2006
@@ -13,171 +13,171 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces.util;
-
-import java.io.IOException;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import java.util.Stack;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.NamespaceSupport;
-import org.xml.sax.helpers.XMLFilterImpl;
-
-public final class XIncludeFilter extends XMLFilterImpl
-{
- public final static String XINCLUDE_NAMESPACE = "http://www.w3.org/2001/XInclude";
-
- public XIncludeFilter(
- XMLReader parent,
- URL base)
- {
- super(parent);
- bases.push(base);
- }
-
- public void setDocumentLocator(
- Locator locator)
- {
- locators.push(locator);
- super.setDocumentLocator(locator);
- }
-
- public void startPrefixMapping(
- String prefix,
- String namespaceURI) throws SAXException
- {
- if (!namespaceURI.equals(XINCLUDE_NAMESPACE))
- {
- namespaces.declarePrefix(prefix, namespaceURI);
- super.startPrefixMapping(prefix, namespaceURI);
- }
- }
-
- public void startElement(
- String namespaceURI,
- String localName,
- String qualifiedName,
- Attributes attributes) throws SAXException
- {
- namespaces.pushContext();
- // support both DTD and Schema
- if (namespaceURI.equals(XINCLUDE_NAMESPACE) &&
- localName.equals("include"))
- {
- // href attribute is required
- String href = attributes.getValue("href");
- if (href == null)
- throw new SAXException("Missing href attribute");
-
- // xpointer attribute is optional
- String xpointer = attributes.getValue("xpointer");
-
- doXInclude(href, xpointer);
- }
- else
- {
- super.startElement(namespaceURI, localName, qualifiedName, attributes);
- }
- }
-
- public void endElement(
- String namespaceURI,
- String localName,
- String qualifiedName) throws SAXException
- {
- if (!namespaceURI.equals(XINCLUDE_NAMESPACE))
- super.endElement(namespaceURI, localName, qualifiedName);
-
- namespaces.popContext();
- }
-
- public void startDocument() throws SAXException
- {
- if (depth == 0)
- super.startDocument();
-
- depth++;
- }
-
- public void endDocument() throws SAXException
- {
- locators.pop();
- depth--;
-
- if (depth == 0)
- super.endDocument();
- }
-
- private void doXInclude(
- String href,
- String xpointer) throws SAXException
- {
- URL target = resolveURL(href);
-
- try
- {
- SAXParserFactory saxFactory = SAXParserFactory.newInstance();
- SAXParser saxParser = saxFactory.newSAXParser();
- XMLReader reader = saxParser.getXMLReader();
- if (xpointer != null)
- {
- // pass all parsed SAX events through XPointerFilter
- reader = new XPointerFilter(reader, namespaces, xpointer);
- }
- // pass all selected XPointer SAX events to XIncludeFilter
- reader.setContentHandler(this);
- reader.setEntityResolver(this);
- reader.setErrorHandler(this);
- reader.setDTDHandler(this);
-
- // push on new base URL in case of nested xi:include
- bases.push(target);
- reader.parse(new InputSource(target.openStream()));
- bases.pop();
- }
- catch (ParserConfigurationException e)
- {
- throw new SAXException("Error during xinclude of " +
- target.toExternalForm(), e);
- }
- catch (IOException e)
- {
- throw new SAXException("Error during xinclude of " +
- target.toExternalForm(), e);
- }
- }
-
- private URL resolveURL(
- String href) throws SAXException
- {
- URL base = (URL) bases.peek();
-
- try
- {
- return new URL(base, href);
- }
- catch (MalformedURLException e)
- {
- throw new SAXException("Error resolving href \"" + href + "\" " +
- "at base \"" + base + "\"", e);
- }
- }
-
- private int depth = 0;
-
- private Stack bases = new Stack();
- private Stack locators = new Stack();
- private NamespaceSupport namespaces = new NamespaceSupport();
-}
-
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
+import java.io.IOException;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.util.Stack;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.NamespaceSupport;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+public final class XIncludeFilter extends XMLFilterImpl
+{
+ public final static String XINCLUDE_NAMESPACE = "http://www.w3.org/2001/XInclude";
+
+ public XIncludeFilter(
+ XMLReader parent,
+ URL base)
+ {
+ super(parent);
+ bases.push(base);
+ }
+
+ public void setDocumentLocator(
+ Locator locator)
+ {
+ locators.push(locator);
+ super.setDocumentLocator(locator);
+ }
+
+ public void startPrefixMapping(
+ String prefix,
+ String namespaceURI) throws SAXException
+ {
+ if (!namespaceURI.equals(XINCLUDE_NAMESPACE))
+ {
+ namespaces.declarePrefix(prefix, namespaceURI);
+ super.startPrefixMapping(prefix, namespaceURI);
+ }
+ }
+
+ public void startElement(
+ String namespaceURI,
+ String localName,
+ String qualifiedName,
+ Attributes attributes) throws SAXException
+ {
+ namespaces.pushContext();
+ // support both DTD and Schema
+ if (namespaceURI.equals(XINCLUDE_NAMESPACE) &&
+ localName.equals("include"))
+ {
+ // href attribute is required
+ String href = attributes.getValue("href");
+ if (href == null)
+ throw new SAXException("Missing href attribute");
+
+ // xpointer attribute is optional
+ String xpointer = attributes.getValue("xpointer");
+
+ doXInclude(href, xpointer);
+ }
+ else
+ {
+ super.startElement(namespaceURI, localName, qualifiedName, attributes);
+ }
+ }
+
+ public void endElement(
+ String namespaceURI,
+ String localName,
+ String qualifiedName) throws SAXException
+ {
+ if (!namespaceURI.equals(XINCLUDE_NAMESPACE))
+ super.endElement(namespaceURI, localName, qualifiedName);
+
+ namespaces.popContext();
+ }
+
+ public void startDocument() throws SAXException
+ {
+ if (depth == 0)
+ super.startDocument();
+
+ depth++;
+ }
+
+ public void endDocument() throws SAXException
+ {
+ locators.pop();
+ depth--;
+
+ if (depth == 0)
+ super.endDocument();
+ }
+
+ private void doXInclude(
+ String href,
+ String xpointer) throws SAXException
+ {
+ URL target = resolveURL(href);
+
+ try
+ {
+ SAXParserFactory saxFactory = SAXParserFactory.newInstance();
+ SAXParser saxParser = saxFactory.newSAXParser();
+ XMLReader reader = saxParser.getXMLReader();
+ if (xpointer != null)
+ {
+ // pass all parsed SAX events through XPointerFilter
+ reader = new XPointerFilter(reader, namespaces, xpointer);
+ }
+ // pass all selected XPointer SAX events to XIncludeFilter
+ reader.setContentHandler(this);
+ reader.setEntityResolver(this);
+ reader.setErrorHandler(this);
+ reader.setDTDHandler(this);
+
+ // push on new base URL in case of nested xi:include
+ bases.push(target);
+ reader.parse(new InputSource(target.openStream()));
+ bases.pop();
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw new SAXException("Error during xinclude of " +
+ target.toExternalForm(), e);
+ }
+ catch (IOException e)
+ {
+ throw new SAXException("Error during xinclude of " +
+ target.toExternalForm(), e);
+ }
+ }
+
+ private URL resolveURL(
+ String href) throws SAXException
+ {
+ URL base = (URL) bases.peek();
+
+ try
+ {
+ return new URL(base, href);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new SAXException("Error resolving href \"" + href + "\" " +
+ "at base \"" + base + "\"", e);
+ }
+ }
+
+ private int depth = 0;
+
+ private Stack bases = new Stack();
+ private Stack locators = new Stack();
+ private NamespaceSupport namespaces = new NamespaceSupport();
+}
+
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XIncludeFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XPointerFilter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XPointerFilter.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XPointerFilter.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XPointerFilter.java Mon Jul 24 19:17:31 2006
@@ -13,96 +13,96 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces.util;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.NamespaceSupport;
-import org.xml.sax.helpers.XMLFilterImpl;
-
-/**
- * For now, just skip the root element since that's our usecase.
- */
-public final class XPointerFilter extends XMLFilterImpl
-{
- public XPointerFilter(
- XMLReader parent,
- NamespaceSupport namespaces,
- String xpointer)
- {
- super(parent);
-
- // We support a very rudimentary - but totally sufficient - XPointer syntax,
- // which is just /element/otherelement/otherotherelement/*
- if (!xpointer.startsWith("/") || !xpointer.endsWith("/*"))
- throw new IllegalArgumentException("Unsupported xpointer syntax: " +
- xpointer);
-
- xpointer = xpointer.substring(0, xpointer.length() - 2).substring(1);
- String[] elements = xpointer.split("/");
- int count = elements.length;
-
- _rootNamespaceURI = new String[count];
- _rootLocalName = new String[count];
- _acceptChildNodes = new boolean[count];
-
- for (int i = 0; i < count; i++)
- {
- String[] parts = elements[i].split(":");
- String prefix = (parts.length == 1) ? "" : parts[0];
- String namespaceURI = namespaces.getURI(prefix);
- _rootNamespaceURI[i] = (namespaceURI != null) ? namespaceURI : "";
- _rootLocalName[i] = (parts.length == 1) ? parts[0] : parts[1];
- _acceptChildNodes[i] = false;
- }
- }
-
- public void startElement(
- String namespaceURI,
- String localName,
- String qualifiedName,
- Attributes attributes) throws SAXException
- {
- if (_depth < _acceptChildNodes.length)
- {
- _acceptChildNodes[_depth] =
- (_rootNamespaceURI[_depth].equals(namespaceURI) &&
- _rootLocalName[_depth].equals(localName));
- }
- else if (_acceptingChildNodes())
- {
- super.startElement(namespaceURI, localName, qualifiedName, attributes);
- }
-
- _depth++;
- }
-
- public void endElement(
- String namespaceURI,
- String localName,
- String qualifiedName) throws SAXException
- {
- _depth--;
-
- if (_depth >= _acceptChildNodes.length && _acceptingChildNodes())
- super.endElement(namespaceURI, localName, qualifiedName);
- }
-
-
- private boolean _acceptingChildNodes()
- {
- for (int i = _acceptChildNodes.length - 1; i >= 0; i--)
- {
- if (!_acceptChildNodes[i])
- return false;
- }
-
- return true;
- }
-
- private int _depth;
- private boolean[] _acceptChildNodes;
- private String[] _rootNamespaceURI;
- private String[] _rootLocalName;
-}
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.NamespaceSupport;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+/**
+ * For now, just skip the root element since that's our usecase.
+ */
+public final class XPointerFilter extends XMLFilterImpl
+{
+ public XPointerFilter(
+ XMLReader parent,
+ NamespaceSupport namespaces,
+ String xpointer)
+ {
+ super(parent);
+
+ // We support a very rudimentary - but totally sufficient - XPointer syntax,
+ // which is just /element/otherelement/otherotherelement/*
+ if (!xpointer.startsWith("/") || !xpointer.endsWith("/*"))
+ throw new IllegalArgumentException("Unsupported xpointer syntax: " +
+ xpointer);
+
+ xpointer = xpointer.substring(0, xpointer.length() - 2).substring(1);
+ String[] elements = xpointer.split("/");
+ int count = elements.length;
+
+ _rootNamespaceURI = new String[count];
+ _rootLocalName = new String[count];
+ _acceptChildNodes = new boolean[count];
+
+ for (int i = 0; i < count; i++)
+ {
+ String[] parts = elements[i].split(":");
+ String prefix = (parts.length == 1) ? "" : parts[0];
+ String namespaceURI = namespaces.getURI(prefix);
+ _rootNamespaceURI[i] = (namespaceURI != null) ? namespaceURI : "";
+ _rootLocalName[i] = (parts.length == 1) ? parts[0] : parts[1];
+ _acceptChildNodes[i] = false;
+ }
+ }
+
+ public void startElement(
+ String namespaceURI,
+ String localName,
+ String qualifiedName,
+ Attributes attributes) throws SAXException
+ {
+ if (_depth < _acceptChildNodes.length)
+ {
+ _acceptChildNodes[_depth] =
+ (_rootNamespaceURI[_depth].equals(namespaceURI) &&
+ _rootLocalName[_depth].equals(localName));
+ }
+ else if (_acceptingChildNodes())
+ {
+ super.startElement(namespaceURI, localName, qualifiedName, attributes);
+ }
+
+ _depth++;
+ }
+
+ public void endElement(
+ String namespaceURI,
+ String localName,
+ String qualifiedName) throws SAXException
+ {
+ _depth--;
+
+ if (_depth >= _acceptChildNodes.length && _acceptingChildNodes())
+ super.endElement(namespaceURI, localName, qualifiedName);
+ }
+
+
+ private boolean _acceptingChildNodes()
+ {
+ for (int i = _acceptChildNodes.length - 1; i >= 0; i--)
+ {
+ if (!_acceptChildNodes[i])
+ return false;
+ }
+
+ return true;
+ }
+
+ private int _depth;
+ private boolean[] _acceptChildNodes;
+ private String[] _rootNamespaceURI;
+ private String[] _rootLocalName;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/XPointerFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java-templates/org/apache/myfaces/adf/component/UIXCommandTemplate.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java-templates/org/apache/myfaces/adf/component/UIXCommandTemplate.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java-templates/org/apache/myfaces/adf/component/UIXCommandTemplate.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java-templates/org/apache/myfaces/adf/component/UIXCommandTemplate.java Mon Jul 24 19:17:31 2006
@@ -1,17 +1,17 @@
-/*
- * Copyright 2003,2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+ * Copyright 2003,2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.myfaces.adf.component;
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java-templates/org/apache/myfaces/adf/component/UIXCommandTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractMojoTestCase.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractMojoTestCase.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractMojoTestCase.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractMojoTestCase.java Mon Jul 24 19:17:31 2006
@@ -13,119 +13,119 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces;
-
-import java.lang.reflect.Field;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import junit.framework.TestCase;
-
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Build;
-import org.apache.maven.plugin.Mojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-
-/**
- * Tests the component generation mojo.
- */
-abstract public class AbstractMojoTestCase extends TestCase
-{
- /**
- * Creates a new AbstractMojoTestCase.
- *
- * @param testName the test to execute
- */
- public AbstractMojoTestCase(
- String testName)
- {
- super(testName);
- }
-
- protected void setMojoProject(
- Mojo mojo,
- String name) throws MojoExecutionException
- {
- Model model = new Model();
- Build build = new Build();
- build.setOutputDirectory("target/test-build-output");
- model.setBuild(build);
- setMojoField(mojo, name, new MavenProject(model));
- }
-
- protected void setMojoField(
- Mojo mojo,
- String name,
- Object value) throws MojoExecutionException
- {
- try
- {
- Class mojoClass = mojo.getClass();
- Field field = mojoClass.getDeclaredField(name);
- field.setAccessible(true);
- field.set(mojo, value);
- }
- catch (NoSuchFieldException e)
- {
- throw new MojoExecutionException("Unknown Mojo property " +
- "\"" + name + "\"", e);
- }
- catch (IllegalAccessException e)
- {
- throw new MojoExecutionException("Error setting Mojo property " +
- "\"" + name + "\"", e);
- }
- }
-
- protected void setMojoProperty(
- Mojo mojo,
- String name,
- Object value) throws MojoExecutionException
- {
- setMojoProperty(mojo, name, value.getClass(), value);
- }
-
- protected void setMojoProperty(
- Mojo mojo,
- String name,
- boolean value) throws MojoExecutionException
- {
- setMojoProperty(mojo, name, Boolean.TYPE, Boolean.valueOf(value));
- }
-
- protected void setMojoProperty(
- Mojo mojo,
- String name,
- Class type,
- Object value) throws MojoExecutionException
- {
- try
- {
- Class mojoClass = mojo.getClass();
- Method method = mojoClass.getDeclaredMethod(
- "set" +
- Character.toUpperCase(name.charAt(0)) +
- name.substring(1),
- new Class[]{type});
- method.setAccessible(true);
- method.invoke(mojo, new Object[]{value});
- }
- catch (NoSuchMethodException e)
- {
- throw new MojoExecutionException("Unknown Mojo property " +
- "\"" + name + "\"", e);
- }
- catch (InvocationTargetException e)
- {
- throw new MojoExecutionException("Error setting Mojo property " +
- "\"" + name + "\"",
- e.getTargetException());
- }
- catch (IllegalAccessException e)
- {
- throw new MojoExecutionException("Error setting Mojo property " +
- "\"" + name + "\"", e);
- }
- }
-}
+package org.apache.myfaces.trinidadbuild.plugin.faces;
+
+import java.lang.reflect.Field;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import junit.framework.TestCase;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Build;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Tests the component generation mojo.
+ */
+abstract public class AbstractMojoTestCase extends TestCase
+{
+ /**
+ * Creates a new AbstractMojoTestCase.
+ *
+ * @param testName the test to execute
+ */
+ public AbstractMojoTestCase(
+ String testName)
+ {
+ super(testName);
+ }
+
+ protected void setMojoProject(
+ Mojo mojo,
+ String name) throws MojoExecutionException
+ {
+ Model model = new Model();
+ Build build = new Build();
+ build.setOutputDirectory("target/test-build-output");
+ model.setBuild(build);
+ setMojoField(mojo, name, new MavenProject(model));
+ }
+
+ protected void setMojoField(
+ Mojo mojo,
+ String name,
+ Object value) throws MojoExecutionException
+ {
+ try
+ {
+ Class mojoClass = mojo.getClass();
+ Field field = mojoClass.getDeclaredField(name);
+ field.setAccessible(true);
+ field.set(mojo, value);
+ }
+ catch (NoSuchFieldException e)
+ {
+ throw new MojoExecutionException("Unknown Mojo property " +
+ "\"" + name + "\"", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new MojoExecutionException("Error setting Mojo property " +
+ "\"" + name + "\"", e);
+ }
+ }
+
+ protected void setMojoProperty(
+ Mojo mojo,
+ String name,
+ Object value) throws MojoExecutionException
+ {
+ setMojoProperty(mojo, name, value.getClass(), value);
+ }
+
+ protected void setMojoProperty(
+ Mojo mojo,
+ String name,
+ boolean value) throws MojoExecutionException
+ {
+ setMojoProperty(mojo, name, Boolean.TYPE, Boolean.valueOf(value));
+ }
+
+ protected void setMojoProperty(
+ Mojo mojo,
+ String name,
+ Class type,
+ Object value) throws MojoExecutionException
+ {
+ try
+ {
+ Class mojoClass = mojo.getClass();
+ Method method = mojoClass.getDeclaredMethod(
+ "set" +
+ Character.toUpperCase(name.charAt(0)) +
+ name.substring(1),
+ new Class[]{type});
+ method.setAccessible(true);
+ method.invoke(mojo, new Object[]{value});
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new MojoExecutionException("Unknown Mojo property " +
+ "\"" + name + "\"", e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new MojoExecutionException("Error setting Mojo property " +
+ "\"" + name + "\"",
+ e.getTargetException());
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new MojoExecutionException("Error setting Mojo property " +
+ "\"" + name + "\"", e);
+ }
+ }
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractMojoTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojoTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojoTest.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojoTest.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojoTest.java Mon Jul 24 19:17:31 2006
@@ -13,99 +13,99 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces;
-
-import java.io.File;
-
-import org.apache.maven.plugin.Mojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
+package org.apache.myfaces.trinidadbuild.plugin.faces;
+
+import java.io.File;
+
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.apache.myfaces.trinidadbuild.plugin.faces.GenerateComponentsMojo;
-
-/**
- * Tests the component generation mojo.
- */
-public class GenerateComponentsMojoTest extends AbstractMojoTestCase
-{
- /**
- * Creates a new GenerateComponentsMojoTest.
- *
- * @param testName the test to execute
- */
- public GenerateComponentsMojoTest(
- String testName)
- {
- super(testName);
- }
-
- public void setUp() throws MojoExecutionException
- {
- Mojo mojo = new GenerateComponentsMojo();
- File genSrcDir = new File("target/mojo-test-output/java");
-
- setMojoProject(mojo, "project");
- setMojoField(mojo, "packageContains", "org");
- setMojoField(mojo, "typePrefix", "org.apache");
- setMojoField(mojo, "templateSourceDirectory",
- new File("src/test/java-templates"));
- setMojoField(mojo, "generatedSourceDirectory", genSrcDir);
- setMojoField(mojo, "force", Boolean.TRUE);
-
- _mojo = mojo;
- _genSrcDir = genSrcDir;
- }
-
- public void tearDown()
- {
- _mojo = null;
- _genSrcDir = null;
- }
-
- public void testMissingDefaultIndex() throws MojoExecutionException, MojoFailureException
- {
- _mojo.execute();
- }
-/*
- public void testSkipAPI() throws MojoExecutionException
- {
- setMojoField(_mojo, "resourcePath",
- "META-INF/maven-faces-plugin/testSkipAPI.lst");
- _mojo.execute();
-
- File targetFile = new File(_genSrcDir,
- "javax/faces/component/UINamingContainer.java");
- if (targetFile.exists())
- fail("JavaServer Faces API component generated");
- }
-*/
- public void testGenerate() throws MojoExecutionException, MojoFailureException
- {
- setMojoField(_mojo, "resourcePath",
- "META-INF/maven-faces-plugin/testGenerate.lst");
- _mojo.execute();
-
- File targetFile = new File(_genSrcDir,
- "org/apache/myfaces/adf/component/UIXCommand.java");
- if (!targetFile.exists())
- fail("Component not generated");
-
- // TODO: verify identity content with ADF Faces example
- }
-
- public void testGenerateWithTemplate() throws MojoExecutionException, MojoFailureException
- {
- setMojoField(_mojo, "resourcePath",
- "META-INF/maven-faces-plugin/testGenerate.lst");
- _mojo.execute();
-
- File targetFile = new File(_genSrcDir,
- "org/apache/myfaces/adf/component/UIXCommand.java");
- if (!targetFile.exists())
- fail("Component not generated");
-
- // TODO: verify identity content with ADF Faces example
- }
-
- private Mojo _mojo;
- private File _genSrcDir;
-}
+
+/**
+ * Tests the component generation mojo.
+ */
+public class GenerateComponentsMojoTest extends AbstractMojoTestCase
+{
+ /**
+ * Creates a new GenerateComponentsMojoTest.
+ *
+ * @param testName the test to execute
+ */
+ public GenerateComponentsMojoTest(
+ String testName)
+ {
+ super(testName);
+ }
+
+ public void setUp() throws MojoExecutionException
+ {
+ Mojo mojo = new GenerateComponentsMojo();
+ File genSrcDir = new File("target/mojo-test-output/java");
+
+ setMojoProject(mojo, "project");
+ setMojoField(mojo, "packageContains", "org");
+ setMojoField(mojo, "typePrefix", "org.apache");
+ setMojoField(mojo, "templateSourceDirectory",
+ new File("src/test/java-templates"));
+ setMojoField(mojo, "generatedSourceDirectory", genSrcDir);
+ setMojoField(mojo, "force", Boolean.TRUE);
+
+ _mojo = mojo;
+ _genSrcDir = genSrcDir;
+ }
+
+ public void tearDown()
+ {
+ _mojo = null;
+ _genSrcDir = null;
+ }
+
+ public void testMissingDefaultIndex() throws MojoExecutionException, MojoFailureException
+ {
+ _mojo.execute();
+ }
+/*
+ public void testSkipAPI() throws MojoExecutionException
+ {
+ setMojoField(_mojo, "resourcePath",
+ "META-INF/maven-faces-plugin/testSkipAPI.lst");
+ _mojo.execute();
+
+ File targetFile = new File(_genSrcDir,
+ "javax/faces/component/UINamingContainer.java");
+ if (targetFile.exists())
+ fail("JavaServer Faces API component generated");
+ }
+*/
+ public void testGenerate() throws MojoExecutionException, MojoFailureException
+ {
+ setMojoField(_mojo, "resourcePath",
+ "META-INF/maven-faces-plugin/testGenerate.lst");
+ _mojo.execute();
+
+ File targetFile = new File(_genSrcDir,
+ "org/apache/myfaces/adf/component/UIXCommand.java");
+ if (!targetFile.exists())
+ fail("Component not generated");
+
+ // TODO: verify identity content with ADF Faces example
+ }
+
+ public void testGenerateWithTemplate() throws MojoExecutionException, MojoFailureException
+ {
+ setMojoField(_mojo, "resourcePath",
+ "META-INF/maven-faces-plugin/testGenerate.lst");
+ _mojo.execute();
+
+ File targetFile = new File(_genSrcDir,
+ "org/apache/myfaces/adf/component/UIXCommand.java");
+ if (!targetFile.exists())
+ fail("Component not generated");
+
+ // TODO: verify identity content with ADF Faces example
+ }
+
+ private Mojo _mojo;
+ private File _genSrcDir;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojoTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojoTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojoTest.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojoTest.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojoTest.java Mon Jul 24 19:17:31 2006
@@ -13,60 +13,60 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.faces;
-
-import java.io.File;
-
-import org.apache.maven.plugin.Mojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
+package org.apache.myfaces.trinidadbuild.plugin.faces;
+
+import java.io.File;
+
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.apache.myfaces.trinidadbuild.plugin.faces.GenerateFacesConfigMojo;
-
-/**
- * Tests the faces-config.xml generation mojo.
- */
-public class GenerateFacesConfigMojoTest extends AbstractMojoTestCase
-{
- /**
- * Creates a new GenerateFacesConfigMojoTest.
- *
- * @param testName the test to execute
- */
- public GenerateFacesConfigMojoTest(
- String testName)
- {
- super(testName);
- }
-
- public void setUp() throws MojoExecutionException
- {
- Mojo mojo = new GenerateFacesConfigMojo();
- File targetDir = new File("target/mojo-test-output/java");
-
- setMojoProject(mojo, "project");
- setMojoField(mojo, "configDirectory",
- new File("src/test/resources"));
- setMojoField(mojo, "configPath", "META-INF/faces-config.xml");
- setMojoField(mojo, "targetDirectory", targetDir);
- setMojoField(mojo, "force", Boolean.TRUE);
-
- _mojo = mojo;
- _targetDir = targetDir;
- }
-
- public void tearDown()
- {
- _mojo = null;
- _targetDir = null;
- }
-
- public void testGenerate() throws MojoExecutionException, MojoFailureException
- {
- _mojo.execute();
-
- // TODO: verify content is correct!
- }
-
- private Mojo _mojo;
- private File _targetDir;
-}
+
+/**
+ * Tests the faces-config.xml generation mojo.
+ */
+public class GenerateFacesConfigMojoTest extends AbstractMojoTestCase
+{
+ /**
+ * Creates a new GenerateFacesConfigMojoTest.
+ *
+ * @param testName the test to execute
+ */
+ public GenerateFacesConfigMojoTest(
+ String testName)
+ {
+ super(testName);
+ }
+
+ public void setUp() throws MojoExecutionException
+ {
+ Mojo mojo = new GenerateFacesConfigMojo();
+ File targetDir = new File("target/mojo-test-output/java");
+
+ setMojoProject(mojo, "project");
+ setMojoField(mojo, "configDirectory",
+ new File("src/test/resources"));
+ setMojoField(mojo, "configPath", "META-INF/faces-config.xml");
+ setMojoField(mojo, "targetDirectory", targetDir);
+ setMojoField(mojo, "force", Boolean.TRUE);
+
+ _mojo = mojo;
+ _targetDir = targetDir;
+ }
+
+ public void tearDown()
+ {
+ _mojo = null;
+ _targetDir = null;
+ }
+
+ public void testGenerate() throws MojoExecutionException, MojoFailureException
+ {
+ _mojo.execute();
+
+ // TODO: verify content is correct!
+ }
+
+ private Mojo _mojo;
+ private File _targetDir;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-faces-plugin/src/test/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojoTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/GenerateJavascriptLocalesMojo.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/GenerateJavascriptLocalesMojo.java?rev=425260&r1=425259&r2=425260&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/GenerateJavascriptLocalesMojo.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/GenerateJavascriptLocalesMojo.java Mon Jul 24 19:17:31 2006
@@ -13,139 +13,139 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.trinidadbuild.plugin.i18n;
-
-import java.io.File;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
+package org.apache.myfaces.trinidadbuild.plugin.i18n;
+
+import java.io.File;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
import org.apache.myfaces.trinidadbuild.plugin.i18n.uixtools.JSLocaleElementsGenerator;
-
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-
-/**
- * @version $Id$
- * @goal generate-javascript-locales
- * @phase generate-sources
- */
-public class GenerateJavascriptLocalesMojo extends AbstractMojo
-{
- /**
- * Execute the Mojo.
- */
- public void execute() throws MojoExecutionException
- {
- try
- {
- // add generated sources to compilation classpath
- addResourceRoot(targetDirectory.getCanonicalPath());
-
- File outputDirectory = new File(targetDirectory, targetPath);
-
- // Incremental check
- boolean uptodate = false;
-
- // TODO: determine how best to check for incremental
-// if (!force)
-// {
-// String[] localeStrings = getLocaleStrings();
-// String bundlePath = JSLocaleElementsGenerator._DEFAULT_BUNDLE_LOCATION_PATH;
-// for (int i=0; i < localeStrings.length; i++)
-// {
-// String path = bundlePath + "LocaleElements" +
-// localeStrings[i] + ".java";
-// File targetFile = new File(targetDirectory, path);
-// if (!targetFile.exists())
-// {
-// uptodate = false;
-// break;
-// }
-// }
-// }
-
- if (force || !uptodate)
- {
- getLog().info("Generating Javascript Locales");
-
- List argsList = new ArrayList();
-
- argsList.add("outDir=" + outputDirectory.getCanonicalPath());
- argsList.add("writeJavascript=true");
- argsList.add("writeSource=false");
- argsList.add("verbose=false");
- argsList.add("prettyPrint=true");
-
- String[] args = (String[])argsList.toArray(new String[0]);
- JSLocaleElementsGenerator.main(args);
- }
- else
- {
- getLog().info("Nothing to generate - Javascript Locales are up to date");
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw new MojoExecutionException(e.getMessage());
- }
- }
-
- // TODO: use project.addResourceRoot()
- protected void addResourceRoot(
- String resourceRoot)
- {
- List resources = project.getBuild().getResources();
- Resource resource = new Resource();
- resource.setDirectory(resourceRoot);
- resources.add(resource);
- }
-
- private String[] getLocaleStrings()
- {
- if ("en_US".equals(locale))
- return new String[] { "" };
-
- Locale[] locales = Locale.getAvailableLocales();
- String[] localeStrings = new String[locales.length];
-
- for (int i=0; i < localeStrings.length; i++)
- {
- localeStrings[i] = locales[i].getDisplayName();
- }
-
- return localeStrings;
- }
-
- /**
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- /**
- * @parameter expression="${project.build.directory}/maven-i18n-plugin/main/javascript"
- * @required
- */
- private File targetDirectory;
-
- /**
- * @parameter
- */
- private String targetPath = "";
-
- /**
- * @parameter
- */
- private String locale;
-
- /**
- * @parameter
- */
- private boolean force;
-}
+
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * @version $Id$
+ * @goal generate-javascript-locales
+ * @phase generate-sources
+ */
+public class GenerateJavascriptLocalesMojo extends AbstractMojo
+{
+ /**
+ * Execute the Mojo.
+ */
+ public void execute() throws MojoExecutionException
+ {
+ try
+ {
+ // add generated sources to compilation classpath
+ addResourceRoot(targetDirectory.getCanonicalPath());
+
+ File outputDirectory = new File(targetDirectory, targetPath);
+
+ // Incremental check
+ boolean uptodate = false;
+
+ // TODO: determine how best to check for incremental
+// if (!force)
+// {
+// String[] localeStrings = getLocaleStrings();
+// String bundlePath = JSLocaleElementsGenerator._DEFAULT_BUNDLE_LOCATION_PATH;
+// for (int i=0; i < localeStrings.length; i++)
+// {
+// String path = bundlePath + "LocaleElements" +
+// localeStrings[i] + ".java";
+// File targetFile = new File(targetDirectory, path);
+// if (!targetFile.exists())
+// {
+// uptodate = false;
+// break;
+// }
+// }
+// }
+
+ if (force || !uptodate)
+ {
+ getLog().info("Generating Javascript Locales");
+
+ List argsList = new ArrayList();
+
+ argsList.add("outDir=" + outputDirectory.getCanonicalPath());
+ argsList.add("writeJavascript=true");
+ argsList.add("writeSource=false");
+ argsList.add("verbose=false");
+ argsList.add("prettyPrint=true");
+
+ String[] args = (String[])argsList.toArray(new String[0]);
+ JSLocaleElementsGenerator.main(args);
+ }
+ else
+ {
+ getLog().info("Nothing to generate - Javascript Locales are up to date");
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new MojoExecutionException(e.getMessage());
+ }
+ }
+
+ // TODO: use project.addResourceRoot()
+ protected void addResourceRoot(
+ String resourceRoot)
+ {
+ List resources = project.getBuild().getResources();
+ Resource resource = new Resource();
+ resource.setDirectory(resourceRoot);
+ resources.add(resource);
+ }
+
+ private String[] getLocaleStrings()
+ {
+ if ("en_US".equals(locale))
+ return new String[] { "" };
+
+ Locale[] locales = Locale.getAvailableLocales();
+ String[] localeStrings = new String[locales.length];
+
+ for (int i=0; i < localeStrings.length; i++)
+ {
+ localeStrings[i] = locales[i].getDisplayName();
+ }
+
+ return localeStrings;
+ }
+
+ /**
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project;
+
+ /**
+ * @parameter expression="${project.build.directory}/maven-i18n-plugin/main/javascript"
+ * @required
+ */
+ private File targetDirectory;
+
+ /**
+ * @parameter
+ */
+ private String targetPath = "";
+
+ /**
+ * @parameter
+ */
+ private String locale;
+
+ /**
+ * @parameter
+ */
+ private boolean force;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/GenerateJavascriptLocalesMojo.java
------------------------------------------------------------------------------
svn:eol-style = native