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 00:24:18 UTC

svn commit: r425235 [10/11] - in /incubator/adffaces/branches/matzew-repackaging-trinidad/plugins: ./ maven-adf-archetype/ maven-adf-archetype/src/main/resources/archetype-resources/ maven-adf-archetype/src/main/resources/archetype-resources/src/main/j...

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Filter2.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Filter2.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Filter2.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Filter2.java Mon Jul 24 17:24:16 2006
@@ -1,320 +1,320 @@
-/*
- * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
-
-import java.io.IOException;
-
-import java.util.Vector;
-import java.util.HashMap;
-
-/**
- * Renames local variable names to short ones
- * @version $Name:  $ ($Revision$) $Date$
- * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
- */
-public class Filter2 implements TokenReader
-{
-
-  public Filter2(TokenReader in)
-  {
-    _in = in;
-    Runnable runner = new Runnable()
-      {
-        public void run()
-        {
-          try
-          {
-            //ystem.out.println("Compressor: start:"+Thread.currentThread());
-            _run();
-            //ystem.out.println("Comressor: end:"+Thread.currentThread());
-          }
-          catch (InterruptedException e)
-          {
-            e.printStackTrace();
-          }
-        }
-      };
-    new Thread(runner).start();
-  }
-
-  /**
-   * @see TokenReader#read()
-   */
-  public Token read() throws IOException, InterruptedException
-  {
-    return _buffer.read();
-  }
-
-  private void _run() throws InterruptedException
-  {
-    try
-    {
-      Token cur = _in.read();
-      for(;cur!=null;)
-      {
-        _process(cur);
-        cur = _in.read();
-      }
-    }
-    catch (IOException e)
-    {
-      _buffer.write(e);
-    }
-    catch (TokenException e)
-    {
-      e.printStackTrace();
-      _buffer.write(new IOException("Error parsing line:"+
-                                    e.getToken().lineNumber));
-    }
-    catch (RuntimeException e)
-    {
-      e.printStackTrace();
-      _buffer.write(new IOException());
-    }
-    _buffer.close();
-  }
-
-  /**
-   * renames local variable names to short names.
-   * First pass. sets a flag if this function uses the JS eval method.
-   */
-  private void _process(Token cur) throws InterruptedException
-  {
-    if ((cur.code == Token.LEFT_BRACE) && (cur.ch == '{'))
-      _openCurly++;
-    else if ((cur.code == Token.RIGHT_BRACE) && (cur.ch == '}'))
-      _openCurly--;
-
-
-    switch(_state)
-    {
-    case ROOT_MODE :
-      if ((cur.code==Token.RESERVED) && (cur.string.equals("function")))
-      {
-        _state = FUNCTION_PARAM_MODE;
-        _function.clear();
-        _isFunctionUsingEval = false;
-        _function.add(cur);
-      }
-      else _buffer.write(cur);
-      break;
-    case FUNCTION_PARAM_MODE :
-      _function.add(cur);
-      if ((cur.code==Token.LEFT_BRACE) && (cur.ch=='{'))
-      {
-        _state = FUNCTION_BODY_MODE;
-        _beginFunction = _openCurly;
-      }
-      break;
-    case FUNCTION_BODY_MODE :
-      _function.add(cur);
-      if (_openCurly<_beginFunction)
-      {
-        _state = ROOT_MODE;
-        if (_isFunctionUsingEval) _writeTokens(_function);
-        else
-        {
-          for(int i=0,sz=_function.size(); i<sz; i++)
-          {
-            _process2((Token) _function.get(i));
-          }
-        }
-      }
-      else if ((cur.code==Token.NAME) && cur.string.equals("eval"))
-      {
-        _isFunctionUsingEval = true;
-      }
-      break;
-    }
-  }
-
-  /**
-   * 2nd pass
-   * Does the actual renaming
-   */
-  private void _process2(Token cur) throws InterruptedException
-  {
-    if ((cur.code == Token.LEFT_BRACE) && (cur.ch == '{'))
-      _openCurly++;
-    else if ((cur.code == Token.RIGHT_BRACE) && (cur.ch == '}'))
-      _openCurly--;
-
-    switch(_state)
-    {
-    case ROOT_MODE :
-      if ((cur.code==Token.RESERVED) && (cur.string.equals("function")))
-        _state = FUNCTION_MODE;
-      break;
-    case FUNCTION_MODE :
-      if ((cur.code==Token.LEFT_BRACE) && (cur.ch=='('))
-      {
-        _state = FUNCTION_PARAM_MODE;
-        _localVarMap.clear();
-      }
-      else if (cur.code==Token.NAME)
-      {
-        //ystem.out.println("function name;"+cur.string);
-        _nameGen.reset();
-      }
-      break;
-    case FUNCTION_PARAM_MODE :
-      if ((cur.code==Token.LEFT_BRACE) && (cur.ch=='{'))
-      {
-        _state = FUNCTION_BODY_MODE;
-        _beginFunction = _openCurly;
-      }
-      else if (cur.code == Token.NAME)
-      {
-        //ystem.out.println(" param:"+cur.string);
-        Token tok = _getNewToken(cur);
-        cur = tok;
-      }
-      break;
-    case FUNCTION_BODY_MODE :
-      if (_openCurly<_beginFunction)
-      {
-        _state = ROOT_MODE;
-      }
-      else if (cur.code==Token.PERIOD)
-        _state = PERIOD_MODE;
-      else if ((cur.code==Token.RESERVED) && (cur.string.equals("var")))
-        _state = VAR_DEF_MODE;
-      else if (cur.code==Token.NAME)
-      {
-        cur = _substForToken(cur);
-      }
-      break;
-    case VAR_DEF_MODE :
-      if (cur.code==Token.NAME)
-      {
-        _state = FUNCTION_BODY_MODE;
-        //ystem.out.println(" local var:"+cur.string);
-        Token tok = _getNewToken(cur);
-        cur = tok;
-      }
-      break;
-    case PERIOD_MODE :
-      // this is just to skip the next token after a period.
-      _state = FUNCTION_BODY_MODE;
-      break;
-    }
-    _buffer.write(cur);
-  }
-
-  private void _writeTokens(Vector tokens) throws InterruptedException
-  {
-    for(int i=0,sz=tokens.size(); i<sz; i++)
-    {
-      _buffer.write((Token) tokens.get(i));
-    }
-  }
-
-  /**
-   * @return a new token to replace the old one with. the new one will have
-   *  a short name
-   */
-  private Token _getNewToken(Token oldToken)
-  {
-    String oldName = oldToken.string;
-    String newName = (String) _localVarMap.get(oldName);
-    if (newName==null)
-    {
-      newName = _nameGen.getNext();
-      _localVarMap.put(oldName, newName);
-    }
-    return new Token(oldToken.code, oldToken.lineNumber, newName);
-  }
-
-  /**
-   * @return the substitute token. if no token has been substituted for the
-   *  <code>oldToken</code> then the <code>oldToken</code> is returned.
-   * @param oldToken the token to substitute for.
-   */
-  private Token _substForToken(Token oldToken)
-  {
-    String oldName = oldToken.string;
-    String newName = (String) _localVarMap.get(oldName);
-    if (newName==null)
-    {
-      if (_nameGen.isInUse(oldName))
-        throw new TokenException(oldToken,
-                                 "Conflict with global var:"+oldName);
-      return oldToken;
-    }
-    Token tok = new Token(oldToken.code, oldToken.lineNumber, newName);
-    return tok;
-  }
-
-  private class NameGen
-  {
-    private int _i = 0;
-    private char _ch = 'a';
-    private final StringBuffer _sb = new StringBuffer();
-
-    /**
-     * @return a new unique short name
-     */
-    public String getNext()
-    {
-      _sb.setLength(0);
-      return _sb.append(_ch).append(_i++).toString();
-    }
-
-    public void reset()
-    {
-      _i = 0;
-    }
-
-    /**
-     * @return true if <code>varName</code> has already been returned by
-     *   the method <code>getNext()</code>
-     * @see #getNext()
-     */
-    public boolean isInUse(String varName)
-    {
-      int sz=varName.length();
-      if ((varName.charAt(0)!=_ch) || (sz<=1)) return false;
-
-      for(int i=1; i<sz; i++)
-      {
-        if (!Character.isDigit(varName.charAt(i))) return false;
-      }
-      String ipart = varName.substring(1);
-      int j = Integer.parseInt(ipart);
-      if (j >= _i) return false;
-      else return true;
-    }
-  }
-
-  private int _state = ROOT_MODE;
-  private int _openCurly = 0;
-  private int _beginFunction = 0;
-  private boolean _isFunctionUsingEval = false;
-
-  private final TokenReader _in;
-  private final NameGen _nameGen = new NameGen();
-  private final HashMap _localVarMap = new HashMap();
-  private final TokenBuffer _buffer = new TokenBuffer();
-  private final Vector _function = new Vector();
-
-  private static final int ROOT_MODE =           0;
-  private static final int FUNCTION_MODE =       1;
-  private static final int FUNCTION_PARAM_MODE = 2;
-  private static final int FUNCTION_BODY_MODE =  3;
-  private static final int VAR_DEF_MODE =        4;
-  private static final int PERIOD_MODE =         5;
-
+/*
+ * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
+
+import java.io.IOException;
+
+import java.util.Vector;
+import java.util.HashMap;
+
+/**
+ * Renames local variable names to short ones
+ * @version $Name:  $ ($Revision$) $Date$
+ * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
+ */
+public class Filter2 implements TokenReader
+{
+
+  public Filter2(TokenReader in)
+  {
+    _in = in;
+    Runnable runner = new Runnable()
+      {
+        public void run()
+        {
+          try
+          {
+            //ystem.out.println("Compressor: start:"+Thread.currentThread());
+            _run();
+            //ystem.out.println("Comressor: end:"+Thread.currentThread());
+          }
+          catch (InterruptedException e)
+          {
+            e.printStackTrace();
+          }
+        }
+      };
+    new Thread(runner).start();
+  }
+
+  /**
+   * @see TokenReader#read()
+   */
+  public Token read() throws IOException, InterruptedException
+  {
+    return _buffer.read();
+  }
+
+  private void _run() throws InterruptedException
+  {
+    try
+    {
+      Token cur = _in.read();
+      for(;cur!=null;)
+      {
+        _process(cur);
+        cur = _in.read();
+      }
+    }
+    catch (IOException e)
+    {
+      _buffer.write(e);
+    }
+    catch (TokenException e)
+    {
+      e.printStackTrace();
+      _buffer.write(new IOException("Error parsing line:"+
+                                    e.getToken().lineNumber));
+    }
+    catch (RuntimeException e)
+    {
+      e.printStackTrace();
+      _buffer.write(new IOException());
+    }
+    _buffer.close();
+  }
+
+  /**
+   * renames local variable names to short names.
+   * First pass. sets a flag if this function uses the JS eval method.
+   */
+  private void _process(Token cur) throws InterruptedException
+  {
+    if ((cur.code == Token.LEFT_BRACE) && (cur.ch == '{'))
+      _openCurly++;
+    else if ((cur.code == Token.RIGHT_BRACE) && (cur.ch == '}'))
+      _openCurly--;
+
+
+    switch(_state)
+    {
+    case ROOT_MODE :
+      if ((cur.code==Token.RESERVED) && (cur.string.equals("function")))
+      {
+        _state = FUNCTION_PARAM_MODE;
+        _function.clear();
+        _isFunctionUsingEval = false;
+        _function.add(cur);
+      }
+      else _buffer.write(cur);
+      break;
+    case FUNCTION_PARAM_MODE :
+      _function.add(cur);
+      if ((cur.code==Token.LEFT_BRACE) && (cur.ch=='{'))
+      {
+        _state = FUNCTION_BODY_MODE;
+        _beginFunction = _openCurly;
+      }
+      break;
+    case FUNCTION_BODY_MODE :
+      _function.add(cur);
+      if (_openCurly<_beginFunction)
+      {
+        _state = ROOT_MODE;
+        if (_isFunctionUsingEval) _writeTokens(_function);
+        else
+        {
+          for(int i=0,sz=_function.size(); i<sz; i++)
+          {
+            _process2((Token) _function.get(i));
+          }
+        }
+      }
+      else if ((cur.code==Token.NAME) && cur.string.equals("eval"))
+      {
+        _isFunctionUsingEval = true;
+      }
+      break;
+    }
+  }
+
+  /**
+   * 2nd pass
+   * Does the actual renaming
+   */
+  private void _process2(Token cur) throws InterruptedException
+  {
+    if ((cur.code == Token.LEFT_BRACE) && (cur.ch == '{'))
+      _openCurly++;
+    else if ((cur.code == Token.RIGHT_BRACE) && (cur.ch == '}'))
+      _openCurly--;
+
+    switch(_state)
+    {
+    case ROOT_MODE :
+      if ((cur.code==Token.RESERVED) && (cur.string.equals("function")))
+        _state = FUNCTION_MODE;
+      break;
+    case FUNCTION_MODE :
+      if ((cur.code==Token.LEFT_BRACE) && (cur.ch=='('))
+      {
+        _state = FUNCTION_PARAM_MODE;
+        _localVarMap.clear();
+      }
+      else if (cur.code==Token.NAME)
+      {
+        //ystem.out.println("function name;"+cur.string);
+        _nameGen.reset();
+      }
+      break;
+    case FUNCTION_PARAM_MODE :
+      if ((cur.code==Token.LEFT_BRACE) && (cur.ch=='{'))
+      {
+        _state = FUNCTION_BODY_MODE;
+        _beginFunction = _openCurly;
+      }
+      else if (cur.code == Token.NAME)
+      {
+        //ystem.out.println(" param:"+cur.string);
+        Token tok = _getNewToken(cur);
+        cur = tok;
+      }
+      break;
+    case FUNCTION_BODY_MODE :
+      if (_openCurly<_beginFunction)
+      {
+        _state = ROOT_MODE;
+      }
+      else if (cur.code==Token.PERIOD)
+        _state = PERIOD_MODE;
+      else if ((cur.code==Token.RESERVED) && (cur.string.equals("var")))
+        _state = VAR_DEF_MODE;
+      else if (cur.code==Token.NAME)
+      {
+        cur = _substForToken(cur);
+      }
+      break;
+    case VAR_DEF_MODE :
+      if (cur.code==Token.NAME)
+      {
+        _state = FUNCTION_BODY_MODE;
+        //ystem.out.println(" local var:"+cur.string);
+        Token tok = _getNewToken(cur);
+        cur = tok;
+      }
+      break;
+    case PERIOD_MODE :
+      // this is just to skip the next token after a period.
+      _state = FUNCTION_BODY_MODE;
+      break;
+    }
+    _buffer.write(cur);
+  }
+
+  private void _writeTokens(Vector tokens) throws InterruptedException
+  {
+    for(int i=0,sz=tokens.size(); i<sz; i++)
+    {
+      _buffer.write((Token) tokens.get(i));
+    }
+  }
+
+  /**
+   * @return a new token to replace the old one with. the new one will have
+   *  a short name
+   */
+  private Token _getNewToken(Token oldToken)
+  {
+    String oldName = oldToken.string;
+    String newName = (String) _localVarMap.get(oldName);
+    if (newName==null)
+    {
+      newName = _nameGen.getNext();
+      _localVarMap.put(oldName, newName);
+    }
+    return new Token(oldToken.code, oldToken.lineNumber, newName);
+  }
+
+  /**
+   * @return the substitute token. if no token has been substituted for the
+   *  <code>oldToken</code> then the <code>oldToken</code> is returned.
+   * @param oldToken the token to substitute for.
+   */
+  private Token _substForToken(Token oldToken)
+  {
+    String oldName = oldToken.string;
+    String newName = (String) _localVarMap.get(oldName);
+    if (newName==null)
+    {
+      if (_nameGen.isInUse(oldName))
+        throw new TokenException(oldToken,
+                                 "Conflict with global var:"+oldName);
+      return oldToken;
+    }
+    Token tok = new Token(oldToken.code, oldToken.lineNumber, newName);
+    return tok;
+  }
+
+  private class NameGen
+  {
+    private int _i = 0;
+    private char _ch = 'a';
+    private final StringBuffer _sb = new StringBuffer();
+
+    /**
+     * @return a new unique short name
+     */
+    public String getNext()
+    {
+      _sb.setLength(0);
+      return _sb.append(_ch).append(_i++).toString();
+    }
+
+    public void reset()
+    {
+      _i = 0;
+    }
+
+    /**
+     * @return true if <code>varName</code> has already been returned by
+     *   the method <code>getNext()</code>
+     * @see #getNext()
+     */
+    public boolean isInUse(String varName)
+    {
+      int sz=varName.length();
+      if ((varName.charAt(0)!=_ch) || (sz<=1)) return false;
+
+      for(int i=1; i<sz; i++)
+      {
+        if (!Character.isDigit(varName.charAt(i))) return false;
+      }
+      String ipart = varName.substring(1);
+      int j = Integer.parseInt(ipart);
+      if (j >= _i) return false;
+      else return true;
+    }
+  }
+
+  private int _state = ROOT_MODE;
+  private int _openCurly = 0;
+  private int _beginFunction = 0;
+  private boolean _isFunctionUsingEval = false;
+
+  private final TokenReader _in;
+  private final NameGen _nameGen = new NameGen();
+  private final HashMap _localVarMap = new HashMap();
+  private final TokenBuffer _buffer = new TokenBuffer();
+  private final Vector _function = new Vector();
+
+  private static final int ROOT_MODE =           0;
+  private static final int FUNCTION_MODE =       1;
+  private static final int FUNCTION_PARAM_MODE = 2;
+  private static final int FUNCTION_BODY_MODE =  3;
+  private static final int VAR_DEF_MODE =        4;
+  private static final int PERIOD_MODE =         5;
+
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Filter2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Queue.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Queue.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Queue.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Queue.java Mon Jul 24 17:24:16 2006
@@ -1,208 +1,208 @@
-/*
- * Copyright 1999-2002,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.trinidadbuild.plugin.javascript.uixtools;
-
-import java.util.List;
-
-/**
- * Implements a first-in-first-out (FIFO) queue. Typically, one thread will add
- * elements to this queue, and another will remove elements from this queue.
- * This class is thread safe.
- * @version $Name:  $ ($Revision$) $Date$
- * @author Arjuna Wijeyekoon (arjuna.wijeyekoon@oracle.com)
- */
-public class Queue
-{
-  /**
-   * @param size the maximum size of this queue
-   */
-  public Queue(int size)
-  {
-    if (size<=0)
-      throw new IllegalArgumentException("size is nonpositive:"+size);
-    _buf = new Object[size];
-  }
-
-  /**
-   * @return the number of elements in this queue. This will never be larger
-   * than the {@link #Queue(int) maximum size} of this queue.
-   */
-  public final synchronized int size()
-  {
-    return _size;
-  }
-
-  /**
-   * @return true if the queue has been closed.
-   * @see #close()
-   */
-  public final synchronized boolean isClosed()
-  {
-    return _closed;
-  }
-
-  /**
-   * closes this queue. Any consequent {@link #add(Object)} method calls will
-   * fail.  All {@link #get()} operations will succeed until the queue is
-   * empty. This method may be called multiple times.
-   * @see #isClosed()
-   */
-  public synchronized void close()
-  {
-    _closed = true;
-    notifyAll();
-  }
-
-  /**
-   * @return true if the queue is full and a call to {@link #add(Object)}
-   * would block.
-   */
-  public final boolean isFull()
-  {
-    return (size() == _buf.length);
-  }
-
-  /**
-   * @return true if the queue is empty and a call to {@link #get()}
-   * would block.
-   */
-  public final boolean isEmpty()
-  {
-    return (size() == 0);
-  }
-
-  /**
-   * This method blocks until space is available in this queue.
-   * @param obj the Object to add to the end of this queue. null is permitted.
-   * @exception InterruptedException if the current thread is interrupted.
-   * @exception IllegalStateException if queue is closed.
-   * @see #close()
-   * @see #remove()
-   */
-  public synchronized void add(Object obj)
-    throws InterruptedException, IllegalStateException
-  {
-    for(;isFull() && (!isClosed());)
-    {
-      //ystem.out.println("waiting to add. size");
-      wait();
-    }
-    //ystem.out.println("adding. size:"+size());
-
-    _checkIsClosed();
-
-    _buf[_head] = obj;
-    _head = _incIndex(_head);
-    _size++;
-    // yes, we are waking up all threads, including those that are
-    // waiting to do an add. This may be inefficient.
-    // note that we must do notifyAll() and not notify()
-    notifyAll();
-  }
-
-  /**
-   * This method blocks until some element is added to this queue, or the queue
-   * is closed.
-   * @return removes and returns the Object at the front of this queue.
-   * null may be returned if null was added using {@link #add(Object)}
-   * @exception InterruptedException if the current thread is interrupted.
-   * @exception IllegalStateException if queue is closed.
-   * @see #close()
-   * @see #add(Object)
-   * @see #remove(LIst,int)
-   */
-  public synchronized Object remove()
-    throws InterruptedException, IllegalStateException
-  {
-    for(;isEmpty();)
-    {
-      _checkIsClosed();
-      wait();
-    }
-
-    Object res = _buf[_tail];
-    _buf[_tail] = null; // allow garbage collect
-    _tail = _incIndex(_tail);
-    _size--;
-
-    // yes, we are waking up all threads, including those that are
-    // waiting to do a remove. This may be inefficient.
-    // note that we must do notifyAll() and not notify()
-    notifyAll();
-    return res;
-  }
-
-  /**
-   * Removes multiple elements. This method will block until there is something
-   * to remove.
-   * @param collector all the elements removed from this queue are added to
-   * the end of this List.
-   * @param count the maximum number of elements to remove. If this is zero,
-   * then it defaults to the maximum size of this queue.
-   * @return the number of elements actually removed.
-   * @see #remove()
-   */
-  public synchronized int remove(List collector, int count)
-    throws InterruptedException, IllegalStateException
-  {
-    collector.add(remove());
-
-    int sz = size()+1;
-    if ((count == 0) || (count > sz))
-      count = sz;
-    else if (count < 0)
-      throw new IllegalArgumentException("count is negative");
-
-    int read = 1;
-    try
-    {
-      for(;read < count; read++)
-      {
-        collector.add(remove());
-      }
-    }
-    catch(IllegalStateException e)
-    {
-      // this should not happen unless the user has subclassed remove() and
-      // done something weird
-    }
-    catch(InterruptedException e)
-    {
-      // this should not happen unless the user has subclassed remove() and
-      // done something weird
-
-      // mark this thread as interrupted, so that it doesn't block again.
-      Thread.currentThread().interrupt();
-    }
-    return read;
-  }
-
-  private int _incIndex(int index)
-  {
-    index++;
-    return (index < _buf.length) ? index : 0;
-  }
-
-  private void _checkIsClosed()
-  {
-    if (isClosed())
-      throw new IllegalStateException("Queue has been closed");
-  }
-
-  private final Object[] _buf;
-  private boolean _closed = false;
-  private int _size = 0, _head = 0, _tail = 0;
+/*
+ * Copyright 1999-2002,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.trinidadbuild.plugin.javascript.uixtools;
+
+import java.util.List;
+
+/**
+ * Implements a first-in-first-out (FIFO) queue. Typically, one thread will add
+ * elements to this queue, and another will remove elements from this queue.
+ * This class is thread safe.
+ * @version $Name:  $ ($Revision$) $Date$
+ * @author Arjuna Wijeyekoon (arjuna.wijeyekoon@oracle.com)
+ */
+public class Queue
+{
+  /**
+   * @param size the maximum size of this queue
+   */
+  public Queue(int size)
+  {
+    if (size<=0)
+      throw new IllegalArgumentException("size is nonpositive:"+size);
+    _buf = new Object[size];
+  }
+
+  /**
+   * @return the number of elements in this queue. This will never be larger
+   * than the {@link #Queue(int) maximum size} of this queue.
+   */
+  public final synchronized int size()
+  {
+    return _size;
+  }
+
+  /**
+   * @return true if the queue has been closed.
+   * @see #close()
+   */
+  public final synchronized boolean isClosed()
+  {
+    return _closed;
+  }
+
+  /**
+   * closes this queue. Any consequent {@link #add(Object)} method calls will
+   * fail.  All {@link #get()} operations will succeed until the queue is
+   * empty. This method may be called multiple times.
+   * @see #isClosed()
+   */
+  public synchronized void close()
+  {
+    _closed = true;
+    notifyAll();
+  }
+
+  /**
+   * @return true if the queue is full and a call to {@link #add(Object)}
+   * would block.
+   */
+  public final boolean isFull()
+  {
+    return (size() == _buf.length);
+  }
+
+  /**
+   * @return true if the queue is empty and a call to {@link #get()}
+   * would block.
+   */
+  public final boolean isEmpty()
+  {
+    return (size() == 0);
+  }
+
+  /**
+   * This method blocks until space is available in this queue.
+   * @param obj the Object to add to the end of this queue. null is permitted.
+   * @exception InterruptedException if the current thread is interrupted.
+   * @exception IllegalStateException if queue is closed.
+   * @see #close()
+   * @see #remove()
+   */
+  public synchronized void add(Object obj)
+    throws InterruptedException, IllegalStateException
+  {
+    for(;isFull() && (!isClosed());)
+    {
+      //ystem.out.println("waiting to add. size");
+      wait();
+    }
+    //ystem.out.println("adding. size:"+size());
+
+    _checkIsClosed();
+
+    _buf[_head] = obj;
+    _head = _incIndex(_head);
+    _size++;
+    // yes, we are waking up all threads, including those that are
+    // waiting to do an add. This may be inefficient.
+    // note that we must do notifyAll() and not notify()
+    notifyAll();
+  }
+
+  /**
+   * This method blocks until some element is added to this queue, or the queue
+   * is closed.
+   * @return removes and returns the Object at the front of this queue.
+   * null may be returned if null was added using {@link #add(Object)}
+   * @exception InterruptedException if the current thread is interrupted.
+   * @exception IllegalStateException if queue is closed.
+   * @see #close()
+   * @see #add(Object)
+   * @see #remove(LIst,int)
+   */
+  public synchronized Object remove()
+    throws InterruptedException, IllegalStateException
+  {
+    for(;isEmpty();)
+    {
+      _checkIsClosed();
+      wait();
+    }
+
+    Object res = _buf[_tail];
+    _buf[_tail] = null; // allow garbage collect
+    _tail = _incIndex(_tail);
+    _size--;
+
+    // yes, we are waking up all threads, including those that are
+    // waiting to do a remove. This may be inefficient.
+    // note that we must do notifyAll() and not notify()
+    notifyAll();
+    return res;
+  }
+
+  /**
+   * Removes multiple elements. This method will block until there is something
+   * to remove.
+   * @param collector all the elements removed from this queue are added to
+   * the end of this List.
+   * @param count the maximum number of elements to remove. If this is zero,
+   * then it defaults to the maximum size of this queue.
+   * @return the number of elements actually removed.
+   * @see #remove()
+   */
+  public synchronized int remove(List collector, int count)
+    throws InterruptedException, IllegalStateException
+  {
+    collector.add(remove());
+
+    int sz = size()+1;
+    if ((count == 0) || (count > sz))
+      count = sz;
+    else if (count < 0)
+      throw new IllegalArgumentException("count is negative");
+
+    int read = 1;
+    try
+    {
+      for(;read < count; read++)
+      {
+        collector.add(remove());
+      }
+    }
+    catch(IllegalStateException e)
+    {
+      // this should not happen unless the user has subclassed remove() and
+      // done something weird
+    }
+    catch(InterruptedException e)
+    {
+      // this should not happen unless the user has subclassed remove() and
+      // done something weird
+
+      // mark this thread as interrupted, so that it doesn't block again.
+      Thread.currentThread().interrupt();
+    }
+    return read;
+  }
+
+  private int _incIndex(int index)
+  {
+    index++;
+    return (index < _buf.length) ? index : 0;
+  }
+
+  private void _checkIsClosed()
+  {
+    if (isClosed())
+      throw new IllegalStateException("Queue has been closed");
+  }
+
+  private final Object[] _buf;
+  private boolean _closed = false;
+  private int _size = 0, _head = 0, _tail = 0;
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Queue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Reducer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Reducer.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Reducer.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Reducer.java Mon Jul 24 17:24:16 2006
@@ -1,134 +1,134 @@
-/*
- * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-/**
- * Reduces JavaScript files by stripping comments and redundant whitespace
- * and renaming local variable names to shorter ones.
- * @version $Name:  $ ($Revision$) $Date$
- * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
- */
-public class Reducer extends FileProcessor
-{
-  /**
-   * creates a new Reducer.
-   * @param whitespaceComments if true removes comments and extra whitespace
-   * @param localVars if true renames local variable names to shorter ones.
-   */
-  public Reducer(boolean whitespaceComments, boolean localVars)
-  {
-    super(".js", false);
-    _STRIP_WHITESPACE_COMMENTS = whitespaceComments;
-    _RENAME_LOCAL_VARIABLES = localVars;
-  }
-
-  public Reducer()
-  {
-    this(true, true);
-  }
-
-  /**
-   * reduces a JavaScript file.
-   * @param in the source to read from
-   * @param out the source to write the reduced form to
-   */
-  public void process(BufferedReader in, PrintWriter out)
-    throws IOException, InterruptedException
-  {
-    TokenReader tr = new Tokenizer(in);
-    if (_STRIP_WHITESPACE_COMMENTS) tr = new Filter1(tr);
-    if (_RENAME_LOCAL_VARIABLES) tr = new Filter2(tr);
-    Detokenizer detok = new Detokenizer(out);
-    for(;;)
-    {
-      Token tok = tr.read();
-      if (tok==null) break;
-      else detok.write(tok);
-    }
-  }
-
-  /**
-   * @see FileProcessor#processFile(File, File)
-   */
-  protected void processFile(File in, File out)
-    throws IOException, InterruptedException
-  {
-    BufferedReader reader = new BufferedReader(new FileReader(in));
-    PrintWriter writer =  new PrintWriter(new FileWriter(out));
-    process(reader, writer);
-    writer.close();
-    reader.close();
-  }
-
-  private static void _help()
-  {
-    String s;
-    s = "Reduces JavaScript source code\n" +
-      "Usage:\n" +
-      "java oracle.uix.tools.uix22.javascript.Reducer" +
-      " [-norename] [-whitespace] [-help] input output \n" +
-      " input/output can be either files or directories.\n" +
-      " Directories will be processed recursively.\n" +
-      " Only files with names that end with .js will be processed.\n" +
-      " -norename prevents renaming local variables to short ones\n" +
-      " -whitespace prevents removing comments and extra whitespace\n" +
-      " -help prints this message.";
-    System.out.println(s);
-  }
-
-  public static void main(String[] args)
-  {
-    boolean rename = true;
-    boolean space = true;
-
-    final int sz = args.length-2;
-
-    if (sz<0)
-    {
-      _help();
-      return;
-    }
-
-    for(int i=0; i<sz; i++)
-    {
-      String s = args[i];
-      if (s.equals("-help")) _help();
-      else if (s.equals("-norename")) rename = false;
-      else if (s.equals("-whitespace")) space = false;
-      else
-      {
-        System.out.println("Unknown option:"+s);
-        _help();
-        return;
-      }
-    }
-
-    File in = new File(args[sz]);
-    File out = new File(args[sz+1]);
-    Reducer reducer = new Reducer(space, rename);
-    reducer.process(in, out);
-  }
-
-  private final boolean _STRIP_WHITESPACE_COMMENTS;
-  private final boolean _RENAME_LOCAL_VARIABLES;
+/*
+ * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * Reduces JavaScript files by stripping comments and redundant whitespace
+ * and renaming local variable names to shorter ones.
+ * @version $Name:  $ ($Revision$) $Date$
+ * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
+ */
+public class Reducer extends FileProcessor
+{
+  /**
+   * creates a new Reducer.
+   * @param whitespaceComments if true removes comments and extra whitespace
+   * @param localVars if true renames local variable names to shorter ones.
+   */
+  public Reducer(boolean whitespaceComments, boolean localVars)
+  {
+    super(".js", false);
+    _STRIP_WHITESPACE_COMMENTS = whitespaceComments;
+    _RENAME_LOCAL_VARIABLES = localVars;
+  }
+
+  public Reducer()
+  {
+    this(true, true);
+  }
+
+  /**
+   * reduces a JavaScript file.
+   * @param in the source to read from
+   * @param out the source to write the reduced form to
+   */
+  public void process(BufferedReader in, PrintWriter out)
+    throws IOException, InterruptedException
+  {
+    TokenReader tr = new Tokenizer(in);
+    if (_STRIP_WHITESPACE_COMMENTS) tr = new Filter1(tr);
+    if (_RENAME_LOCAL_VARIABLES) tr = new Filter2(tr);
+    Detokenizer detok = new Detokenizer(out);
+    for(;;)
+    {
+      Token tok = tr.read();
+      if (tok==null) break;
+      else detok.write(tok);
+    }
+  }
+
+  /**
+   * @see FileProcessor#processFile(File, File)
+   */
+  protected void processFile(File in, File out)
+    throws IOException, InterruptedException
+  {
+    BufferedReader reader = new BufferedReader(new FileReader(in));
+    PrintWriter writer =  new PrintWriter(new FileWriter(out));
+    process(reader, writer);
+    writer.close();
+    reader.close();
+  }
+
+  private static void _help()
+  {
+    String s;
+    s = "Reduces JavaScript source code\n" +
+      "Usage:\n" +
+      "java oracle.uix.tools.uix22.javascript.Reducer" +
+      " [-norename] [-whitespace] [-help] input output \n" +
+      " input/output can be either files or directories.\n" +
+      " Directories will be processed recursively.\n" +
+      " Only files with names that end with .js will be processed.\n" +
+      " -norename prevents renaming local variables to short ones\n" +
+      " -whitespace prevents removing comments and extra whitespace\n" +
+      " -help prints this message.";
+    System.out.println(s);
+  }
+
+  public static void main(String[] args)
+  {
+    boolean rename = true;
+    boolean space = true;
+
+    final int sz = args.length-2;
+
+    if (sz<0)
+    {
+      _help();
+      return;
+    }
+
+    for(int i=0; i<sz; i++)
+    {
+      String s = args[i];
+      if (s.equals("-help")) _help();
+      else if (s.equals("-norename")) rename = false;
+      else if (s.equals("-whitespace")) space = false;
+      else
+      {
+        System.out.println("Unknown option:"+s);
+        _help();
+        return;
+      }
+    }
+
+    File in = new File(args[sz]);
+    File out = new File(args[sz+1]);
+    Reducer reducer = new Reducer(space, rename);
+    reducer.process(in, out);
+  }
+
+  private final boolean _STRIP_WHITESPACE_COMMENTS;
+  private final boolean _RENAME_LOCAL_VARIABLES;
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Reducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Token.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Token.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Token.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Token.java Mon Jul 24 17:24:16 2006
@@ -1,75 +1,75 @@
-/*
- * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
-
-/**
- * Tokens for JavaScript source code
- * @version $Name:  $ ($Revision$) $Date$
- * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
- */
-public class Token
-{
-
-  public Token(int code, int lineNumber)
-  {
-    this(code, lineNumber, (char) 0, (String) null);
-  }
-
-  public Token(int code, int lineNumber, char ch)
-  {
-    this(code, lineNumber, ch, (String) null);
-  }
-
-  public Token(int code, int lineNumber, String s)
-  {
-    this(code, lineNumber, (char) 0, s);
-  }
-
-  public Token(int code, int lineNumber, char ch, String s)
-  {
-    this.code=code;
-    this.lineNumber = lineNumber;
-    this.ch=ch;
-    string = s;
-  }
-
-  public String toString()
-  {
-    return "Token code:"+code+" line:"+lineNumber+
-      " char:"+ch+" string:"+string;
-  }
-
-  public final int code, lineNumber;
-  public final char ch;
-  public final String string;
-
-  public static final int EOF =                 0;
-  public static final int NEWLINE =             10;
-  public static final int WHITESPACE =          11;
-  public static final int PERIOD =              12;
-  public static final int SEMICOLON =           13;
-  public static final int QUOTED =              20;
-  public static final int NAME =                30;
-  public static final int NUMBER =              40;
-  public static final int COMMENT =             50;
-  public static final int REGULAR_EXP =         60;
-  public static final int REGULAR_EXP_MODIFIER =65;
-  public static final int CONTROL =             100;
-  public static final int LEFT_BRACE =          110;
-  public static final int RIGHT_BRACE =         120;
-  public static final int RESERVED =            200; //reserved words
-
+/*
+ * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
+
+/**
+ * Tokens for JavaScript source code
+ * @version $Name:  $ ($Revision$) $Date$
+ * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
+ */
+public class Token
+{
+
+  public Token(int code, int lineNumber)
+  {
+    this(code, lineNumber, (char) 0, (String) null);
+  }
+
+  public Token(int code, int lineNumber, char ch)
+  {
+    this(code, lineNumber, ch, (String) null);
+  }
+
+  public Token(int code, int lineNumber, String s)
+  {
+    this(code, lineNumber, (char) 0, s);
+  }
+
+  public Token(int code, int lineNumber, char ch, String s)
+  {
+    this.code=code;
+    this.lineNumber = lineNumber;
+    this.ch=ch;
+    string = s;
+  }
+
+  public String toString()
+  {
+    return "Token code:"+code+" line:"+lineNumber+
+      " char:"+ch+" string:"+string;
+  }
+
+  public final int code, lineNumber;
+  public final char ch;
+  public final String string;
+
+  public static final int EOF =                 0;
+  public static final int NEWLINE =             10;
+  public static final int WHITESPACE =          11;
+  public static final int PERIOD =              12;
+  public static final int SEMICOLON =           13;
+  public static final int QUOTED =              20;
+  public static final int NAME =                30;
+  public static final int NUMBER =              40;
+  public static final int COMMENT =             50;
+  public static final int REGULAR_EXP =         60;
+  public static final int REGULAR_EXP_MODIFIER =65;
+  public static final int CONTROL =             100;
+  public static final int LEFT_BRACE =          110;
+  public static final int RIGHT_BRACE =         120;
+  public static final int RESERVED =            200; //reserved words
+
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Token.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenBuffer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenBuffer.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenBuffer.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenBuffer.java Mon Jul 24 17:24:16 2006
@@ -1,96 +1,96 @@
-/*
- * Copyright 2000-2002,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.trinidadbuild.plugin.javascript.uixtools;
-
-import java.io.IOException;
-
-/**
- * A buffer to hold Token objects. Tokens can be read from and written to this
- * buffer as if it were a queue. it is thread safe. Best if a single thread is
- * reading and a single thread is writing.
- * @version $Name:  $ ($Revision$) $Date$
- * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
- */
-public class TokenBuffer extends Queue implements TokenReader
-{
-
-  /**
-   * @param bufferSize the maximum size of this buffer.
-   */
-  public TokenBuffer(int bufferSize)
-  {
-    super(bufferSize);
-  }
-
-  public TokenBuffer()
-  {
-    this(100);
-  }
-
-  /**
-   * reads a Token from this buffer. This method blocks until data is available
-   * @return null if there is no more data and this buffer has been closed.
-   * @see TokenReader
-   */
-  public synchronized Token read() throws IOException, InterruptedException
-  {
-    Token tok;
-    try
-    {
-      tok = (Token) super.remove();
-    }
-    catch (IllegalStateException e)
-    {
-      tok = null;
-    }
-
-    if (tok==_EXCEPTION_TOKEN)
-    {
-      throw _getException();
-    }
-    return tok;
-  }
-
-  /**
-   * This method blocks if the buffer is full.
-   * @param tok the token to write to this buffer
-   */
-  public synchronized void write(Token tok) throws InterruptedException
-  {
-    super.add(tok);
-  }
-
-  public synchronized void write(IOException e) throws InterruptedException
-  {
-    _setException(e);
-    write(_EXCEPTION_TOKEN);
-    close();
-  }
-
-  private synchronized void _setException(IOException e)
-  {
-    _exception = e;
-  }
-
-  private synchronized IOException _getException()
-  {
-    return _exception;
-  }
-
-  private IOException _exception = null;
-
-  private static final Token _EXCEPTION_TOKEN = new Token(-1, 0);
+/*
+ * Copyright 2000-2002,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.trinidadbuild.plugin.javascript.uixtools;
+
+import java.io.IOException;
+
+/**
+ * A buffer to hold Token objects. Tokens can be read from and written to this
+ * buffer as if it were a queue. it is thread safe. Best if a single thread is
+ * reading and a single thread is writing.
+ * @version $Name:  $ ($Revision$) $Date$
+ * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
+ */
+public class TokenBuffer extends Queue implements TokenReader
+{
+
+  /**
+   * @param bufferSize the maximum size of this buffer.
+   */
+  public TokenBuffer(int bufferSize)
+  {
+    super(bufferSize);
+  }
+
+  public TokenBuffer()
+  {
+    this(100);
+  }
+
+  /**
+   * reads a Token from this buffer. This method blocks until data is available
+   * @return null if there is no more data and this buffer has been closed.
+   * @see TokenReader
+   */
+  public synchronized Token read() throws IOException, InterruptedException
+  {
+    Token tok;
+    try
+    {
+      tok = (Token) super.remove();
+    }
+    catch (IllegalStateException e)
+    {
+      tok = null;
+    }
+
+    if (tok==_EXCEPTION_TOKEN)
+    {
+      throw _getException();
+    }
+    return tok;
+  }
+
+  /**
+   * This method blocks if the buffer is full.
+   * @param tok the token to write to this buffer
+   */
+  public synchronized void write(Token tok) throws InterruptedException
+  {
+    super.add(tok);
+  }
+
+  public synchronized void write(IOException e) throws InterruptedException
+  {
+    _setException(e);
+    write(_EXCEPTION_TOKEN);
+    close();
+  }
+
+  private synchronized void _setException(IOException e)
+  {
+    _exception = e;
+  }
+
+  private synchronized IOException _getException()
+  {
+    return _exception;
+  }
+
+  private IOException _exception = null;
+
+  private static final Token _EXCEPTION_TOKEN = new Token(-1, 0);
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenBuffer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenException.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenException.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenException.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenException.java Mon Jul 24 17:24:16 2006
@@ -1,36 +1,36 @@
-/*
- * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
-
-/**
- * @version $Name:  $ ($Revision$) $Date$
- * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
- */
-public class TokenException extends RuntimeException
-{
-  private final Token _token;
-
-  public TokenException(Token token, String message)
-  {
-    super(message);
-    _token = token;
-  }
-
-  public Token getToken()
-  {
-    return _token;
-  }
+/*
+ * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
+
+/**
+ * @version $Name:  $ ($Revision$) $Date$
+ * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
+ */
+public class TokenException extends RuntimeException
+{
+  private final Token _token;
+
+  public TokenException(Token token, String message)
+  {
+    super(message);
+    _token = token;
+  }
+
+  public Token getToken()
+  {
+    return _token;
+  }
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenReader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenReader.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenReader.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenReader.java Mon Jul 24 17:24:16 2006
@@ -1,33 +1,33 @@
-/*
- * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
-
-import java.io.IOException;
-
-/**
- * @version $Name:  $ ($Revision$) $Date$
- * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
- */
-public interface TokenReader
-{
-
-  /*
-   * Reads a Token from this source. This method will block until data
-   * becomes available.
-   * @return null if there is no more data and EOF is reached.
-   */
-  public Token read() throws IOException, InterruptedException;
+/*
+ * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
+
+import java.io.IOException;
+
+/**
+ * @version $Name:  $ ($Revision$) $Date$
+ * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
+ */
+public interface TokenReader
+{
+
+  /*
+   * Reads a Token from this source. This method will block until data
+   * becomes available.
+   * @return null if there is no more data and EOF is reached.
+   */
+  public Token read() throws IOException, InterruptedException;
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/TokenReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Tokenizer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Tokenizer.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Tokenizer.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Tokenizer.java Mon Jul 24 17:24:16 2006
@@ -1,421 +1,421 @@
-/*
- * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-
-/**
- * A Tokenizer for JavaScript source files.
- * @version $Name:  $ ($Revision$) $Date$
- * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
- */
-public class Tokenizer implements TokenReader
-{
-
-  /**
-   * @param in used to read data from the JS file
-   */
-  public Tokenizer(BufferedReader in)
-  {
-    _in = in;
-    Runnable runner = new Runnable()
-      {
-        public void run()
-        {
-          //ystem.out.println("Tokenizer: start:"+Thread.currentThread());
-          _run();
-          //ystem.out.println("Tokenizer: end:"+Thread.currentThread());
-        }
-      };
-    new Thread(runner).start();
-  }
-
-  /**
-   * reads a Token. blocks until a Token is available.
-   * @return null if the EOF is reached.
-   */
-  public Token read() throws IOException, InterruptedException
-  {
-    return _out.read();
-  }
-
-  private void _run()
-  {
-    try
-      {
-        _run2();
-      }
-    catch (Exception e)
-      {
-        System.out.println("Exception parsing line:"+_lineNumber);
-        e.printStackTrace();
-      }
-  }
-
-  private void _run2() throws InterruptedException
-  {
-    try
-    {
-      for(;_fillBuffer();)
-      {
-        //ystem.out.println("begin process");
-        _processBuffer();
-        //ystem.out.println("end process");
-      }
-      _out.write(new Token(Token.EOF, _lineNumber));
-    }
-    catch (IOException e)
-    {
-      System.out.println("Exception parsing line:"+_lineNumber);
-      _out.write(e);
-    }
-    catch (Exception e)
-    {
-      e.printStackTrace();
-      _out.write(new IOException("Exception parsing line:"+_lineNumber));
-    }
-    finally
-    {
-      _out.close();
-    }
-  }
-
-  private void _processBuffer() throws InterruptedException
-  {
-    _offset = 0;
-
-    for(;_offset<_len;)
-      {
-        //ystem.out.println("line:"+_lineNumber+" offset:"+_offset);
-        char ch = _buffer.charAt(_offset++);
-        switch(_status)
-          {
-          case ROOT_MODE :
-          case DIVISION_MODE :
-            _next = _rootMode(ch, _status);
-            break;
-          case READ_WORD_MODE :
-            _next = _readWordMode(ch, _status, _str);
-            break;
-          case QUOTE1_MODE :
-          case QUOTE2_MODE :
-            _next = _quoteMode(ch, _status, _prev, _str);
-            break;
-          case ESCAPED_CHAR_MODE :
-            _str.append('\\');
-            _str.append(ch);
-            _next = _prev;
-            break;
-          case POSSIBLE_COMMENT_MODE :
-            if (ch=='/') _next = COMMENT1_MODE;
-            else if (ch=='*') _next = COMMENT2_MODE;
-            else
-              {
-                _offset--; //Roll Back one
-                if (_prev == DIVISION_MODE)
-                  {
-                    _writeControl('/');
-                    _next = ROOT_MODE;
-                  }
-                else
-                  {
-                    _next = REGULAR_EXP_MODE;
-                  }
-              }
-            break;
-          case COMMENT1_MODE :
-          case COMMENT2_MODE :
-          case END_COMMENT_MODE :
-            _next = _commentMode(ch, _status, _str);
-            break;
-          case REGULAR_EXP_MODE :
-            _next = _regularExpMode(ch, _str);
-            break;
-          case END_REGULAR_EXP_MODE :
-            if ((ch=='g') || (ch=='i'))
-              {
-                _out.write(new Token(Token.REGULAR_EXP_MODIFIER,
-                                     _lineNumber,
-                                     ch));
-                _next = END_REGULAR_EXP_MODE;
-              }
-            else
-              {
-                _offset--; //Rollback
-                _next = ROOT_MODE;
-              }
-            break;
-          }
-        _prev = _status;
-        _status = _next;
-      }
-  }
-
-  private int _rootMode(char ch, int status) throws InterruptedException
-  {
-    switch(ch)
-      {
-      case '\'' :
-        return QUOTE1_MODE;
-      case '\"' :
-        return QUOTE2_MODE;
-      case ' '  :
-      case '\t' :
-        _out.write(WHITESPACE);
-        return status;
-      case '\n' :
-        _out.write(NEWLINE);
-        return ROOT_MODE;
-      case '.' :
-        _out.write(PERIOD);
-        return status;
-      case ';' :
-        _out.write(SEMICOLON);
-        return ROOT_MODE;
-      case '(' :
-      case '{' :
-      case '[' :
-        _out.write(new Token(Token.LEFT_BRACE, _lineNumber, ch));
-        return ROOT_MODE;
-      case ')' :
-        _out.write(new Token(Token.RIGHT_BRACE, _lineNumber, ch));
-        return DIVISION_MODE;
-      case '}' :
-      case ']' :
-        _out.write(new Token(Token.RIGHT_BRACE, _lineNumber, ch));
-        return ROOT_MODE;
-      case '/'  : return POSSIBLE_COMMENT_MODE;
-      default :
-        if (_isAlphaNumeric(ch))
-          {
-            _offset--; //Rollback
-            return READ_WORD_MODE;
-          }
-        else
-          {
-            _writeControl(ch);
-            return ROOT_MODE;
-          }
-      }
-  }
-
-  private int _regularExpMode(char ch, StringBuffer regExp)
-    throws InterruptedException
-  {
-    switch(ch)
-      {
-      case '\\' :
-        return ESCAPED_CHAR_MODE;
-      case '/' :
-        _out.write(new Token(Token.REGULAR_EXP,
-                             _lineNumber,
-                             regExp.toString()));
-        regExp.setLength(0);
-        return END_REGULAR_EXP_MODE;
-      default :
-        regExp.append(ch);
-        return REGULAR_EXP_MODE;
-      }
-  }
-
-  private int _quoteMode(char ch, int status, int prev,
-                         StringBuffer quoteString) throws InterruptedException
-  {
-    if (((ch=='\'') && (status==QUOTE1_MODE)) ||
-        ((ch=='\"') && (status==QUOTE2_MODE)))
-      {
-        _out.write(new Token(Token.QUOTED,
-                             _lineNumber, ch, quoteString.toString()));
-        quoteString.setLength(0);
-        return ROOT_MODE;
-      }
-    else if (ch=='\\') return ESCAPED_CHAR_MODE;
-    else
-      {
-        quoteString.append(ch);
-        return status;
-      }
-  }
-
-  private int _commentMode(char ch, int status,
-                           StringBuffer commentString)
-    throws InterruptedException
-  {
-    if (status==END_COMMENT_MODE)
-      {
-        if (ch=='/')
-          {
-            _writeComment(commentString);
-            return ROOT_MODE;
-          }
-        else
-          {
-            commentString.append('*');
-            _offset--; //Roll back
-            return COMMENT2_MODE;
-          }
-      }
-    else if ((status==COMMENT2_MODE) && (ch=='*'))
-      {
-        return END_COMMENT_MODE;
-      }
-    else if ((status==COMMENT1_MODE) && (ch=='\n'))
-      {
-        _writeComment(commentString);
-        _out.write(NEWLINE);
-        return ROOT_MODE;
-      }
-    else
-      {
-        commentString.append(ch);
-        return status;
-      }
-  }
-
-  private int _readWordMode(char ch, int status, StringBuffer wordBuffer)
-    throws InterruptedException
-  {
-    if (_isAlphaNumeric(ch))
-      {
-        wordBuffer.append(ch);
-        return status;
-      }
-    else
-      {
-        _writeAlphaNumeric(wordBuffer.toString());
-        wordBuffer.setLength(0);
-        _offset--; //Rollback
-        return DIVISION_MODE;
-      }
-  }
-
-  private void _writeComment(StringBuffer s) throws InterruptedException
-  {
-    _out.write(new Token(Token.COMMENT, _lineNumber, s.toString()));
-    s.setLength(0);
-  }
-
-  private void _writeControl(char ch) throws InterruptedException
-  {
-    _out.write(new Token(Token.CONTROL, _lineNumber, ch));
-  }
-
-  private void _writeAlphaNumeric(String s) throws InterruptedException
-  {
-    if (Character.isDigit(s.charAt(0)))
-      {
-        _out.write(new Token(Token.NUMBER, _lineNumber, s));
-      }
-    else if (_isReservedKeyword(s))
-      {
-        _out.write(new Token(Token.RESERVED, _lineNumber, s));
-      }
-    else
-      {
-        _out.write(new Token(Token.NAME, _lineNumber, s));
-      }
-  }
-
-  private boolean _isReservedKeyword(String s)
-  {
-    for(int i=0; i<reservedWords.length; i++)
-      {
-        if (s.equals(reservedWords[i])) return true;
-      }
-    return false;
-  }
-
-  private boolean _isAlphaNumeric(char ch)
-  {
-    return Character.isLetterOrDigit(ch) || (ch=='_') ;
-  }
-
-  /**
-   * @return false if EOF
-   */
-  private boolean _fillBuffer() throws IOException
-  {
-    _buffer.setLength(0);
-    String s = _in.readLine();
-    if (s==null)
-      {
-        _len=0;
-        return false;
-      }
-    else
-      {
-        _buffer.append(s).append('\n');
-        _len = _buffer.length();
-        _lineNumber++;
-        return true;
-      }
-  }
-
-  private void _reset()
-  {
-    _status = _prev = _next = ROOT_MODE;
-    _buffer.setLength(0);
-    _len = _lineNumber = _offset = 0;
-    _wordBuffer.setLength(0);
-    _str.setLength(0);
-  }
-
-  private int _status = ROOT_MODE;
-  private int _prev = ROOT_MODE;
-  private int _next = ROOT_MODE;
-
-  private int _len = 0;
-  private int _lineNumber = 0;
-  private int _offset = 0;
-
-  private final StringBuffer _buffer = new StringBuffer();
-  private final StringBuffer _wordBuffer = new StringBuffer();
-  private final StringBuffer _str = new StringBuffer();
-
-  private final BufferedReader _in;
-  private final TokenBuffer _out = new TokenBuffer();
-
-  /**
-   * These are not all the reserved words in JS but are the only ones
-   * important to the filters.
-   */
-  private static final String[] reservedWords =
-  {
-    "function", "var"
-  };
-
-  private final Token NEWLINE = new Token(Token.NEWLINE, 0);
-  private final Token WHITESPACE = new Token(Token.WHITESPACE, 0);
-  private final Token PERIOD = new Token(Token.PERIOD, 0);
-  private final Token SEMICOLON = new Token(Token.SEMICOLON, 0);
-
-  /**
-   * These are the FSM states
-   */
-  private static final int ROOT_MODE = 0;
-  private static final int READ_WORD_MODE = 10;
-  private static final int DIVISION_MODE = 15;
-  private static final int QUOTE1_MODE = 20;
-  private static final int QUOTE2_MODE = 30;
-  private static final int ESCAPED_CHAR_MODE = 40;
-  private static final int POSSIBLE_COMMENT_MODE = 50;
-  private static final int COMMENT1_MODE = 60;
-  private static final int COMMENT2_MODE = 70;
-  private static final int END_COMMENT_MODE = 80;
-  private static final int REGULAR_EXP_MODE = 90;
-  private static final int END_REGULAR_EXP_MODE = 95;
+/*
+ * Copyright 2000-2001,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.trinidadbuild.plugin.javascript.uixtools;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+
+/**
+ * A Tokenizer for JavaScript source files.
+ * @version $Name:  $ ($Revision$) $Date$
+ * @author Arjuna Wijeyekoon - arjuna.wijeyekoon@oracle.com
+ */
+public class Tokenizer implements TokenReader
+{
+
+  /**
+   * @param in used to read data from the JS file
+   */
+  public Tokenizer(BufferedReader in)
+  {
+    _in = in;
+    Runnable runner = new Runnable()
+      {
+        public void run()
+        {
+          //ystem.out.println("Tokenizer: start:"+Thread.currentThread());
+          _run();
+          //ystem.out.println("Tokenizer: end:"+Thread.currentThread());
+        }
+      };
+    new Thread(runner).start();
+  }
+
+  /**
+   * reads a Token. blocks until a Token is available.
+   * @return null if the EOF is reached.
+   */
+  public Token read() throws IOException, InterruptedException
+  {
+    return _out.read();
+  }
+
+  private void _run()
+  {
+    try
+      {
+        _run2();
+      }
+    catch (Exception e)
+      {
+        System.out.println("Exception parsing line:"+_lineNumber);
+        e.printStackTrace();
+      }
+  }
+
+  private void _run2() throws InterruptedException
+  {
+    try
+    {
+      for(;_fillBuffer();)
+      {
+        //ystem.out.println("begin process");
+        _processBuffer();
+        //ystem.out.println("end process");
+      }
+      _out.write(new Token(Token.EOF, _lineNumber));
+    }
+    catch (IOException e)
+    {
+      System.out.println("Exception parsing line:"+_lineNumber);
+      _out.write(e);
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      _out.write(new IOException("Exception parsing line:"+_lineNumber));
+    }
+    finally
+    {
+      _out.close();
+    }
+  }
+
+  private void _processBuffer() throws InterruptedException
+  {
+    _offset = 0;
+
+    for(;_offset<_len;)
+      {
+        //ystem.out.println("line:"+_lineNumber+" offset:"+_offset);
+        char ch = _buffer.charAt(_offset++);
+        switch(_status)
+          {
+          case ROOT_MODE :
+          case DIVISION_MODE :
+            _next = _rootMode(ch, _status);
+            break;
+          case READ_WORD_MODE :
+            _next = _readWordMode(ch, _status, _str);
+            break;
+          case QUOTE1_MODE :
+          case QUOTE2_MODE :
+            _next = _quoteMode(ch, _status, _prev, _str);
+            break;
+          case ESCAPED_CHAR_MODE :
+            _str.append('\\');
+            _str.append(ch);
+            _next = _prev;
+            break;
+          case POSSIBLE_COMMENT_MODE :
+            if (ch=='/') _next = COMMENT1_MODE;
+            else if (ch=='*') _next = COMMENT2_MODE;
+            else
+              {
+                _offset--; //Roll Back one
+                if (_prev == DIVISION_MODE)
+                  {
+                    _writeControl('/');
+                    _next = ROOT_MODE;
+                  }
+                else
+                  {
+                    _next = REGULAR_EXP_MODE;
+                  }
+              }
+            break;
+          case COMMENT1_MODE :
+          case COMMENT2_MODE :
+          case END_COMMENT_MODE :
+            _next = _commentMode(ch, _status, _str);
+            break;
+          case REGULAR_EXP_MODE :
+            _next = _regularExpMode(ch, _str);
+            break;
+          case END_REGULAR_EXP_MODE :
+            if ((ch=='g') || (ch=='i'))
+              {
+                _out.write(new Token(Token.REGULAR_EXP_MODIFIER,
+                                     _lineNumber,
+                                     ch));
+                _next = END_REGULAR_EXP_MODE;
+              }
+            else
+              {
+                _offset--; //Rollback
+                _next = ROOT_MODE;
+              }
+            break;
+          }
+        _prev = _status;
+        _status = _next;
+      }
+  }
+
+  private int _rootMode(char ch, int status) throws InterruptedException
+  {
+    switch(ch)
+      {
+      case '\'' :
+        return QUOTE1_MODE;
+      case '\"' :
+        return QUOTE2_MODE;
+      case ' '  :
+      case '\t' :
+        _out.write(WHITESPACE);
+        return status;
+      case '\n' :
+        _out.write(NEWLINE);
+        return ROOT_MODE;
+      case '.' :
+        _out.write(PERIOD);
+        return status;
+      case ';' :
+        _out.write(SEMICOLON);
+        return ROOT_MODE;
+      case '(' :
+      case '{' :
+      case '[' :
+        _out.write(new Token(Token.LEFT_BRACE, _lineNumber, ch));
+        return ROOT_MODE;
+      case ')' :
+        _out.write(new Token(Token.RIGHT_BRACE, _lineNumber, ch));
+        return DIVISION_MODE;
+      case '}' :
+      case ']' :
+        _out.write(new Token(Token.RIGHT_BRACE, _lineNumber, ch));
+        return ROOT_MODE;
+      case '/'  : return POSSIBLE_COMMENT_MODE;
+      default :
+        if (_isAlphaNumeric(ch))
+          {
+            _offset--; //Rollback
+            return READ_WORD_MODE;
+          }
+        else
+          {
+            _writeControl(ch);
+            return ROOT_MODE;
+          }
+      }
+  }
+
+  private int _regularExpMode(char ch, StringBuffer regExp)
+    throws InterruptedException
+  {
+    switch(ch)
+      {
+      case '\\' :
+        return ESCAPED_CHAR_MODE;
+      case '/' :
+        _out.write(new Token(Token.REGULAR_EXP,
+                             _lineNumber,
+                             regExp.toString()));
+        regExp.setLength(0);
+        return END_REGULAR_EXP_MODE;
+      default :
+        regExp.append(ch);
+        return REGULAR_EXP_MODE;
+      }
+  }
+
+  private int _quoteMode(char ch, int status, int prev,
+                         StringBuffer quoteString) throws InterruptedException
+  {
+    if (((ch=='\'') && (status==QUOTE1_MODE)) ||
+        ((ch=='\"') && (status==QUOTE2_MODE)))
+      {
+        _out.write(new Token(Token.QUOTED,
+                             _lineNumber, ch, quoteString.toString()));
+        quoteString.setLength(0);
+        return ROOT_MODE;
+      }
+    else if (ch=='\\') return ESCAPED_CHAR_MODE;
+    else
+      {
+        quoteString.append(ch);
+        return status;
+      }
+  }
+
+  private int _commentMode(char ch, int status,
+                           StringBuffer commentString)
+    throws InterruptedException
+  {
+    if (status==END_COMMENT_MODE)
+      {
+        if (ch=='/')
+          {
+            _writeComment(commentString);
+            return ROOT_MODE;
+          }
+        else
+          {
+            commentString.append('*');
+            _offset--; //Roll back
+            return COMMENT2_MODE;
+          }
+      }
+    else if ((status==COMMENT2_MODE) && (ch=='*'))
+      {
+        return END_COMMENT_MODE;
+      }
+    else if ((status==COMMENT1_MODE) && (ch=='\n'))
+      {
+        _writeComment(commentString);
+        _out.write(NEWLINE);
+        return ROOT_MODE;
+      }
+    else
+      {
+        commentString.append(ch);
+        return status;
+      }
+  }
+
+  private int _readWordMode(char ch, int status, StringBuffer wordBuffer)
+    throws InterruptedException
+  {
+    if (_isAlphaNumeric(ch))
+      {
+        wordBuffer.append(ch);
+        return status;
+      }
+    else
+      {
+        _writeAlphaNumeric(wordBuffer.toString());
+        wordBuffer.setLength(0);
+        _offset--; //Rollback
+        return DIVISION_MODE;
+      }
+  }
+
+  private void _writeComment(StringBuffer s) throws InterruptedException
+  {
+    _out.write(new Token(Token.COMMENT, _lineNumber, s.toString()));
+    s.setLength(0);
+  }
+
+  private void _writeControl(char ch) throws InterruptedException
+  {
+    _out.write(new Token(Token.CONTROL, _lineNumber, ch));
+  }
+
+  private void _writeAlphaNumeric(String s) throws InterruptedException
+  {
+    if (Character.isDigit(s.charAt(0)))
+      {
+        _out.write(new Token(Token.NUMBER, _lineNumber, s));
+      }
+    else if (_isReservedKeyword(s))
+      {
+        _out.write(new Token(Token.RESERVED, _lineNumber, s));
+      }
+    else
+      {
+        _out.write(new Token(Token.NAME, _lineNumber, s));
+      }
+  }
+
+  private boolean _isReservedKeyword(String s)
+  {
+    for(int i=0; i<reservedWords.length; i++)
+      {
+        if (s.equals(reservedWords[i])) return true;
+      }
+    return false;
+  }
+
+  private boolean _isAlphaNumeric(char ch)
+  {
+    return Character.isLetterOrDigit(ch) || (ch=='_') ;
+  }
+
+  /**
+   * @return false if EOF
+   */
+  private boolean _fillBuffer() throws IOException
+  {
+    _buffer.setLength(0);
+    String s = _in.readLine();
+    if (s==null)
+      {
+        _len=0;
+        return false;
+      }
+    else
+      {
+        _buffer.append(s).append('\n');
+        _len = _buffer.length();
+        _lineNumber++;
+        return true;
+      }
+  }
+
+  private void _reset()
+  {
+    _status = _prev = _next = ROOT_MODE;
+    _buffer.setLength(0);
+    _len = _lineNumber = _offset = 0;
+    _wordBuffer.setLength(0);
+    _str.setLength(0);
+  }
+
+  private int _status = ROOT_MODE;
+  private int _prev = ROOT_MODE;
+  private int _next = ROOT_MODE;
+
+  private int _len = 0;
+  private int _lineNumber = 0;
+  private int _offset = 0;
+
+  private final StringBuffer _buffer = new StringBuffer();
+  private final StringBuffer _wordBuffer = new StringBuffer();
+  private final StringBuffer _str = new StringBuffer();
+
+  private final BufferedReader _in;
+  private final TokenBuffer _out = new TokenBuffer();
+
+  /**
+   * These are not all the reserved words in JS but are the only ones
+   * important to the filters.
+   */
+  private static final String[] reservedWords =
+  {
+    "function", "var"
+  };
+
+  private final Token NEWLINE = new Token(Token.NEWLINE, 0);
+  private final Token WHITESPACE = new Token(Token.WHITESPACE, 0);
+  private final Token PERIOD = new Token(Token.PERIOD, 0);
+  private final Token SEMICOLON = new Token(Token.SEMICOLON, 0);
+
+  /**
+   * These are the FSM states
+   */
+  private static final int ROOT_MODE = 0;
+  private static final int READ_WORD_MODE = 10;
+  private static final int DIVISION_MODE = 15;
+  private static final int QUOTE1_MODE = 20;
+  private static final int QUOTE2_MODE = 30;
+  private static final int ESCAPED_CHAR_MODE = 40;
+  private static final int POSSIBLE_COMMENT_MODE = 50;
+  private static final int COMMENT1_MODE = 60;
+  private static final int COMMENT2_MODE = 70;
+  private static final int END_COMMENT_MODE = 80;
+  private static final int REGULAR_EXP_MODE = 90;
+  private static final int END_REGULAR_EXP_MODE = 95;
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/uixtools/Tokenizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-jdev-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-jdev-plugin/pom.xml?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-jdev-plugin/pom.xml (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-jdev-plugin/pom.xml Mon Jul 24 17:24:16 2006
@@ -1,39 +1,39 @@
-<project> 
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.myfaces.trinidadbuild</groupId>
-    <artifactId>maven-plugin-parent</artifactId> 
-    <version>incubator-alpha-1-SNAPSHOT</version>
-  </parent>
-
-  <groupId>org.apache.myfaces.trinidadbuild</groupId>
-  <artifactId>maven-jdev-plugin</artifactId> 
-  <version>incubator-alpha-2-SNAPSHOT</version>
-  <packaging>maven-plugin</packaging>
-  <name>Maven JDev Plugin</name>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-project</artifactId>
-      <version>2.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-      <version>2.0</version>
-    </dependency>
-    <dependency>
-      <groupId>stax</groupId>
-      <artifactId>stax-api</artifactId>
-      <version>1.0.1</version>
-    </dependency>
-    <dependency>
-      <groupId>stax</groupId>
-      <artifactId>stax</artifactId>
-      <version>1.2.0_rc2-dev</version>
-    </dependency>
-  </dependencies>
-
+<project> 
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.myfaces.trinidadbuild</groupId>
+    <artifactId>maven-plugin-parent</artifactId> 
+    <version>incubator-alpha-1-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.myfaces.trinidadbuild</groupId>
+  <artifactId>maven-jdev-plugin</artifactId> 
+  <version>incubator-alpha-2-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+  <name>Maven JDev Plugin</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax-api</artifactId>
+      <version>1.0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax</artifactId>
+      <version>1.2.0_rc2-dev</version>
+    </dependency>
+  </dependencies>
+
 </project>

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-jdev-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/JDeveloperMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-tagdoc-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java
------------------------------------------------------------------------------
    svn:eol-style = native