harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r557439 - in /harmony/enhanced/classlib/trunk/modules/beans: META-INF/ src/main/java/java/beans/ src/test/java/org/apache/harmony/beans/tests/java/beans/
Date Thu, 19 Jul 2007 00:56:22 GMT
Author: tonywu
Date: Wed Jul 18 17:56:20 2007
New Revision: 557439

URL: http://svn.apache.org/viewvc?view=rev&rev=557439
Log:
Apply Harmony-4478 ([classlib][beans] Current bean implementation does not persist many awt classes properly (refer to Harmony-4473)
)

Added:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtComponentPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtContainerPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtCursorPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtDimensionPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontTextAttributePersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtInsetsPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtListPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuBarPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuShortcutPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtPointPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtScrollPanePersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtSystemColorPersistenceDelegate.java   (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StaticFieldPersistenceDelegate.java   (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF?view=diff&rev=557439&r1=557438&r2=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF Wed Jul 18 17:56:20 2007
@@ -13,6 +13,7 @@
 Eclipse-JREBundle: true
 Import-Package: java.applet,
  java.awt,
+ java.awt.dnd,
  java.awt.event;resolution:=optional,
  java.awt.font,
  java.io,
@@ -21,9 +22,11 @@
  java.net,
  java.nio.charset;resolution:=optional,
  java.security,
+ java.text,
  java.util,
  java.util.regex;resolution:=optional,
  javax.accessibility;resolution:=optional,
+ javax.swing,
  javax.xml.parsers,
  org.apache.harmony.kernel.vm,
  org.apache.harmony.testframework.serialization;hy_usage=test;resolution:=optional,

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtComponentPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtComponentPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtComponentPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtComponentPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,88 @@
+/*
+ *  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 java.beans;
+
+class AwtComponentPersistenceDelegate extends DefaultPersistenceDelegate {
+
+	protected void initialize(Class<?> type, Object oldInstance,
+			Object newInstance, Encoder enc) {
+		// Call the initialization of the super type
+		super.initialize(type, oldInstance, newInstance, enc);
+
+		// background
+		writeProperty(oldInstance, newInstance, enc, "Background");
+
+		// foreground
+		writeProperty(oldInstance, newInstance, enc, "Foreground");
+
+		// font
+		writeProperty(oldInstance, newInstance, enc, "Font");
+
+		// bounds
+		writeProperty(oldInstance, newInstance, enc, "Bounds");
+
+		// name
+		writeProperty(oldInstance, newInstance, enc, "Name");
+
+	}
+
+	static void writeProperty(Object oldInstance, Object newInstance,
+			Encoder enc, String property) {
+		StringBuilder builder = new StringBuilder();
+		Expression getterExp = new Expression(oldInstance, builder
+				.append("get").append(property).toString(), null);
+		try {
+			// Calculate the old value of the property
+			Object oldVal = getterExp.getValue();
+			// Write the getter expression to the encoder
+			enc.writeExpression(getterExp);
+			// Get the target value that exists in the new environment
+			Object targetVal = enc.get(oldVal);
+			// Get the current property value in the new environment
+			builder.delete(0, builder.capacity());
+			Object newVal = new Expression(newInstance, builder.append("get")
+					.append(property).toString(), null).getValue();
+			/*
+			 * Make the target value and current property value equivalent in
+			 * the new environment
+			 */
+			if (null == targetVal) {
+				if (null != newVal) {
+					// Set to null
+					builder.delete(0, builder.capacity());
+					Statement setterStm = new Statement(oldInstance, builder
+							.append("set").append(property).toString(),
+							new Object[] { null });
+					enc.writeStatement(setterStm);
+				}
+			} else {
+				PersistenceDelegate pd = enc.getPersistenceDelegate(targetVal
+						.getClass());
+				if (!pd.mutatesTo(targetVal, newVal)) {
+					builder.delete(0, builder.capacity());
+					Statement setterStm = new Statement(oldInstance, builder
+							.append("set").append(property).toString(),
+							new Object[] { oldVal });
+					enc.writeStatement(setterStm);
+				}
+			}
+		} catch (Exception ex) {
+			enc.getExceptionListener().exceptionThrown(ex);
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtComponentPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtContainerPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtContainerPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtContainerPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtContainerPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,76 @@
+/*
+ *  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 java.beans;
+
+import java.awt.Container;
+
+class AwtContainerPersistenceDelegate extends AwtComponentPersistenceDelegate {
+	protected void initialize(Class<?> type, Object oldInstance,
+			Object newInstance, Encoder enc) {
+		// Call the initialization of the super type
+		super.initialize(type, oldInstance, newInstance, enc);
+
+		Container container = (Container) oldInstance;
+		int count = container.getComponentCount();
+		Expression getterExp = null;
+		for (int i = 0; i < count; i++) {
+			getterExp = new Expression(container.getComponent(i), container,
+					"getComponent", new Object[] { i });
+			try {
+				// Calculate the old value of the property
+				Object oldVal = getterExp.getValue();
+				// Write the getter expression to the encoder
+				enc.writeExpression(getterExp);
+				// Get the target value that exists in the new environment
+				Object targetVal = enc.get(oldVal);
+				// Get the current property value in the new environment
+				Object newVal = null;
+				try {
+					newVal = new Expression(((Container) newInstance)
+							.getComponent(i), newInstance, "getComponent",
+							new Object[] { i }).getValue();
+				} catch (ArrayIndexOutOfBoundsException ex) {
+					// Current Container does not have any component, newVal set
+					// to null
+				}
+				/*
+				 * Make the target value and current property value equivalent
+				 * in the new environment
+				 */
+				if (null == targetVal) {
+					if (null != newVal) {
+						// Set to null
+						Statement setterStm = new Statement(oldInstance, "add",
+								new Object[] { null });
+						enc.writeStatement(setterStm);
+					}
+				} else {
+					PersistenceDelegate pd = enc
+							.getPersistenceDelegate(targetVal.getClass());
+					if (!pd.mutatesTo(targetVal, newVal)) {
+						Statement setterStm = new Statement(oldInstance, "add",
+								new Object[] { oldVal });
+						enc.writeStatement(setterStm);
+					}
+				}
+			} catch (Exception ex) {
+				enc.getExceptionListener().exceptionThrown(ex);
+			}
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtContainerPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtCursorPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtCursorPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtCursorPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtCursorPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,28 @@
+/*
+ *  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 java.beans;
+
+import java.awt.Cursor;
+
+class AwtCursorPersistenceDelegate extends DefaultPersistenceDelegate {
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		Cursor cursor = (Cursor) oldInstance;
+		return new Expression(oldInstance, oldInstance.getClass(),
+                Statement.CONSTRUCTOR_NAME, new Object[] { cursor.getType() });
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtCursorPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtDimensionPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtDimensionPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtDimensionPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtDimensionPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,30 @@
+/*
+ *  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 java.beans;
+
+import java.awt.Dimension;
+
+class AwtDimensionPersistenceDelegate extends DefaultPersistenceDelegate {
+	
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		Dimension dimesion = (Dimension) oldInstance;
+
+        return new Expression(dimesion, dimesion.getClass(), Statement.CONSTRUCTOR_NAME,
+                new Object[] { dimesion.width, dimesion.height });
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtDimensionPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,29 @@
+/*
+ *  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 java.beans;
+
+import java.awt.Font;
+
+class AwtFontPersistenceDelegate extends DefaultPersistenceDelegate {
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		Font font = (Font) oldInstance;
+		return new Expression(oldInstance, oldInstance.getClass(),
+                Statement.CONSTRUCTOR_NAME, new Object[] { font.getFontName(),
+						font.getStyle(), font.getSize() });
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontTextAttributePersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontTextAttributePersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontTextAttributePersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontTextAttributePersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,31 @@
+/*
+ *  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 java.beans;
+
+import java.awt.font.TextAttribute;
+
+class AwtFontTextAttributePersistenceDelegate extends
+		StaticFieldPersistenceDelegate {
+	public AwtFontTextAttributePersistenceDelegate() {
+		super();
+	}
+	static {
+		init(TextAttribute.class);
+	}
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtFontTextAttributePersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtInsetsPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtInsetsPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtInsetsPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtInsetsPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,29 @@
+/*
+ *  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 java.beans;
+
+import java.awt.Insets;
+
+class AwtInsetsPersistenceDelegate extends DefaultPersistenceDelegate {
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		Insets inset = (Insets) oldInstance;
+		return new Expression(oldInstance, oldInstance.getClass(),
+				Statement.CONSTRUCTOR_NAME, new Object[] { inset.top, inset.left, inset.bottom,
+			 inset.right, });
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtInsetsPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtListPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtListPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtListPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtListPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,77 @@
+/*
+ *  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 java.beans;
+
+import java.awt.List;
+
+class AwtListPersistenceDelegate extends DefaultPersistenceDelegate {
+	protected void initialize(Class<?> type, Object oldInstance,
+			Object newInstance, Encoder enc) {
+		super.initialize(type, oldInstance, newInstance, enc);
+
+		List list = (List) oldInstance;
+		Statement setterStm = new Statement(oldInstance, "setSize",
+				new Object[] { list.getSize()});
+		enc.writeStatement(setterStm);
+		
+		int count = list.getItemCount();
+		Expression getterExp = null;
+		for (int i = 0; i < count; i++) {
+			getterExp = new Expression(list, "getItem", new Object[] { i });
+			try {
+				// Calculate the old value of the property
+				Object oldVal = getterExp.getValue();
+				// Write the getter expression to the encoder
+				enc.writeExpression(getterExp);
+				// Get the target value that exists in the new environment
+				Object targetVal = enc.get(oldVal);
+				// Get the current property value in the new environment
+				Object newVal = null;
+				try {
+					newVal = new Expression(newInstance, "getItem",
+							new Object[] { i }).getValue();
+				} catch (IndexOutOfBoundsException ex) {
+					// The newInstance has no elements, so current property
+					// value remains null
+				}
+				/*
+				 * Make the target value and current property value equivalent
+				 * in the new environment
+				 */
+				if (null == targetVal) {
+					if (null != newVal) {
+						// Set to null
+						setterStm = new Statement(oldInstance, "add",
+								new Object[] { null });
+						enc.writeStatement(setterStm);
+					}
+				} else {
+					PersistenceDelegate pd = enc
+							.getPersistenceDelegate(targetVal.getClass());
+					if (!pd.mutatesTo(targetVal, newVal)) {
+						setterStm = new Statement(oldInstance, "add",
+								new Object[] { oldVal });
+						enc.writeStatement(setterStm);
+					}
+				}
+			} catch (Exception ex) {
+				enc.getExceptionListener().exceptionThrown(ex);
+			}
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtListPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuBarPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuBarPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuBarPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuBarPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,79 @@
+/*
+ *  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 java.beans;
+
+import java.awt.Menu;
+import java.awt.MenuBar;
+
+class AwtMenuBarPersistenceDelegate extends DefaultPersistenceDelegate {
+	protected void initialize(Class<?> type, Object oldInstance,
+			Object newInstance, Encoder enc) {
+		super.initialize(type, oldInstance, newInstance, enc);
+		if (type != oldInstance.getClass()) {
+            return;
+        }
+		
+		MenuBar bar = (MenuBar) oldInstance;
+		int count = bar.getMenuCount();
+		Expression getterExp = null;
+		for (int i = 0; i < count; i++) {
+			getterExp = new Expression(bar.getMenu(i), "getLabel", null);
+			try {
+				// Calculate the old value of the property
+				Object oldVal = getterExp.getValue();
+				// Write the getter expression to the encoder
+				enc.writeExpression(getterExp);
+				// Get the target value that exists in the new environment
+				Object targetVal = enc.get(oldVal);
+				// Get the current property value in the new environment
+				Object newVal = null;
+				try {
+					newVal = new Expression(((MenuBar) newInstance).getMenu(i),
+							"getLabel", null).getValue();
+				} catch (IndexOutOfBoundsException ex) {
+					// The newInstance has no elements, so current property
+					// value remains null
+				}
+				/*
+				 * Make the target value and current property value equivalent
+				 * in the new environment
+				 */
+				if (null == targetVal) {
+					if (null != newVal) {
+						// Set to null
+						Statement setterStm = new Statement(oldInstance, "insert",
+								new Object[] { null, i });
+						enc.writeStatement(setterStm);
+					}
+				} else {
+					PersistenceDelegate pd = enc
+							.getPersistenceDelegate(targetVal.getClass());
+					if (!pd.mutatesTo(targetVal, newVal)) {
+						Menu menu = new Menu((String) oldVal);
+						menu.setName(bar.getMenu(i).getName());
+						Statement setterStm = new Statement(oldInstance,
+								"add", new Object[] { menu });
+						enc.writeStatement(setterStm);
+					}
+				}
+			} catch (Exception ex) {
+				enc.getExceptionListener().exceptionThrown(ex);
+			}
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuBarPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,79 @@
+/*
+ *  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 java.beans;
+
+import java.awt.Menu;
+import java.awt.MenuItem;
+
+class AwtMenuPersistenceDelegate extends DefaultPersistenceDelegate {
+	protected void initialize(Class<?> type, Object oldInstance,
+			Object newInstance, Encoder enc) {
+		super.initialize(type, oldInstance, newInstance, enc);
+		if (type != oldInstance.getClass()) {
+            return;
+        }
+		
+		Menu menu = (Menu) oldInstance;
+		int count = menu.getItemCount();
+		Expression getterExp = null;
+		for (int i = 0; i < count; i++) {
+			getterExp = new Expression(menu.getItem(i), "getLabel", null);
+			try {
+				// Calculate the old value of the property
+				Object oldVal = getterExp.getValue();
+				// Write the getter expression to the encoder
+				enc.writeExpression(getterExp);
+				// Get the target value that exists in the new environment
+				Object targetVal = enc.get(oldVal);
+				// Get the current property value in the new environment
+				Object newVal = null;
+				try {
+					newVal = new Expression(((Menu) newInstance).getItem(i),
+							"getLabel", null).getValue();
+				} catch (IndexOutOfBoundsException ex) {
+					// The newInstance has no elements, so current property
+					// value remains null
+				}
+				/*
+				 * Make the target value and current property value equivalent
+				 * in the new environment
+				 */
+				if (null == targetVal) {
+					if (null != newVal) {
+						// Set to null
+						Statement setterStm = new Statement(oldInstance, "insert",
+								new Object[] { null, i });
+						enc.writeStatement(setterStm);
+					}
+				} else {
+					PersistenceDelegate pd = enc
+							.getPersistenceDelegate(targetVal.getClass());
+					if (!pd.mutatesTo(targetVal, newVal)) {
+						MenuItem menuItem = new MenuItem((String) oldVal);
+						menuItem.setName(menu.getItem(i).getName());
+						Statement setterStm = new Statement(oldInstance,
+								"add", new Object[] { menuItem });
+						enc.writeStatement(setterStm);
+					}
+				}
+			} catch (Exception ex) {
+				enc.getExceptionListener().exceptionThrown(ex);
+			}
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuShortcutPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuShortcutPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuShortcutPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuShortcutPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,33 @@
+/*
+ *  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 java.beans;
+
+import java.awt.MenuShortcut;
+
+class AwtMenuShortcutPersistenceDelegate extends PersistenceDelegate {
+
+	@Override
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		MenuShortcut shortcut = (MenuShortcut) oldInstance;
+		int keyCode = shortcut.getKey();
+		boolean useShiftModifier = shortcut.usesShiftModifier();
+		return new Expression(shortcut, shortcut.getClass(),
+                Statement.CONSTRUCTOR_NAME, new Object[] {keyCode, useShiftModifier});
+	}
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtMenuShortcutPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtPointPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtPointPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtPointPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtPointPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,27 @@
+/* 
+ * 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 java.beans;
+
+import java.awt.Point;
+
+class AwtPointPersistenceDelegate extends DefaultPersistenceDelegate {
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		Point point = (Point) oldInstance;
+		return new Expression(oldInstance, oldInstance.getClass(),
+				Statement.CONSTRUCTOR_NAME, new Object[] { point.x, point.y });
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtPointPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtScrollPanePersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtScrollPanePersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtScrollPanePersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtScrollPanePersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,29 @@
+/* 
+ * 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 java.beans;
+
+import java.awt.ScrollPane;
+
+class AwtScrollPanePersistenceDelegate extends
+		DefaultPersistenceDelegate {
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		return new Expression(oldInstance, oldInstance.getClass(),
+				Statement.CONSTRUCTOR_NAME,
+				new Object[] { ((ScrollPane) oldInstance)
+						.getScrollbarDisplayPolicy() });
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtScrollPanePersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtSystemColorPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtSystemColorPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtSystemColorPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtSystemColorPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,31 @@
+/*
+ *  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 java.beans;
+
+import java.awt.SystemColor;
+
+class AwtSystemColorPersistenceDelegate extends
+		StaticFieldPersistenceDelegate {
+	public AwtSystemColorPersistenceDelegate() {
+		super();
+	}
+	static {
+		init(SystemColor.class);
+	}
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/AwtSystemColorPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java?view=diff&rev=557439&r1=557438&r2=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java Wed Jul 18 17:56:20 2007
@@ -86,7 +86,21 @@
         
         delegates.put(Choice.class, new AwtChoicePersistenceDelegate());
         delegates.put(Color.class, new AwtColorPersistenceDelegate());
+        delegates.put(Container.class, new AwtContainerPersistenceDelegate());
+        delegates.put(Component.class, new AwtComponentPersistenceDelegate());
+        delegates.put(Cursor.class, new AwtCursorPersistenceDelegate());
+        delegates.put(Dimension.class, new AwtDimensionPersistenceDelegate());
+        delegates.put(Font.class, new AwtFontPersistenceDelegate());
+        delegates.put(Insets.class, new AwtInsetsPersistenceDelegate());
+        delegates.put(List.class, new AwtListPersistenceDelegate());
+        delegates.put(Menu.class, new AwtMenuPersistenceDelegate());
+        delegates.put(MenuBar.class, new AwtMenuBarPersistenceDelegate());
+        delegates.put(MenuShortcut.class, new AwtMenuShortcutPersistenceDelegate());
+        delegates.put(Point.class, new AwtPointPersistenceDelegate());
         delegates.put(Rectangle.class, new AwtRectanglePersistenceDelegate());
+        delegates.put(SystemColor.class, new AwtSystemColorPersistenceDelegate());
+        delegates.put(TextAttribute.class, new AwtFontTextAttributePersistenceDelegate());
+        
 	}
 
 	private ExceptionListener listener = defaultExListener;

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StaticFieldPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StaticFieldPersistenceDelegate.java?view=auto&rev=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StaticFieldPersistenceDelegate.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StaticFieldPersistenceDelegate.java Wed Jul 18 17:56:20 2007
@@ -0,0 +1,58 @@
+/*
+ *  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 java.beans;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+
+class StaticFieldPersistenceDelegate extends
+		PersistenceDelegate {
+
+	public StaticFieldPersistenceDelegate() {
+		super();
+	}
+	
+	static HashMap<Object, String> pairs = new HashMap<Object, String>();
+	static void init(Class<?> clz) {
+		Field[] field = clz.getFields();
+		for (int i = 0; i < field.length; i++) {
+			Object value = null;
+			try {
+				value = field[i].get(clz);
+			} catch (Exception e) {
+				// expected
+			}
+			if (value.getClass() == clz) {
+				pairs.put(value, field[i].getName());
+			}
+		}
+	}
+
+	@Override
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		Field field = null;
+		try {
+			field = oldInstance.getClass().getDeclaredField(pairs.get(oldInstance));
+		} catch (Exception e) {
+			enc.getExceptionListener().exceptionThrown(e);
+		}
+		return new Expression(oldInstance, field, "get",
+				new Object[] { oldInstance.getClass() });
+	}
+
+}
\ No newline at end of file

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StaticFieldPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java?view=diff&rev=557439&r1=557438&r2=557439
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java Wed Jul 18 17:56:20 2007
@@ -19,6 +19,8 @@
 
 import java.awt.*;
 import java.awt.event.*;
+import java.awt.font.TextAttribute;
+import java.awt.dnd.DropTarget;
 import java.beans.Encoder;
 import java.beans.Expression;
 import java.beans.PersistenceDelegate;
@@ -36,8 +38,12 @@
 import java.lang.reflect.Method;
 import java.util.EmptyStackException;
 import java.util.LinkedList;
+import java.util.Locale;
 import java.util.Stack;
 
+import javax.swing.JTabbedPane;
+import javax.swing.LayoutFocusTraversalPolicy;
+
 import junit.framework.TestCase;
 
 import org.apache.harmony.beans.tests.support.mock.MockFoo;
@@ -433,6 +439,367 @@
         assertEquals(choice.getName(), aChoice.getName());
 
         assertEquals(choice.getItem(0), aChoice.getItem(0));
+    }
+    
+    public void test_writeObject_java_awt_SystemColor() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+
+        encoder.writeObject(SystemColor.activeCaption);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        SystemColor color = (SystemColor) decoder.readObject();
+        assertEquals(SystemColor.activeCaption, color);
+    }
+
+    public void test_writeObject_java_awt_font_TextAttribute() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+
+        encoder.writeObject(TextAttribute.BACKGROUND);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        TextAttribute attribute = (TextAttribute) decoder.readObject();
+        assertEquals(TextAttribute.BACKGROUND, attribute);
+    }
+
+    public void test_writeObject_java_awt_MenuShortcut() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        MenuShortcut shortCut = new MenuShortcut(2);
+
+        encoder.writeObject(shortCut);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        MenuShortcut aMenuShortcut = (MenuShortcut) decoder.readObject();
+        assertEquals(shortCut, aMenuShortcut);
+        assertEquals(shortCut.getKey(), aMenuShortcut.getKey());
+    }
+
+    public static class MockComponent extends Component {
+
+        /**
+         * 
+         */
+        private static final long serialVersionUID = 1L;
+    }
+    public void test_writeObject_java_awt_Component() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        
+        Component component = new MockComponent();
+        component.add(new PopupMenu("PopupMenu"));
+        component.setBackground(Color.black);
+        component.setBounds(new Rectangle(1, 1, 10, 10));
+        component.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
+        component.setEnabled(true);
+        component.setFocusable(true);
+        component.setFont(new Font("Arial", 1, 1));
+        component.setForeground(Color.blue);
+        component.setIgnoreRepaint(true);
+        component.setLocale(Locale.CANADA);
+        component.setName("MockComponent");
+        component.setVisible(true);
+        component.setCursor(new Cursor(Cursor.TEXT_CURSOR));
+        component.setDropTarget(new DropTarget());
+
+        encoder.writeObject(component);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        Component aComponent = (Component) decoder.readObject();
+        assertEquals(component.getBackground(), aComponent.getBackground());
+        assertEquals(component.getForeground(), aComponent.getForeground());
+        assertEquals(component.getFont().getFamily(), aComponent.getFont().getFamily());
+        assertEquals(component.getFont().getStyle(), aComponent.getFont().getStyle());
+        assertEquals(component.getFont().getSize(), aComponent.getFont().getSize());
+        assertEquals(component.getName(), aComponent.getName());
+        assertEquals(component.getBounds(), aComponent.getBounds());
+    }
+
+    public void test_writeObject_java_awt_Container() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        Container container = new Container();
+        container.setBackground(Color.blue);
+        container.setFocusTraversalKeysEnabled(true);
+        container.setBounds(0, 0, 10, 10);
+        container.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
+        container.setComponentZOrder(new Label("label"), 0);
+        container.setComponentZOrder(new JTabbedPane(), 1);
+        container.setCursor(new Cursor(Cursor.WAIT_CURSOR));
+        container.setFocusTraversalKeysEnabled(true);
+        container.setFocusable(true);
+        container.setFocusTraversalPolicyProvider(true);
+        container.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
+        container.setFont(new Font("Arial Bold", Font.ITALIC, 0));
+        container.setForeground(Color.green);
+        container.setIgnoreRepaint(true);
+        container.setLocation(1, 2);
+        container.setName("container");
+        container.setSize(new Dimension(200, 100));
+        container.setEnabled(true);
+        container.setFocusCycleRoot(true);
+        container.setLayout(new BorderLayout());
+        container.setLocale(Locale.CANADA);
+        container.setVisible(true);
+        container.add(new Label("label"));
+        container.add(new JTabbedPane());
+
+        encoder.writeObject(container);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        Container aContainer = (Container) decoder.readObject();
+        assertEquals(container.getFocusTraversalKeysEnabled(), aContainer
+                .getFocusTraversalKeysEnabled());
+        assertEquals(Color.blue, aContainer.getBackground());
+        assertEquals(new Rectangle(1, 2, 200, 100), aContainer.getBounds());
+        
+        // ComponentOrientation is not persistent
+        assertTrue(aContainer.getComponentOrientation().isLeftToRight());
+        Component [] components = aContainer.getComponents();
+        assertTrue(components[0] instanceof Label);
+        assertEquals(0, aContainer.getComponentZOrder(components[0]));
+        assertTrue(components[1] instanceof JTabbedPane);
+        assertEquals(1, aContainer.getComponentZOrder(components[1]));
+        
+        // Cursor will not be persisted
+        assertEquals(Cursor.DEFAULT_CURSOR, aContainer.getCursor().getType());
+        // DropTarget will not be persisted
+        assertNull(aContainer.getDropTarget());
+        
+        assertEquals(container.getFocusTraversalPolicy().getClass(), aContainer
+                .getFocusTraversalPolicy().getClass());
+        assertEquals(container.getName(), aContainer.getName());
+
+        container = new Container();
+        container.setFocusCycleRoot(true);
+        byteArrayOutputStream = new ByteArrayOutputStream();
+        encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        encoder.writeObject(container);
+        encoder.close();
+        stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        decoder = new XMLDecoder(stream);
+        aContainer = (Container) decoder.readObject();
+        assertTrue(aContainer.isFocusCycleRoot());
+        
+    }
+    
+    public void test_writeObject_java_awt_Menu() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        Menu menu = new Menu();
+        String action = "menu action command";
+        menu.setActionCommand(action);
+        menu.setEnabled(true);
+        menu.setFont(new Font("Arial Black", Font.BOLD, 10));
+        menu.setLabel("menu");
+        menu.setName("menu");
+        menu.setShortcut(new MenuShortcut(10));
+        menu.insertSeparator(1);
+
+        encoder.writeObject(menu);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        Menu aMenu = (Menu) decoder.readObject();
+        assertTrue(aMenu.isEnabled());
+        assertEquals(action, aMenu.getActionCommand());
+        assertEquals(menu.getFont().getSize(), aMenu.getFont().getSize());
+        assertEquals(menu.getFont().getStyle(), aMenu.getFont().getStyle());
+        assertEquals(menu.getLabel(), aMenu.getLabel());
+        assertEquals(menu.getName(), aMenu.getName());
+        assertEquals(menu.getShortcut().getKey(), aMenu.getShortcut().getKey());
+        assertEquals(1, menu.getItemCount());
+        assertEquals(menu.getItem(0).getLabel(), aMenu.getItem(0).getLabel());
+        assertEquals(menu.getItem(0).getName(), aMenu.getItem(0).getName());
+        assertEquals(menu.getItem(0).getFont().getStyle(), aMenu.getItem(0).getFont().getStyle());
+        assertEquals(menu.getFont().getSize(), aMenu.getItem(0).getFont().getSize());
+        
+    }
+
+    public void test_writeObject_java_awt_MenuBar() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+ 
+        MenuBar bar = new MenuBar();
+        bar.add(new Menu("menu1"));
+
+        encoder.writeObject(bar);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        MenuBar aBar = (MenuBar) decoder.readObject();
+        assertEquals(bar.getMenu(0).getName(), aBar.getMenu(0).getName());
+        
+    }
+
+    public void test_writeObject_java_awt_List() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+
+        java.awt.List list = new List();
+        list.setBounds(0, 0, 10, 10);
+        list.add(new PopupMenu("popupMenu"));
+        list.add("1");
+        list.add("2", 2);
+        list.setBackground(Color.BLUE);
+        encoder.writeObject(list);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        List aList = (List) decoder.readObject();
+        assertEquals(list.getItem(0), aList.getItem(0));
+        assertEquals(list.getHeight(), aList.getHeight());
+        assertEquals(list.getBackground(), aList.getBackground());
+    }
+
+    public void test_writeObject_java_awt_BorderLayout(){
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+
+        BorderLayout layout = new BorderLayout();
+        layout.setHgap(2);
+        layout.setVgap(3);
+        encoder.writeObject(layout);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        BorderLayout aLayout = (BorderLayout) decoder.readObject();
+        assertEquals(layout.getHgap(), aLayout.getHgap());
+        assertEquals(layout.getVgap(), aLayout.getVgap());
+    }
+
+    public void test_writeObject_java_awt_CardLayout(){
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        
+        CardLayout layout = new CardLayout();
+        layout.addLayoutComponent(new Label("label"), "constraints");
+        layout.setHgap(2);
+        layout.setVgap(3);
+        encoder.writeObject(layout);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        CardLayout aLayout = (CardLayout) decoder.readObject();
+        assertEquals(layout.getHgap(), aLayout.getHgap());
+        assertEquals(layout.getVgap(), aLayout.getVgap());
+    }
+
+    public void test_writeObject_java_awt_GridBagLayout() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+
+        GridBagLayout layout = new GridBagLayout();
+        layout.addLayoutComponent(new Label("label"), new GridBagConstraints(0,
+                0, 100, 60, 0.1, 0.1, GridBagConstraints.WEST,
+                GridBagConstraints.NONE, new Insets(0,0, 99, 59), 0, 0));
+        encoder.writeObject(layout);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        GridBagLayout aLayout = (GridBagLayout) decoder.readObject();
+        assertEquals(layout.getConstraints(new Label("label")).weightx, aLayout
+                .getConstraints(new Label("label")).weightx);
+        assertEquals(layout.getConstraints(new Label("label")).insets.left, aLayout
+                .getConstraints(new Label("label")).insets.left);
+    }
+    
+    public void test_writeObject_java_awt_Cursor() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        Cursor cursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
+
+        encoder.writeObject(cursor);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        Cursor aCursor = (Cursor) decoder.readObject();
+        assertEquals(cursor.getName(), aCursor
+                .getName());
+        assertEquals(cursor.getType(), aCursor.getType());
+    }
+    
+    public void test_writeObject_java_awt_Insets() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        Insets inset = new Insets(0, 0, 10, 10);
+
+        encoder.writeObject(inset);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        Insets aInset = (Insets) decoder.readObject();
+        assertEquals(inset.left, aInset.left);
+        assertEquals(inset.top, aInset.top);
+    }
+    
+    public void test_writeObject_java_awt_point() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        Point point = new Point(10, 20);
+        
+        encoder.writeObject(point);
+        encoder.close();
+        
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        Point aPoint = (Point) decoder.readObject();
+        assertEquals(point, aPoint);
+    }
+
+    public void test_writeObject_java_awt_ScrollPane() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        ScrollPane scrollPane = new ScrollPane();
+        
+        encoder.writeObject(scrollPane);
+        encoder.close();
+        
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        ScrollPane aScrollPane = (ScrollPane) decoder.readObject();
+        assertEquals(scrollPane.getAlignmentX(), aScrollPane.getAlignmentX());
+        assertEquals(scrollPane.getAlignmentY(), aScrollPane.getAlignmentY());
+        assertEquals(scrollPane.getScrollbarDisplayPolicy(), aScrollPane
+                .getScrollbarDisplayPolicy());
     }
 
     // <--



Mime
View raw message