myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1239799 [9/9] - in /myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared: application/ config/ context/flash/ renderkit/ renderkit/html/ renderkit/html/util/ resource/ util/ util/io/ util/xml/
Date Thu, 02 Feb 2012 20:00:44 GMT
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java
Thu Feb  2 20:00:42 2012
@@ -1,154 +1,154 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.shared.util.io;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-
-/**
- * NOTE: Copy of org.apache.abdera.i18n.text.io.DynamicPushbackInputStream
- * 
- * PushbackInputStream implementation that performs dynamic resizing of the unread buffer
- */
-public class DynamicPushbackInputStream extends PushbackInputStream
-{
-
-    private final int origsize;
-
-    public DynamicPushbackInputStream(InputStream in)
-    {
-        super(in);
-        this.origsize = 1;
-    }
-
-    public DynamicPushbackInputStream(InputStream in, int initialSize)
-    {
-        super(in, initialSize);
-        this.origsize = initialSize;
-    }
-
-    /**
-     * Clear the buffer
-     */
-    public int clear()
-    {
-        int m = buf.length;
-        buf = new byte[origsize];
-        pos = origsize;
-        return m;
-    }
-
-    /**
-     * Shrink the buffer. This will reclaim currently unused space in the buffer, reducing
memory but potentially
-     * increasing the cost of resizing the buffer
-     */
-    public int shrink()
-    {
-        byte[] old = buf;
-        if (pos == 0)
-        {
-            return 0; // nothing to do
-        }
-        int n = old.length - pos;
-        int m;
-        int p;
-        int s;
-        int l;
-        if (n < origsize)
-        {
-            buf = new byte[origsize];
-            p = pos;
-            s = origsize - n;
-            l = old.length - p;
-            m = old.length - origsize;
-            pos = s;
-        }
-        else
-        {
-            buf = new byte[n];
-            p = pos;
-            s = 0;
-            l = n;
-            m = old.length - l;
-            pos = 0;
-        }
-        System.arraycopy(old, p, buf, s, l);
-        return m;
-    }
-
-    private void resize(int len)
-    {
-        byte[] old = buf;
-        buf = new byte[old.length + len];
-        System.arraycopy(old, 0, buf, len, old.length);
-    }
-
-    public void unread(byte[] b, int off, int len) throws IOException
-    {
-        if (len > pos && pos + len > buf.length)
-        {
-            resize(len - pos);
-            pos += len - pos;
-        }
-        super.unread(b, off, len);
-    }
-
-    public void unread(int b) throws IOException
-    {
-        if (pos == 0)
-        {
-            resize(1);
-            pos++;
-        }
-        super.unread(b);
-    }
-
-    public int read() throws IOException
-    {
-        int m = super.read();
-        if (pos >= buf.length && buf.length > origsize)
-        {
-            shrink();
-        }
-        return m;
-    }
-
-    public int read(byte[] b, int off, int len) throws IOException
-    {
-        this.available(); // workaround for a problem in PushbackInputStream, without this,
the amount of bytes read
-                          // from some streams will be incorrect
-        int r = super.read(b, off, len);
-        if (pos >= buf.length && buf.length > origsize)
-        {
-            shrink();
-        }
-        return r;
-    }
-
-    public long skip(long n) throws IOException
-    {
-        long r = super.skip(n);
-        if (pos >= buf.length && buf.length > origsize)
-        {
-            shrink();
-        }
-        return r;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.shared.util.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+
+/**
+ * NOTE: Copy of org.apache.abdera.i18n.text.io.DynamicPushbackInputStream
+ * 
+ * PushbackInputStream implementation that performs dynamic resizing of the unread buffer
+ */
+public class DynamicPushbackInputStream extends PushbackInputStream
+{
+
+    private final int origsize;
+
+    public DynamicPushbackInputStream(InputStream in)
+    {
+        super(in);
+        this.origsize = 1;
+    }
+
+    public DynamicPushbackInputStream(InputStream in, int initialSize)
+    {
+        super(in, initialSize);
+        this.origsize = initialSize;
+    }
+
+    /**
+     * Clear the buffer
+     */
+    public int clear()
+    {
+        int m = buf.length;
+        buf = new byte[origsize];
+        pos = origsize;
+        return m;
+    }
+
+    /**
+     * Shrink the buffer. This will reclaim currently unused space in the buffer, reducing
memory but potentially
+     * increasing the cost of resizing the buffer
+     */
+    public int shrink()
+    {
+        byte[] old = buf;
+        if (pos == 0)
+        {
+            return 0; // nothing to do
+        }
+        int n = old.length - pos;
+        int m;
+        int p;
+        int s;
+        int l;
+        if (n < origsize)
+        {
+            buf = new byte[origsize];
+            p = pos;
+            s = origsize - n;
+            l = old.length - p;
+            m = old.length - origsize;
+            pos = s;
+        }
+        else
+        {
+            buf = new byte[n];
+            p = pos;
+            s = 0;
+            l = n;
+            m = old.length - l;
+            pos = 0;
+        }
+        System.arraycopy(old, p, buf, s, l);
+        return m;
+    }
+
+    private void resize(int len)
+    {
+        byte[] old = buf;
+        buf = new byte[old.length + len];
+        System.arraycopy(old, 0, buf, len, old.length);
+    }
+
+    public void unread(byte[] b, int off, int len) throws IOException
+    {
+        if (len > pos && pos + len > buf.length)
+        {
+            resize(len - pos);
+            pos += len - pos;
+        }
+        super.unread(b, off, len);
+    }
+
+    public void unread(int b) throws IOException
+    {
+        if (pos == 0)
+        {
+            resize(1);
+            pos++;
+        }
+        super.unread(b);
+    }
+
+    public int read() throws IOException
+    {
+        int m = super.read();
+        if (pos >= buf.length && buf.length > origsize)
+        {
+            shrink();
+        }
+        return m;
+    }
+
+    public int read(byte[] b, int off, int len) throws IOException
+    {
+        this.available(); // workaround for a problem in PushbackInputStream, without this,
the amount of bytes read
+                          // from some streams will be incorrect
+        int r = super.read(b, off, len);
+        if (pos >= buf.length && buf.length > origsize)
+        {
+            shrink();
+        }
+        return r;
+    }
+
+    public long skip(long n) throws IOException
+    {
+        long r = super.skip(n);
+        if (pos >= buf.length && buf.length > origsize)
+        {
+            shrink();
+        }
+        return r;
+    }
+}

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/xml/MyFacesErrorHandler.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/xml/MyFacesErrorHandler.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/xml/MyFacesErrorHandler.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/xml/MyFacesErrorHandler.java
Thu Feb  2 20:00:42 2012
@@ -41,7 +41,10 @@ public class MyFacesErrorHandler
 
     public void warning(SAXParseException exception)
     {
-        if (_log.isLoggable(Level.WARNING)) _log.log(Level.WARNING, getMessage(exception),
exception);
+        if (_log.isLoggable(Level.WARNING))
+        {
+            _log.log(Level.WARNING, getMessage(exception), exception);
+        }
     }
 
     public void error(SAXParseException exception)
@@ -56,7 +59,7 @@ public class MyFacesErrorHandler
 
     private String getMessage(SAXParseException exception)
     {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         buf.append("SAXParseException at");
         buf.append(" URI=");
         buf.append(exception.getSystemId());

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/xml/XmlUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/xml/XmlUtils.java?rev=1239799&r1=1239798&r2=1239799&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/xml/XmlUtils.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/util/xml/XmlUtils.java
Thu Feb  2 20:00:42 2012
@@ -39,7 +39,7 @@ public class XmlUtils
 
     public static String getElementText(Element elem)
     {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         NodeList nodeList = elem.getChildNodes();
         for (int i = 0, len = nodeList.getLength(); i < len; i++)
         {



Mime
View raw message