You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/08/30 16:33:59 UTC
svn commit: r571185 [2/3] - in /harmony/enhanced/classlib/branches/java6:
depends/jars/ make/
modules/auth/src/main/java/common/org/apache/harmony/auth/module/
modules/auth/src/test/java/common/org/apache/harmony/auth/tests/module/
modules/beans/src/ma...
Modified: harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/MemoryHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/MemoryHandler.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/MemoryHandler.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/MemoryHandler.java Thu Aug 30 07:33:56 2007
@@ -22,7 +22,6 @@
import org.apache.harmony.logging.internal.nls.Messages;
-
/**
* <code>MemoryHandler</code> is a <code>Handler</code> that 'remembers' a
* finite number of <code>LogRecord</code>s at a time and stores them in a
@@ -63,93 +62,96 @@
* specified either by property setting or by constructor.</li>
* </ul>
* </p>
- *
*/
public class MemoryHandler extends Handler {
- //default maximum buffered number of LogRecord
+ // default maximum buffered number of LogRecord
private static final int DEFAULT_SIZE = 1000;
- //target handler
+
+ // target handler
private Handler target;
-
- //buffer size
+
+ // buffer size
private int size = DEFAULT_SIZE;
-
- //push level
+
+ // push level
private Level push = Level.SEVERE;
- //LogManager instance for convenience
+ // LogManager instance for convenience
private final LogManager manager = LogManager.getLogManager();
-
- //buffer
+
+ // buffer
private LogRecord[] buffer;
-
- //current position in buffer
+
+ // current position in buffer
private int cursor;
-
+
/**
- * Default constructor, construct and init a <code>MemoryHandler</code> using
- * <code>LogManager</code> properties or default values
+ * Default constructor, construct and init a <code>MemoryHandler</code>
+ * using <code>LogManager</code> properties or default values
*/
public MemoryHandler() {
super();
String className = this.getClass().getName();
- //init target
- final String targetName = manager.getProperty(className+".target"); //$NON-NLS-1$
+ // init target
+ final String targetName = manager.getProperty(className + ".target"); //$NON-NLS-1$
try {
- Class<?> targetClass = AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>(){
- public Class<?> run() throws Exception{
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if(loader == null){
- loader = ClassLoader.getSystemClassLoader();
- }
- return loader.loadClass(targetName);
- }
- });
+ Class<?> targetClass = AccessController
+ .doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws Exception {
+ ClassLoader loader = Thread.currentThread()
+ .getContextClassLoader();
+ if (loader == null) {
+ loader = ClassLoader.getSystemClassLoader();
+ }
+ return loader.loadClass(targetName);
+ }
+ });
target = (Handler) targetClass.newInstance();
} catch (Exception e) {
// logging.10=Cannot load target handler:{0}
throw new RuntimeException(Messages.getString("logging.10", //$NON-NLS-1$
targetName));
}
- //init size
- String sizeString = manager.getProperty(className+".size"); //$NON-NLS-1$
+ // init size
+ String sizeString = manager.getProperty(className + ".size"); //$NON-NLS-1$
if (null != sizeString) {
try {
size = Integer.parseInt(sizeString);
- if(size <= 0){
+ if (size <= 0) {
size = DEFAULT_SIZE;
}
} catch (Exception e) {
- printInvalidPropMessage(className+".size", sizeString, e); //$NON-NLS-1$
+ printInvalidPropMessage(className + ".size", sizeString, e); //$NON-NLS-1$
}
}
- //init push level
- String pushName = manager.getProperty(className+".push"); //$NON-NLS-1$
+ // init push level
+ String pushName = manager.getProperty(className + ".push"); //$NON-NLS-1$
if (null != pushName) {
try {
push = Level.parse(pushName);
} catch (Exception e) {
- printInvalidPropMessage(className+".push", pushName, e); //$NON-NLS-1$
+ printInvalidPropMessage(className + ".push", pushName, e); //$NON-NLS-1$
}
}
- //init other properties which are common for all Handler
- initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$
+ // init other properties which are common for all Handler
+ initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$
buffer = new LogRecord[size];
}
-
+
/**
- * Construct and init a <code>MemoryHandler</code> using given target, size
- * and push level, other properties using <code>LogManager</code> properties
- * or default values
+ * Construct and init a <code>MemoryHandler</code> using given target,
+ * size and push level, other properties using <code>LogManager</code>
+ * properties or default values
*
* @param target
- * the given <code>Handler</code> to output
- * @param size the maximum number of buffered <code>LogRecord</code>
+ * the given <code>Handler</code> to output
+ * @param size
+ * the maximum number of buffered <code>LogRecord</code>
* @param pushLevel
- * the push level
+ * the push level
* @throws IllegalArgumentException
- * if size<=0
+ * if size<=0
*/
public MemoryHandler(Handler target, int size, Level pushLevel) {
if (size <= 0) {
@@ -161,16 +163,16 @@
this.target = target;
this.size = size;
this.push = pushLevel;
- initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$
+ initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$
buffer = new LogRecord[size];
}
-
+
/**
* Close this handler and target handler, free all associated resources
*
* @throws SecurityException
- * if security manager exists and it determines that caller
- * does not have the required permissions to control this handler
+ * if security manager exists and it determines that caller does
+ * not have the required permissions to control this handler
*/
@Override
public void close() {
@@ -183,7 +185,6 @@
* Call target handler to flush any buffered output.
*
* Note that this doesn't cause this <code>MemoryHandler</code> to push.
- *
*/
@Override
public void flush() {
@@ -193,12 +194,13 @@
/**
* Put a given <code>LogRecord</code> into internal buffer.
*
- * If given record is not loggable, just return. Otherwise it is stored in
+ * If given record is not loggable, just return. Otherwise it is stored in
* the buffer. Furthermore if the record's level is not less than the push
- * level, the push action is triggered to output all the buffered records
- * to the target handler, and the target handler will publish them.
+ * level, the push action is triggered to output all the buffered records to
+ * the target handler, and the target handler will publish them.
*
- * @param record the log record.
+ * @param record
+ * the log record.
*/
@Override
public synchronized void publish(LogRecord record) {
@@ -225,19 +227,19 @@
}
/**
- * <p>Check if given <code>LogRecord</code> would be put into this
+ * Check if given <code>LogRecord</code> would be put into this
* <code>MemoryHandler</code>'s internal buffer.
- * </p>
* <p>
- * The given <code>LogRecord</code> is loggable if and only if it has
- * appropriate level and it pass any associated filter's check.
+ * The given <code>LogRecord</code> is loggable if and only if it has
+ * appropriate level and it pass any associated filter's check.
* </p>
* <p>
- * Note that the push level is not used for this check.
+ * Note that the push level is not used for this check.
* </p>
+ *
* @param record
- * the given <code>LogRecord</code>
- * @return if the given <code>LogRecord</code> should be logged
+ * the given <code>LogRecord</code>
+ * @return if the given <code>LogRecord</code> should be logged
*/
@Override
public boolean isLoggable(LogRecord record) {
@@ -245,18 +247,19 @@
}
/**
- * Triggers a push action to output all buffered records to the target handler,
- * and the target handler will publish them. Then the buffer is cleared.
+ * Triggers a push action to output all buffered records to the target
+ * handler, and the target handler will publish them. Then the buffer is
+ * cleared.
*/
public void push() {
for (int i = cursor; i < size; i++) {
- if(null != buffer[i]) {
+ if (null != buffer[i]) {
target.publish(buffer[i]);
}
buffer[i] = null;
}
for (int i = 0; i < cursor; i++) {
- if(null != buffer[i]) {
+ if (null != buffer[i]) {
target.publish(buffer[i]);
}
buffer[i] = null;
@@ -265,16 +268,17 @@
}
/**
- * Set the push level. The push level is used to check the push action
+ * Set the push level. The push level is used to check the push action
* triggering. When a new <code>LogRecord</code> is put into the internal
- * buffer and its level is not less than the push level, the push action
- * will be triggered. Note that set new push level won't trigger push action.
+ * buffer and its level is not less than the push level, the push action
+ * will be triggered. Note that set new push level won't trigger push
+ * action.
*
* @param newLevel
- * the new level to set
+ * the new level to set
* @throws SecurityException
- * if security manager exists and it determines that caller
- * does not have the required permissions to control this handler
+ * if security manager exists and it determines that caller does
+ * not have the required permissions to control this handler
*/
public void setPushLevel(Level newLevel) {
manager.checkAccess();
Modified: harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/SimpleFormatter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/SimpleFormatter.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/SimpleFormatter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/SimpleFormatter.java Thu Aug 30 07:33:56 2007
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-
package java.util.logging;
import java.io.PrintWriter;
@@ -27,7 +26,6 @@
* <code>SimpleFormatter</code> can be used to print a summary of the
* information contained in a <code>LogRecord</code> object in a human
* readable format.
- *
*/
public class SimpleFormatter extends Formatter {
/**
@@ -43,7 +41,8 @@
sb.append(MessageFormat.format("{0, date} {0, time} ", //$NON-NLS-1$
new Object[] { new Date(r.getMillis()) }));
sb.append(r.getSourceClassName()).append(" "); //$NON-NLS-1$
- sb.append(r.getSourceMethodName()).append(LogManager.getSystemLineSeparator()); //$NON-NLS-1$
+ sb.append(r.getSourceMethodName()).append(
+ LogManager.getSystemLineSeparator());
sb.append(r.getLevel().getName()).append(": "); //$NON-NLS-1$
sb.append(formatMessage(r)).append(LogManager.getSystemLineSeparator());
if (null != r.getThrown()) {
@@ -56,7 +55,7 @@
t.printStackTrace(pw);
sb.append(sw.toString());
} finally {
- if(pw != null){
+ if (pw != null) {
try {
pw.close();
} catch (Exception e) {
@@ -68,4 +67,3 @@
return sb.toString();
}
}
-
Modified: harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/SocketHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/SocketHandler.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/SocketHandler.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/SocketHandler.java Thu Aug 30 07:33:56 2007
@@ -15,12 +15,11 @@
* limitations under the License.
*/
-
package java.util.logging;
-import java.net.Socket;
import java.io.BufferedOutputStream;
import java.io.IOException;
+import java.net.Socket;
import org.apache.harmony.logging.internal.nls.Messages;
@@ -56,9 +55,9 @@
* <p>
* This class is not thread-safe.
* </p>
- *
*/
public class SocketHandler extends StreamHandler {
+
// default level
private static final String DEFAULT_LEVEL = "ALL"; //$NON-NLS-1$
@@ -154,8 +153,8 @@
try {
super.close();
if (null != this.socket) {
- this.socket.close();
- this.socket = null;
+ this.socket.close();
+ this.socket = null;
}
} catch (Exception e) {
// logging.F=Exception occurred when closing the socket handler.
@@ -175,5 +174,4 @@
super.publish(record);
super.flush();
}
-
}
Modified: harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/StreamHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/StreamHandler.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/StreamHandler.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/StreamHandler.java Thu Aug 30 07:33:56 2007
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-
package java.util.logging;
import java.io.OutputStream;
@@ -46,9 +45,9 @@
* <p>
* This class is not thread-safe.
* </p>
- *
*/
public class StreamHandler extends Handler {
+
// the output stream this handler writes to
private OutputStream os;
@@ -63,7 +62,7 @@
* does not have an associated output stream.
*/
public StreamHandler() {
- initProperties("INFO", null, "java.util.logging.SimpleFormatter", //$NON-NLS-1$//$NON-NLS-2$
+ initProperties("INFO", null, "java.util.logging.SimpleFormatter", //$NON-NLS-1$//$NON-NLS-2$
null);
this.os = null;
this.writer = null;
@@ -158,7 +157,6 @@
this.os = newOs;
}
-
/**
* Sets the output stream this handler writes to. If there's an existing
* output stream, the tail string of the associated formatter will be
@@ -196,8 +194,8 @@
@Override
public void setEncoding(String encoding) throws SecurityException,
UnsupportedEncodingException {
- //flush first before set new encoding
- this.flush();
+ // flush first before set new encoding
+ this.flush();
super.setEncoding(encoding);
// renew writer only if the writer exists
if (null != this.writer) {
@@ -219,7 +217,8 @@
/**
* Closes this handler, but the underlying output stream is only closed when
- * <code>closeStream</code> is <code>true</code>. Security is not checked.
+ * <code>closeStream</code> is <code>true</code>. Security is not
+ * checked.
*
* @param closeStream
* whether to close the underlying output stream
@@ -234,8 +233,8 @@
this.writer.flush();
if (closeStream) {
this.writer.close();
- this.writer = null;
- this.os = null;
+ this.writer = null;
+ this.os = null;
}
} catch (Exception e) {
// logging.15=Exception occurred when closing the output stream.
@@ -274,7 +273,8 @@
this.os.flush();
}
} catch (Exception e) {
- // logging.16=Exception occurred while flushing the output stream.
+ // logging.16=Exception occurred while flushing the output
+ // stream.
getErrorManager().error(Messages.getString("logging.16"), //$NON-NLS-1$
e, ErrorManager.FLUSH_FAILURE);
}
@@ -309,7 +309,8 @@
try {
msg = getFormatter().format(record);
} catch (Exception e) {
- // logging.17=Exception occurred while formatting the log record.
+ // logging.17=Exception occurred while formatting the log
+ // record.
getErrorManager().error(Messages.getString("logging.17"), //$NON-NLS-1$
e, ErrorManager.FORMAT_FAILURE);
}
@@ -334,13 +335,12 @@
*/
@Override
public boolean isLoggable(LogRecord record) {
- if (null == record) {
- return false;
- }
+ if (null == record) {
+ return false;
+ }
if (null != this.os && super.isLoggable(record)) {
return true;
}
return false;
}
-
}
Modified: harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/XMLFormatter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/XMLFormatter.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/XMLFormatter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/logging/src/main/java/java/util/logging/XMLFormatter.java Thu Aug 30 07:33:56 2007
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-
package java.util.logging;
import java.security.AccessController;
@@ -25,12 +24,12 @@
import java.util.ResourceBundle;
/**
- * Format a given <code>LogRecord</code> into string represents XML. The DTD specified in
- * Appendix A to Java Logging APIs specification is used.
- *
- * <code>XMLFormatter</code> uses given <code>Handler</code>'s encoding if has, otherwise
- * uses default platform encoding instead. However, the UTF-8 is recommended encoding.
+ * Format a given <code>LogRecord</code> into string represents XML. The DTD
+ * specified in Appendix A to Java Logging APIs specification is used.
*
+ * <code>XMLFormatter</code> uses given <code>Handler</code>'s encoding if
+ * has, otherwise uses default platform encoding instead. However, the UTF-8 is
+ * recommended encoding.
*/
public class XMLFormatter extends Formatter {
@@ -47,60 +46,64 @@
}
/**
- * Format a <code>LogRecord</code> into string which represents XML
+ * Format a <code>LogRecord</code> into string which represents XML.
*
- * @param r the given LogRecord instance to be formatted
- * @return string which represents XML
+ * @param r
+ * the given LogRecord instance to be formatted
+ * @return string which represents XML
*/
+ @SuppressWarnings("nls")
@Override
public String format(LogRecord r) {
- //call a method of LogRecord to ensure not null
+ // call a method of LogRecord to ensure not null
long time = r.getMillis();
- //format to date
- String date = MessageFormat.format("{0, date} {0, time}", //$NON-NLS-1$
+ // format to date
+ String date = MessageFormat.format("{0, date} {0, time}",
new Object[] { new Date(time) });
StringBuilder sb = new StringBuilder();
- sb.append(("<record>")).append(lineSeperator); //$NON-NLS-1$
- sb.append(indent).append(("<date>")).append(date).append(("</date>")) //$NON-NLS-1$ //$NON-NLS-2$
+ sb.append(("<record>")).append(lineSeperator);
+ sb.append(indent).append(("<date>")).append(date).append(("</date>"))
.append(lineSeperator);
- sb.append(indent).append(("<millis>")).append(time).append( //$NON-NLS-1$
- ("</millis>")).append(lineSeperator); //$NON-NLS-1$
- sb.append(indent).append(("<sequence>")).append(r.getSequenceNumber()) //$NON-NLS-1$
- .append(("</sequence>")).append(lineSeperator); //$NON-NLS-1$
+ sb.append(indent).append(("<millis>")).append(time).append(
+ ("</millis>")).append(lineSeperator);
+ sb.append(indent).append(("<sequence>")).append(r.getSequenceNumber())
+ .append(("</sequence>")).append(lineSeperator);
if (null != r.getLoggerName()) {
- sb.append(indent).append(("<logger>")).append(r.getLoggerName()) //$NON-NLS-1$
- .append(("</logger>")).append(lineSeperator); //$NON-NLS-1$
+ sb.append(indent).append(("<logger>")).append(r.getLoggerName())
+ .append(("</logger>")).append(lineSeperator);
}
- sb.append(indent).append(("<level>")).append(r.getLevel().getName()) //$NON-NLS-1$
- .append(("</level>")).append(lineSeperator); //$NON-NLS-1$
+ sb.append(indent).append(("<level>")).append(r.getLevel().getName())
+ .append(("</level>")).append(lineSeperator);
if (null != r.getSourceClassName()) {
- sb.append(indent).append(("<class>")) //$NON-NLS-1$
- .append(r.getSourceClassName()).append(("</class>")) //$NON-NLS-1$
+ sb.append(indent).append(("<class>"))
+ .append(r.getSourceClassName()).append(("</class>"))
.append(lineSeperator);
}
if (null != r.getSourceMethodName()) {
- sb.append(indent).append(("<method>")).append( //$NON-NLS-1$
- r.getSourceMethodName()).append(("</method>")).append( //$NON-NLS-1$
+ sb.append(indent).append(("<method>")).append(
+ r.getSourceMethodName()).append(("</method>")).append(
lineSeperator);
}
- sb.append(indent).append(("<thread>")).append(r.getThreadID()).append( //$NON-NLS-1$
- ("</thread>")).append(lineSeperator); //$NON-NLS-1$
+ sb.append(indent).append(("<thread>")).append(r.getThreadID()).append(
+ ("</thread>")).append(lineSeperator);
formatMessages(r, sb);
Object[] params;
if ((params = r.getParameters()) != null) {
for (Object element : params) {
- sb.append(indent).append(("<param>")).append(element).append( //$NON-NLS-1$
- ("</param>")).append(lineSeperator); //$NON-NLS-1$
+ sb.append(indent).append(("<param>")).append(element).append(
+ ("</param>")).append(lineSeperator);
}
}
formatThrowable(r, sb);
- sb.append(("</record>")).append(lineSeperator); //$NON-NLS-1$
+ sb.append(("</record>")).append(lineSeperator);
return sb.toString();
}
+ @SuppressWarnings("nls")
private void formatMessages(LogRecord r, StringBuilder sb) {
- //get localized message if has, but don't call Formatter.formatMessage to parse pattern string
+ // get localized message if has, but don't call Formatter.formatMessage
+ // to parse pattern string
ResourceBundle rb = r.getResourceBundle();
String pattern = r.getMessage();
if (null != rb && null != pattern) {
@@ -113,80 +116,84 @@
if (message == null) {
message = pattern;
- sb.append(indent).append(("<message>")).append(message).append( //$NON-NLS-1$
- ("</message>")).append(lineSeperator); //$NON-NLS-1$
+ sb.append(indent).append(("<message>")).append(message).append(
+ ("</message>")).append(lineSeperator);
} else {
- sb.append(indent).append(("<message>")).append(message).append( //$NON-NLS-1$
- ("</message>")).append(lineSeperator); //$NON-NLS-1$
- sb.append(indent).append(("<key>")).append(pattern).append( //$NON-NLS-1$
- ("</key>")).append(lineSeperator); //$NON-NLS-1$
- sb.append(indent).append(("<catalog>")).append( //$NON-NLS-1$
- r.getResourceBundleName()).append(("</catalog>")) //$NON-NLS-1$
+ sb.append(indent).append(("<message>")).append(message).append(
+ ("</message>")).append(lineSeperator);
+ sb.append(indent).append(("<key>")).append(pattern).append(
+ ("</key>")).append(lineSeperator);
+ sb.append(indent).append(("<catalog>")).append(
+ r.getResourceBundleName()).append(("</catalog>"))
.append(lineSeperator);
}
- } else if(null != pattern){
- sb.append(indent).append(("<message>")).append(pattern).append( //$NON-NLS-1$
- ("</message>")).append(lineSeperator); //$NON-NLS-1$
- } else{
- sb.append(indent).append(("<message/>")); //$NON-NLS-1$
+ } else if (null != pattern) {
+ sb.append(indent).append(("<message>")).append(pattern).append(
+ ("</message>")).append(lineSeperator);
+ } else {
+ sb.append(indent).append(("<message/>"));
}
}
+ @SuppressWarnings("nls")
private void formatThrowable(LogRecord r, StringBuilder sb) {
Throwable t;
if ((t = r.getThrown()) != null) {
- sb.append(indent).append("<exception>").append(lineSeperator); //$NON-NLS-1$
- sb.append(indent).append(indent).append("<message>").append( //$NON-NLS-1$
- t.toString()).append("</message>").append(lineSeperator); //$NON-NLS-1$
- //format throwable's stack trace
+ sb.append(indent).append("<exception>").append(lineSeperator);
+ sb.append(indent).append(indent).append("<message>").append(
+ t.toString()).append("</message>").append(lineSeperator);
+ // format throwable's stack trace
StackTraceElement[] elements = t.getStackTrace();
for (StackTraceElement e : elements) {
- sb.append(indent).append(indent).append("<frame>").append( //$NON-NLS-1$
+ sb.append(indent).append(indent).append("<frame>").append(
lineSeperator);
sb.append(indent).append(indent).append(indent).append(
- "<class>").append(e.getClassName()).append("</class>") //$NON-NLS-1$//$NON-NLS-2$
+ "<class>").append(e.getClassName()).append("</class>")
.append(lineSeperator);
sb.append(indent).append(indent).append(indent).append(
- "<method>").append(e.getMethodName()).append( //$NON-NLS-1$
- "</method>").append(lineSeperator); //$NON-NLS-1$
+ "<method>").append(e.getMethodName()).append(
+ "</method>").append(lineSeperator);
sb.append(indent).append(indent).append(indent)
- .append("<line>").append(e.getLineNumber()).append( //$NON-NLS-1$
- "</line>").append(lineSeperator); //$NON-NLS-1$
- sb.append(indent).append(indent).append("</frame>").append( //$NON-NLS-1$
+ .append("<line>").append(e.getLineNumber()).append(
+ "</line>").append(lineSeperator);
+ sb.append(indent).append(indent).append("</frame>").append(
lineSeperator);
}
- sb.append(indent).append("</exception>").append(lineSeperator); //$NON-NLS-1$
+ sb.append(indent).append("</exception>").append(lineSeperator);
}
}
/**
- * Return the header string for XML, use given handler's encoding if has,
- * other wise use default platform encoding
+ * Return the header string for XML, use given handler's encoding if has,
+ * other wise use default platform encoding
*
- * @param h the given handler
+ * @param h
+ * the given handler
* @return the header string for XML
*/
+ @SuppressWarnings("nls")
@Override
public String getHead(Handler h) {
String encoding = null;
- if(null != h) {
- encoding = h.getEncoding();
+ if (null != h) {
+ encoding = h.getEncoding();
}
if (null == encoding) {
- encoding = getSystemProperty("file.encoding"); //$NON-NLS-1$
+ encoding = getSystemProperty("file.encoding");
}
StringBuilder sb = new StringBuilder();
- sb.append("<?xml version=\"1.0\" encoding=\"").append(encoding).append( //$NON-NLS-1$
- "\" standalone=\"no\"?>").append(lineSeperator); //$NON-NLS-1$
- sb.append("<!DOCTYPE log SYSTEM \"logger.dtd\">").append(lineSeperator); //$NON-NLS-1$
- sb.append(("<log>")); //$NON-NLS-1$
+ sb.append("<?xml version=\"1.0\" encoding=\"").append(encoding).append(
+ "\" standalone=\"no\"?>").append(lineSeperator);
+ sb.append("<!DOCTYPE log SYSTEM \"logger.dtd\">").append(lineSeperator);
+ sb.append(("<log>"));
return sb.toString();
}
/**
* Return the tail string for XML
*
- * @param h the given handler
+ * @param h
+ * the given handler
* @return the tail string for XML
*/
@Override
@@ -195,16 +202,12 @@
return "</log>"; //$NON-NLS-1$
}
- //use privilege code to get system property
+ // use privilege code to get system property
private static String getSystemProperty(final String key) {
- return AccessController.doPrivileged(
- new PrivilegedAction<String>() {
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty(key);
}
});
}
-
}
-
-
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java Thu Aug 30 07:33:56 2007
@@ -476,7 +476,7 @@
String nameC2 = c2.getName();
int indexDotC1 = nameC1.lastIndexOf('.');
int indexDotC2 = nameC2.lastIndexOf('.');
- if (indexDotC1 != indexDotC1) {
+ if (indexDotC1 != indexDotC2) {
return false; // cannot be in the same package if indices are not
}
// the same
Modified: harmony/enhanced/classlib/branches/java6/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java Thu Aug 30 07:33:56 2007
@@ -23,6 +23,8 @@
import java.io.ObjectOutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.math.MathContext;
+import java.math.RoundingMode;
public class BigDecimalTest extends junit.framework.TestCase {
@@ -917,4 +919,35 @@
((zerotest.stripTrailingZeros()).scale() == 0)
);
}
+
+ public void testMathContextConstruction() {
+ String a = "-12380945E+61";
+ BigDecimal aNumber = new BigDecimal(a);
+ int precision = 6;
+ RoundingMode rm = RoundingMode.HALF_DOWN;
+ MathContext mcIntRm = new MathContext(precision, rm);
+ MathContext mcStr = new MathContext("precision=6 roundingMode=HALF_DOWN");
+ MathContext mcInt = new MathContext(precision);
+ BigDecimal res = aNumber.abs(mcInt);
+ assertEquals("MathContext Constructer with int precision failed",
+ res,
+ new BigDecimal("1.23809E+68"));
+
+ assertEquals("Equal MathContexts are not Equal ",
+ mcIntRm,
+ mcStr);
+
+ assertEquals("Different MathContext are reported as Equal ",
+ mcInt.equals(mcStr),
+ false);
+
+ assertEquals("Equal MathContexts have different hashcodes ",
+ mcIntRm.hashCode(),
+ mcStr.hashCode());
+
+ assertEquals("MathContext.toString() returning incorrect value",
+ mcIntRm.toString(),
+ "precision=6 roundingMode=HALF_DOWN");
+ }
+
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java Thu Aug 30 07:33:56 2007
@@ -46,7 +46,8 @@
*/
private List<SelectionKey> keyList = new ArrayList<SelectionKey>();
- private class BlockingLock {
+ // Marker class so lock type shows up in profilers
+ static private class BlockingLock {
}
private final Object blockingLock = new BlockingLock();
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java Thu Aug 30 07:33:56 2007
@@ -41,12 +41,11 @@
* provided by the port layer.
*
* This class is non-API, but implements the API of the FileChannel interface.
- *
*/
public abstract class FileChannelImpl extends FileChannel {
- // Reference to the portable file system code.
- private static final IFileSystem fileSystem = Platform.getFileSystem();
+ // Reference to the portable file system code.
+ private static final IFileSystem fileSystem = Platform.getFileSystem();
private static final int ALLOC_GRANULARITY;
@@ -59,79 +58,78 @@
}
- // Handle to the open file
- private final long handle;
+ // Handle to the open file
+ private final long handle;
- // The object that will track all outstanding locks on this channel.
- private final LockManager lockManager = new LockManager();
+ // The object that will track all outstanding locks on this channel.
+ private final LockManager lockManager = new LockManager();
- private class RepositioningLock {}
- private final Object repositioningLock = new RepositioningLock();
+ private static class RepositioningLock {}
+ private final Object repositioningLock = new RepositioningLock();
- private final Object stream;
-
- /*
- * Create a new file channel implementation class that wraps the given file
- * handle and operates in the specified mode.
- *
- */
+ private final Object stream;
+
+ /*
+ * Create a new file channel implementation class that wraps the given file
+ * handle and operates in the specified mode.
+ *
+ */
public FileChannelImpl(Object stream, long handle) {
- super();
- this.handle = handle;
- this.stream = stream;
- }
-
- /*
- * Helper method to throw an exception if the channel is already closed.
- * Note that we don't bother to synchronize on this test since the file may
- * be closed by operations beyond our control anyways.
- */
- protected final void openCheck() throws ClosedChannelException {
- if (!isOpen()) {
- throw new ClosedChannelException();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.nio.channels.spi.AbstractInterruptibleChannel#implCloseChannel()
- */
- protected void implCloseChannel() throws IOException {
+ super();
+ this.handle = handle;
+ this.stream = stream;
+ }
+
+ /*
+ * Helper method to throw an exception if the channel is already closed.
+ * Note that we don't bother to synchronize on this test since the file may
+ * be closed by operations beyond our control anyways.
+ */
+ protected final void openCheck() throws ClosedChannelException {
+ if (!isOpen()) {
+ throw new ClosedChannelException();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.nio.channels.spi.AbstractInterruptibleChannel#implCloseChannel()
+ */
+ protected void implCloseChannel() throws IOException {
if (stream instanceof Closeable) {
((Closeable) stream).close();
}
- }
+ }
- protected FileLock basicLock(long position, long size, boolean shared,
- boolean wait) throws IOException {
- if ((position < 0) || (size < 0)) {
+ protected FileLock basicLock(long position, long size, boolean shared,
+ boolean wait) throws IOException {
+ if ((position < 0) || (size < 0)) {
// nio.0A=Lock position and size must be non-negative.
- throw new IllegalArgumentException(
- Messages.getString("nio.0A")); //$NON-NLS-1$
- }
+ throw new IllegalArgumentException(Messages.getString("nio.0A")); //$NON-NLS-1$
+ }
int lockType = shared ? IFileSystem.SHARED_LOCK_TYPE
: IFileSystem.EXCLUSIVE_LOCK_TYPE;
- FileLock pendingLock = new FileLockImpl(this, position, size, shared);
- lockManager.addLock(pendingLock);
+ FileLock pendingLock = new FileLockImpl(this, position, size, shared);
+ lockManager.addLock(pendingLock);
+
+ if (fileSystem.lock(handle, position, size, lockType, wait)) {
+ return pendingLock;
+ }
+
+ // Lock acquisition failed
+ lockManager.removeLock(pendingLock);
+ return null;
+ }
- if (fileSystem.lock(handle, position, size, lockType, wait)) {
- return pendingLock;
- }
-
- // Lock acquisition failed
- lockManager.removeLock(pendingLock);
- return null;
- }
-
- /*
- * Acquire a lock on the receiver, blocks if the lock cannot be obtained
- * immediately.
- *
- * @see java.nio.channels.FileChannel#lock(long, long, boolean)
- */
- public final FileLock lock(long position, long size, boolean shared)
- throws IOException {
+ /*
+ * Acquire a lock on the receiver, blocks if the lock cannot be obtained
+ * immediately.
+ *
+ * @see java.nio.channels.FileChannel#lock(long, long, boolean)
+ */
+ public final FileLock lock(long position, long size, boolean shared)
+ throws IOException {
openCheck();
FileLock resultLock = null;
{
@@ -145,40 +143,40 @@
}
}
return resultLock;
- }
+ }
+
+ /*
+ * Attempts to acquire the given lock, but does not block. If the lock
+ * cannot be acquired the method returns null.
+ *
+ * @see java.nio.channels.FileChannel#tryLock(long, long, boolean)
+ */
+ public final FileLock tryLock(long position, long size, boolean shared)
+ throws IOException {
+ openCheck();
+ return basicLock(position, size, shared, false);
+ }
+
+ /*
+ * Non-API method to release a given lock on a file channel. Assumes that
+ * the lock will mark itself invalid after successful unlocking.
+ */
+ void release(FileLock lock) throws IOException {
+ openCheck();
+ fileSystem.unlock(handle, lock.position(), lock.size());
+ lockManager.removeLock(lock);
+ }
- /*
- * Attempts to acquire the given lock, but does not block. If the lock
- * cannot be acquired the method returns null.
- *
- * @see java.nio.channels.FileChannel#tryLock(long, long, boolean)
- */
- public final FileLock tryLock(long position, long size, boolean shared)
- throws IOException {
- openCheck();
- return basicLock(position, size, shared, false);
- }
-
- /*
- * Non-API method to release a given lock on a file channel. Assumes that
- * the lock will mark itself invalid after successful unlocking.
- */
- void release(FileLock lock) throws IOException {
- openCheck();
- fileSystem.unlock(handle, lock.position(), lock.size());
- lockManager.removeLock(lock);
- }
-
- /*
- * Flush the contents of the file to disk, and the metadata if asked.
- */
- public void force(boolean metadata) throws IOException {
- openCheck();
- // Forcing data-only on a read-only file is a no-op.
+ /*
+ * Flush the contents of the file to disk, and the metadata if asked.
+ */
+ public void force(boolean metadata) throws IOException {
+ openCheck();
+ // Forcing data-only on a read-only file is a no-op.
if (metadata) {
fileSystem.fflush(handle, metadata);
}
- }
+ }
public abstract MappedByteBuffer map(MapMode mode, long position, long size)
throws IOException;
@@ -190,8 +188,8 @@
}
long alignment = position - position % ALLOC_GRANULARITY;
int offset = (int) (position - alignment);
- PlatformAddress address = PlatformAddressFactory.allocMap(handle, alignment, size
- + offset, mapMode);
+ PlatformAddress address = PlatformAddressFactory.allocMap(handle,
+ alignment, size + offset, mapMode);
MappedByteBuffer buffer = null;
try {
buffer = MappedByteBufferFactory.getBuffer(address, mapMode, size,
@@ -200,72 +198,71 @@
throw new IOException(e.getMessage());
}
return buffer;
- }
+ }
- /*
- * Answers the current file position.
- */
- public long position() throws IOException {
- openCheck();
- return fileSystem.seek(handle, 0L, IFileSystem.SEEK_CUR);
- }
-
- /*
- * Sets the file pointer.
- */
- public FileChannel position(long newPosition) throws IOException {
+ /*
+ * Answers the current file position.
+ */
+ public long position() throws IOException {
openCheck();
- if (newPosition < 0) {
+ return fileSystem.seek(handle, 0L, IFileSystem.SEEK_CUR);
+ }
+
+ /*
+ * Sets the file pointer.
+ */
+ public FileChannel position(long newPosition) throws IOException {
+ openCheck();
+ if (newPosition < 0) {
// nio.0B=New position must be non-negative.
- throw new IllegalArgumentException(
- Messages.getString("nio.0B")); //$NON-NLS-1$
- }
-
- synchronized (repositioningLock) {
- fileSystem.seek(handle, newPosition, IFileSystem.SEEK_SET);
- }
- return this;
- }
+ throw new IllegalArgumentException(Messages.getString("nio.0B")); //$NON-NLS-1$
+ }
+
+ synchronized (repositioningLock) {
+ fileSystem.seek(handle, newPosition, IFileSystem.SEEK_SET);
+ }
+ return this;
+ }
- public int read(ByteBuffer buffer, long position) throws IOException {
- if (null == buffer){
+ public int read(ByteBuffer buffer, long position) throws IOException {
+ if (null == buffer) {
throw new NullPointerException();
}
- if (position < 0){
+ if (position < 0) {
throw new IllegalArgumentException();
}
- openCheck();
- if (!buffer.hasRemaining()){
+ openCheck();
+ if (!buffer.hasRemaining()) {
return 0;
}
- synchronized (repositioningLock) {
- int bytesRead = 0;
- long preReadPosition = position();
- position(position);
- try {
- bytesRead = read(buffer);
- } finally {
- position(preReadPosition);
- }
- return bytesRead;
- }
- }
+ synchronized (repositioningLock) {
+ int bytesRead = 0;
+ long preReadPosition = position();
+ position(position);
+ try {
+ bytesRead = read(buffer);
+ } finally {
+ position(preReadPosition);
+ }
+ return bytesRead;
+ }
+ }
- public int read(ByteBuffer buffer) throws IOException {
+ public int read(ByteBuffer buffer) throws IOException {
openCheck();
- if (!buffer.hasRemaining()){
+ if (!buffer.hasRemaining()) {
return 0;
}
boolean completed = false;
int bytesRead = 0;
- synchronized (repositioningLock) {
- if (buffer.isDirect()) {
- DirectBuffer directBuffer = (DirectBuffer) buffer;
- long address = directBuffer.getEffectiveAddress().toLong();
+ synchronized (repositioningLock) {
+ if (buffer.isDirect()) {
+ DirectBuffer directBuffer = (DirectBuffer) buffer;
+ long address = directBuffer.getEffectiveAddress().toLong();
try {
begin();
/*
- * if (bytesRead <= EOF) delt by read completed = false;
+ * if (bytesRead <= EOF) dealt by read completed = false;
*/
bytesRead = (int) fileSystem.readDirect(handle, address,
buffer.position(), buffer.remaining());
@@ -273,11 +270,11 @@
} finally {
end(completed && bytesRead >= 0);
}
- } else {
+ } else {
try {
begin();
/*
- * if (bytesRead <= EOF) delt by read completed = false;
+ * if (bytesRead <= EOF) dealt by read completed = false;
*/
bytesRead = (int) fileSystem.read(handle, buffer.array(),
buffer.arrayOffset() + buffer.position(), buffer
@@ -286,16 +283,16 @@
} finally {
end(completed && bytesRead >= 0);
}
- }
- if (bytesRead > 0) {
- buffer.position(buffer.position() + bytesRead);
- }
- }
- return bytesRead;
- }
+ }
+ if (bytesRead > 0) {
+ buffer.position(buffer.position() + bytesRead);
+ }
+ }
+ return bytesRead;
+ }
- public long read(ByteBuffer[] buffers, int offset, int length)
- throws IOException {
+ public long read(ByteBuffer[] buffers, int offset, int length)
+ throws IOException {
int count = 0;
if (offset < 0 || length < 0 || offset + length > buffers.length) {
throw new IndexOutOfBoundsException();
@@ -338,7 +335,7 @@
}
completed = true;
/*
- * if (bytesRead < EOF) //delt by readv? completed = false;
+ * if (bytesRead < EOF) //dealt by readv? completed = false;
*/
} finally {
end(completed);
@@ -359,38 +356,38 @@
}
} else {
ByteBuffer buf = directBuffers[i - offset];
- if (bytesRemaining < buf.remaining()){
- // this is the last step.
+ if (bytesRemaining < buf.remaining()) {
+ // this is the last step.
int pos = buf.position();
buffers[i].put(buf);
- buffers[i].position(pos + (int)bytesRemaining);
+ buffers[i].position(pos + (int) bytesRemaining);
bytesRemaining = 0;
} else {
bytesRemaining -= buf.remaining();
buffers[i].put(buf);
- }
+ }
}
}
return bytesRead;
- }
+ }
- /*
- * Answers the current file size, as an integer number of bytes.
- */
- public long size() throws IOException {
- openCheck();
- synchronized (repositioningLock) {
- long currentPosition = fileSystem.seek(handle, 0L,
- IFileSystem.SEEK_CUR);
- long endOfFilePosition = fileSystem.seek(handle, 0L,
- IFileSystem.SEEK_END);
- fileSystem.seek(handle, currentPosition, IFileSystem.SEEK_SET);
- return endOfFilePosition;
- }
- }
+ /*
+ * Answers the current file size, as an integer number of bytes.
+ */
+ public long size() throws IOException {
+ openCheck();
+ synchronized (repositioningLock) {
+ long currentPosition = fileSystem.seek(handle, 0L,
+ IFileSystem.SEEK_CUR);
+ long endOfFilePosition = fileSystem.seek(handle, 0L,
+ IFileSystem.SEEK_END);
+ fileSystem.seek(handle, currentPosition, IFileSystem.SEEK_SET);
+ return endOfFilePosition;
+ }
+ }
- public long transferFrom(ReadableByteChannel src, long position, long count)
- throws IOException {
+ public long transferFrom(ReadableByteChannel src, long position, long count)
+ throws IOException {
openCheck();
if (!src.isOpen()) {
throw new ClosedChannelException();
@@ -399,10 +396,10 @@
|| count > Integer.MAX_VALUE) {
throw new IllegalArgumentException();
}
- if(position > size()) {
+ if (position > size()) {
return 0;
}
-
+
ByteBuffer buffer = null;
try {
@@ -424,13 +421,13 @@
if (buffer != null) {
// all children of FileChannelImpl currently returns
// an instance of DirectBuffer from map() method
- ((DirectBuffer) buffer).free();
+ ((DirectBuffer) buffer).free();
}
}
- }
+ }
- public long transferTo(long position, long count, WritableByteChannel target)
- throws IOException {
+ public long transferTo(long position, long count, WritableByteChannel target)
+ throws IOException {
openCheck();
if (!target.isOpen()) {
throw new ClosedChannelException();
@@ -442,7 +439,7 @@
|| count > Integer.MAX_VALUE) {
throw new IllegalArgumentException();
}
-
+
if (count == 0 || position >= size()) {
return 0;
}
@@ -480,7 +477,7 @@
}
}
- public FileChannel truncate(long size) throws IOException {
+ public FileChannel truncate(long size) throws IOException {
openCheck();
if (size < 0) {
throw new IllegalArgumentException();
@@ -499,37 +496,37 @@
}
}
return this;
- }
+ }
- /*
- * (non-Javadoc)
- *
- * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
- */
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
+ */
- public int write(ByteBuffer buffer, long position) throws IOException {
- if (null == buffer){
+ public int write(ByteBuffer buffer, long position) throws IOException {
+ if (null == buffer) {
throw new NullPointerException();
}
- if (position < 0){
+ if (position < 0) {
throw new IllegalArgumentException();
}
openCheck();
- if (!buffer.hasRemaining()){
+ if (!buffer.hasRemaining()) {
return 0;
}
int bytesWritten = 0;
- synchronized (repositioningLock) {
- long preWritePosition = position();
- position(position);
- try {
- bytesWritten = writeImpl(buffer);
- } finally {
- position(preWritePosition);
- }
- }
- return bytesWritten;
- }
+ synchronized (repositioningLock) {
+ long preWritePosition = position();
+ position(position);
+ try {
+ bytesWritten = writeImpl(buffer);
+ } finally {
+ position(preWritePosition);
+ }
+ }
+ return bytesWritten;
+ }
public int write(ByteBuffer buffer) throws IOException {
openCheck();
@@ -537,12 +534,12 @@
}
private int writeImpl(ByteBuffer buffer) throws IOException {
- int bytesWritten;
+ int bytesWritten;
boolean completed = false;
- synchronized (repositioningLock) {
- if (buffer.isDirect()) {
- DirectBuffer directBuffer = (DirectBuffer) buffer;
- long address = directBuffer.getEffectiveAddress().toLong();
+ synchronized (repositioningLock) {
+ if (buffer.isDirect()) {
+ DirectBuffer directBuffer = (DirectBuffer) buffer;
+ long address = directBuffer.getEffectiveAddress().toLong();
try {
begin();
bytesWritten = (int) fileSystem.writeDirect(handle,
@@ -551,7 +548,7 @@
} finally {
end(completed);
}
- } else {
+ } else {
try {
begin();
bytesWritten = (int) fileSystem.write(handle, buffer
@@ -561,16 +558,16 @@
} finally {
end(completed);
}
- }
- if (bytesWritten > 0) {
- buffer.position(buffer.position() + bytesWritten);
- }
- }
- return bytesWritten;
- }
+ }
+ if (bytesWritten > 0) {
+ buffer.position(buffer.position() + bytesWritten);
+ }
+ }
+ return bytesWritten;
+ }
- public long write(ByteBuffer[] buffers, int offset, int length)
- throws IOException {
+ public long write(ByteBuffer[] buffers, int offset, int length)
+ throws IOException {
if (offset < 0 || length < 0 || (offset + length) > buffers.length) {
throw new IndexOutOfBoundsException();
}
@@ -628,8 +625,8 @@
}
return bytesWritten;
}
-
- public long getHandle(){
+
+ public long getHandle() {
return handle;
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java Thu Aug 30 07:33:56 2007
@@ -73,7 +73,7 @@
boolean isBound = false;
// lock for accept
- private class AcceptLock {}
+ private static class AcceptLock {}
private final Object acceptLock = new AcceptLock();
// ----------------------------------------------------
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties?rev=571185&r1=571184&r2=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties Thu Aug 30 07:33:56 2007
@@ -59,3 +59,6 @@
sql.42=Illegal Argument
sql.43=The object is not serializable
sql.44=No logger has been set
+
+rowset.0=Not a valid position
+rowset.1=Not a valid column name
Copied: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java (from r571136, harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java)
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java?p2=harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java&p1=harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java&r1=571136&r2=571185&rev=571185&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java Thu Aug 30 07:33:56 2007
@@ -19,17 +19,7 @@
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.Ref;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.Statement;
-import java.sql.Time;
-import java.sql.Timestamp;
+import java.sql.*;
import java.util.Calendar;
import java.util.Map;
@@ -574,6 +564,286 @@
public boolean wasNull() throws SQLException {
throw new NotImplementedException();
+ }
+
+ public int getHoldability() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NClob getNClob(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NClob getNClob(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getNString(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getNString(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public RowId getRowId(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public RowId getRowId(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isClosed() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void updateAsciiStream(int columnIndex, InputStream x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateAsciiStream(String columnLabel, InputStream x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateAsciiStream(int columnIndex, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateAsciiStream(String columnLabel, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateBinaryStream(int columnIndex, InputStream x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateBinaryStream(String columnLabel, InputStream x,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateBinaryStream(int columnIndex, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateBinaryStream(String columnLabel, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateBlob(int columnIndex, InputStream inputStream, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateBlob(String columnLabel, InputStream inputStream,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateBlob(int columnIndex, InputStream inputStream)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateBlob(String columnLabel, InputStream inputStream)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateCharacterStream(int columnIndex, Reader x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateCharacterStream(String columnLabel, Reader reader,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateCharacterStream(int columnIndex, Reader x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateCharacterStream(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateClob(int columnIndex, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateClob(String columnLabel, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateClob(int columnIndex, Reader reader) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateClob(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNCharacterStream(int columnIndex, Reader x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNCharacterStream(String columnLabel, Reader reader,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNCharacterStream(int columnIndex, Reader x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNCharacterStream(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNClob(int columnIndex, NClob clob) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNClob(String columnLabel, NClob clob) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNClob(int columnIndex, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNClob(String columnLabel, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNClob(int columnIndex, Reader reader) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNClob(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNString(int columnIndex, String string)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateNString(String columnLabel, String string)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateSQLXML(String columnLabel, SQLXML xmlObject)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
}