You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/03/20 17:31:33 UTC
svn commit: r387239 [13/21] - in
/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math: ./
Harmony/ doc/ doc/images/ make/ src/ src/common/ src/common/javasrc/
src/common/javasrc/java/ src/common/javasrc/java/applet/
src/common/javasrc/ja...
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.PersistenceDelegate;
+import java.beans.DefaultPersistenceDelegate;
+import java.util.StringTokenizer;
+import java.util.HashMap;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public final class DefaultPersistenceDelegatesFactory {
+
+ private static HashMap persistenceDelegates = new HashMap();
+
+ private static PersistenceDelegate createPersistenceDelegate(Class type) {
+ PersistenceDelegate pd = null;
+ try {
+ String className = createDefaultNameForPersistenceDelegateClass(
+ type);
+ pd = (PersistenceDelegate) Class.forName(
+ className, true, type.getClassLoader()).newInstance();
+ } catch (Exception e) {
+ Class ancestor = type.getSuperclass();
+
+ while(ancestor != null) {
+ try {
+ String className =
+ createDefaultNameForPersistenceDelegateClass(ancestor);
+ pd = (PersistenceDelegate) Class.forName(
+ className, true,
+ type.getClassLoader()).newInstance();
+ } catch(Exception e2) {
+ ancestor = ancestor.getSuperclass();
+ }
+ }
+
+ if(pd == null) {
+ pd = new DefaultPersistenceDelegate();
+ }
+ }
+ return pd;
+ }
+
+ public static PersistenceDelegate getPersistenceDelegate(Class type) {
+ String className = type.getName();
+ PersistenceDelegate result =
+ (PersistenceDelegate) persistenceDelegates.get(className);
+ if(result == null) {
+ if(type.isArray()) {
+ result = org.apache.harmony.beans.ArrayPersistenceDelegate.getInstance();
+ } else {
+ result = createPersistenceDelegate(type);
+ persistenceDelegates.put(className, result);
+ }
+ }
+ return result;
+ }
+
+ private static String createDefaultNameForPersistenceDelegateClass(
+ Class type) {
+ String typeName = type.getName();
+ StringTokenizer st = new StringTokenizer(typeName, ".");
+ String className = "";
+ while(st.hasMoreElements()) {
+ String s = (String) st.nextElement();
+ className += "".equals(className) ? s : "_" + s;
+ }
+ return "org.apache.harmony.beans." + className + "PersistenceDelegate";
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/Handler.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/Handler.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/Handler.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/Handler.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.util.HashMap;
+import java.util.Stack;
+import java.util.Vector;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import java.beans.XMLDecoder;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class Handler extends DefaultHandler {
+
+ private Vector result;
+ private Vector commands;
+ private XMLDecoder decoder;
+ private HashMap references;
+ private Stack stack;
+ private int tabCount;
+
+ public Handler(XMLDecoder decoder, Vector result) {
+ this.decoder = decoder;
+ this.result = result;
+ this.commands = new Vector();
+ this.references = new HashMap();
+ this.stack = new Stack();
+ }
+
+ // clear collections to prepare parsing document
+ public void startDocument() {
+ references.clear();
+ tabCount = 0;
+ }
+
+ // create new command and put it on stack
+ public void startElement(String namespaceURI, String localeName,
+ String tagName, Attributes attrs) throws SAXException
+ {
+ Command.printAttrs(tabCount, tagName, attrs);
+ Command cmd = tagName.equals("java") ? new Command(decoder, tagName,
+ Command.parseAttrs(tagName, attrs)) :
+ new Command(tagName, Command.parseAttrs(tagName, attrs));
+ stack.push(cmd);
+ ++tabCount;
+ }
+
+ // add data to command
+ public void characters(char[] text, int start, int length)
+ throws SAXException {
+ if(length > 0) {
+ String data = String.valueOf(text, start, length).replace('\n', ' ')
+ .replace('\t', ' ').trim();
+ if(data.length() > 0) {
+ Command.prn(tabCount, tabCount + ">setting data=" + data
+ + "<EOL>");
+ Command cmd = (Command) stack.peek();
+ cmd.setData(data);
+ }
+ }
+ }
+
+ // pop command from stack and put it to one of collections
+ public void endElement(String namespaceURI, String localeName,
+ String tagName) throws SAXException
+ {
+ Command cmd = (Command) stack.pop();
+ cmd.setTabCount(tabCount);
+
+ // find if command works in context
+ if(!stack.isEmpty()) {
+ Command ctx = (Command) stack.peek();
+ ctx.addChild(cmd);
+ }
+
+ // upper level commands
+ if(stack.size() == 1 && cmd.isExecutable()){
+ commands.add(cmd);
+ }
+
+ // store reference to command
+ if(cmd.hasAttr("id")) {
+ references.put(cmd.getAttr("id"), cmd);
+ }
+
+ try {
+ cmd.exec(references);
+ } catch (Exception e) {
+ throw new SAXException(e);
+ }
+
+ if(--tabCount < 0) {
+ tabCount = 0;
+ }
+
+ Command.prn(tabCount, tabCount + ">...<" + tagName + "> end");
+ }
+
+ // iterate over deferred commands and execute them again
+ public void endDocument() throws SAXException {
+ for(int i = 0; i < commands.size(); ++i) {
+ Command cmd = (Command) commands.elementAt(i);
+ boolean backtracked = true;
+ try {
+ backtracked = cmd.backtrack(references);
+ } catch (Exception e) {
+ throw new SAXException("Exception in command excution");
+ }
+ /*
+ if(!backtracked)
+ throw new SAXException("Command " + cmd.getTagName() +
+ " is unresolved on second run() call.");
+ */
+ }
+
+ for(int i = 0; i < commands.size(); ++i) {
+ Command cmd = (Command) commands.elementAt(i);
+ result.add(cmd.getResultValue());
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/NullPersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/NullPersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/NullPersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/NullPersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class NullPersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ return new Expression(null, null, null, null);
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/ObjectNode.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/ObjectNode.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/ObjectNode.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/ObjectNode.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Expression;
+import java.beans.Statement;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class ObjectNode {
+
+ private Expression initializer;
+ private Object objectValue = null;
+ private HashMap nodes;
+
+ private Vector statements = new Vector();
+ private Vector expressions = new Vector();
+ private Vector referencedExpressions = new Vector();
+
+ private int referencesNumber = 0;
+ private String id = null;
+
+ public ObjectNode(Expression initializer) {
+ this.initializer = initializer;
+ this.nodes = null;
+ }
+
+ public ObjectNode(Expression initializer, HashMap nodes) {
+ this.initializer = initializer;
+ this.nodes = nodes;
+ }
+
+ public Expression getInitializer() {
+ return initializer;
+ }
+
+ public Object getObjectValue() throws Exception {
+ if(objectValue != null) {
+ return objectValue;
+ }
+
+ if(nodes != null) {
+ Object[] oldArgs = initializer.getArguments();
+ Object[] newArgs = new Object[oldArgs.length];
+
+ for(int i = 0; i < oldArgs.length; ++i) {
+ if(oldArgs[i] != null) {
+ ObjectNode node = (ObjectNode) nodes.get(oldArgs[i]);
+ newArgs[i] = node.getObjectValue();
+ } else {
+ newArgs[i] = null;
+ }
+ }
+
+ objectValue = (new Expression(initializer.getTarget(),
+ initializer.getMethodName(), newArgs)).getValue();
+ } else {
+ objectValue = initializer.getValue();
+ }
+
+ return objectValue;
+ }
+
+ public Class getObjectType() throws Exception {
+ Object value = getObjectValue();
+ return (value != null) ? value.getClass() : null;
+ }
+
+ public Object[] getObjectArguments() {
+ return initializer.getArguments();
+ //return (nodes == null) ? new Object[0] : initializer.getArguments();
+ }
+
+ public int getReferencesNumber() {
+ return referencesNumber;
+ }
+
+ public int getReferencedExpressionsNumber() {
+ return referencedExpressions.size();
+ }
+
+ public void addReference() {
+ referencesNumber++;
+ }
+
+ public void addReferencedExpression(Expression expr) {
+ referencedExpressions.add(expr);
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void addExpression(Expression expression) {
+ expressions.add(expression);
+ }
+
+ public void addStatement(Statement statement) {
+ boolean found = false;
+ Iterator i = statements.iterator();
+ while(i.hasNext()) {
+ Statement s = (Statement) i.next();
+
+ if(s.equals(statement)) {
+ found = true;
+ break;
+ }
+ }
+
+ if(!found) {
+ statements.add(statement);
+ }
+ }
+
+ public Enumeration expressions() {
+ return expressions.elements();
+ }
+
+ public Enumeration referencedExpressions() {
+ return referencedExpressions.elements();
+ }
+
+ public Enumeration statements() {
+ return statements.elements();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/BooleanEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/BooleanEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/BooleanEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/BooleanEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class BooleanEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public BooleanEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public BooleanEditor() {
+ super();
+ }
+
+ public String getAsText() {
+ return getValueAsString();
+ }
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ setValue(new Boolean(text));
+ }
+
+ public String getJavaInitializationString() {
+ return getValueAsString();
+ }
+
+ public String[] getTags() {
+ return new String[] {"true", "false"};
+ }
+
+ public void setValue(Object value) {
+ if(value instanceof Boolean) {
+ super.setValue(value);
+ }
+ }
+
+ private String getValueAsString() {
+ String result = null;
+ Object value = getValue();
+ if(value != null) {
+ Boolean bValue = (Boolean) value;
+ result = bValue.toString();
+ }
+ return result;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ByteEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ByteEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ByteEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ByteEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class ByteEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public ByteEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public ByteEditor() {
+ super();
+ }
+
+ public String getAsText() {
+ return getValueAsText();
+ }
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ try {
+ setValue(new Byte(text));
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(nfe.toString());
+ }
+ }
+
+ public String getJavaInitializationString() {
+ return getValueAsText();
+ }
+
+ public String[] getTags() {
+ return null;
+ }
+
+ public void setValue(Object value) {
+ if(value instanceof Byte) {
+ super.setValue(value);
+ }
+ }
+
+ private String getValueAsText() {
+ String result = null;
+ Object value = getValue();
+ if(value != null) {
+ Byte bValue = (Byte) value;
+ result = bValue.toString();
+ }
+ return result;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ColorEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ColorEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ColorEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ColorEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class ColorEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public ColorEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public ColorEditor() {
+ super();
+ }
+
+ public Component getCustomEditor() {
+ return null;
+ }
+
+ public boolean supportsCustomEditor() {
+ return true;
+ }
+
+ public String getJavaInitializationString() {
+ String result = null;
+ Color color = (Color) getValue();
+ if(color != null) {
+ int red = color.getRed();
+ int green = color.getGreen();
+ int blue = color.getBlue();
+ result = "new Color(" + red + "," + green + "," + blue + ")";
+ }
+ return result;
+ }
+
+ public String[] getTags() {
+ return null;
+ }
+
+ public void setValue(Object value) {
+ if(value instanceof Color) {
+ super.setValue(value);
+ }
+ }
+
+ public boolean isPaintable() {
+ return true;
+ }
+
+ public void paintValue(Graphics gfx, Rectangle box) {
+ Color color = (Color) getValue();
+ if(color != null) {
+ gfx.setColor(color);
+ gfx.drawRect(box.x, box.y, box.x + box.width, box.y + box.height);
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/DoubleEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/DoubleEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/DoubleEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/DoubleEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class DoubleEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public DoubleEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public DoubleEditor() {
+ super();
+ }
+
+ public String getAsText() {
+ return getValueAsText();
+ }
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ try {
+ setValue(new Double(text));
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(nfe.toString());
+ }
+ }
+
+ public String getJavaInitializationString() {
+ return getValueAsText();
+ }
+
+ public String[] getTags() {
+ return null;
+ }
+
+ public void setValue(Object value) {
+ if(value instanceof Double) {
+ super.setValue(value);
+ }
+ }
+
+ private String getValueAsText() {
+ String result = null;
+ Object value = getValue();
+ if(value != null) {
+ Double dValue = (Double) value;
+ result = dValue.toString();
+ }
+ return result;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/FloatEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/FloatEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/FloatEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/FloatEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class FloatEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public FloatEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public FloatEditor() {
+ super();
+ }
+
+ public String getAsText() {
+ return getValueAsText();
+ }
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ try {
+ setValue(new Float(text));
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(nfe.toString());
+ }
+ }
+
+ public String getJavaInitializationString() {
+ return getValueAsText();
+ }
+
+ public String[] getTags() {
+ return null;
+ }
+
+ public void setValue(Object value) {
+ if(value instanceof Float) {
+ super.setValue(value);
+ }
+ }
+
+ private String getValueAsText() {
+ String result = null;
+ Object value = getValue();
+ if(value != null) {
+ Float fValue = (Float) value;
+ result = fValue.toString();
+ }
+ return result;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/FontEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/FontEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/FontEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/FontEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class FontEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public FontEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public FontEditor() {
+ super();
+ }
+
+ public Component getCustomEditor() {
+ return null;
+ }
+
+ public boolean supportsCustomEditor() {
+ return true;
+ }
+
+ public String getJavaInitializationString() {
+ String result = null;
+ Font font = (Font) getValue();
+ if(font != null) {
+ String name = font.getName();
+ int style = font.getStyle();
+ int size = font.getSize();
+ result = "new Font(" + name + "," + style + "," + size + ")";
+ }
+ return result;
+ }
+
+ public String[] getTags() {
+ return null;
+ }
+
+ public void setValue(Object value) {
+ if(value instanceof Font) {
+ super.setValue(value);
+ }
+ }
+
+ public boolean isPaintable() {
+ return true;
+ }
+
+ public void paintValue(Graphics gfx, Rectangle box) {
+ Font font = (Font) getValue();
+ if(font != null) {
+ gfx.setFont(font);
+ gfx.drawBytes("Hello".getBytes(), box.x, box.y, box.x + box.width,
+ box.y + box.height);
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/IntEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/IntEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/IntEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/IntEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class IntEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public IntEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public IntEditor() {
+ super();
+ }
+
+ public String getAsText() {
+ return getValueAsText();
+ }
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ try {
+ setValue(new Integer(text));
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(nfe.toString());
+ }
+ }
+
+ public String getJavaInitializationString() {
+ return getValueAsText();
+ }
+
+ public String[] getTags() {
+ return null;
+ }
+
+ public void setValue(Object value) {
+ if(value instanceof Integer) {
+ super.setValue(value);
+ }
+ }
+
+ private String getValueAsText() {
+ String result = null;
+ Object value = getValue();
+ if(value != null) {
+ Integer iValue = (Integer) value;
+ result = iValue.toString();
+ }
+ return result;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/LongEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/LongEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/LongEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/LongEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class LongEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public LongEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public LongEditor() {
+ super();
+ }
+
+ public String getAsText() {
+ return getValueAsText();
+ }
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ try {
+ setValue(new Long(text));
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(nfe.toString());
+ }
+ }
+
+ public String getJavaInitializationString() {
+ return getValueAsText();
+ }
+
+ public String[] getTags() {
+ return null;
+ }
+
+ public void setValue(Object value) {
+ if(value instanceof Long) {
+ super.setValue(value);
+ }
+ }
+
+ private String getValueAsText() {
+ String result = null;
+ Object value = getValue();
+ if(value != null) {
+ Long lValue = (Long) value;
+ result = lValue.toString();
+ }
+ return result;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ShortEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ShortEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ShortEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/ShortEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class ShortEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public ShortEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public ShortEditor() {
+ super();
+ }
+
+ public String getAsText() {
+ return getValueAsText();
+ }
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ try {
+ setValue(new Short(text));
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(nfe.toString());
+ }
+ }
+
+ public String getJavaInitializationString() {
+ return getValueAsText();
+ }
+
+ public String[] getTags() {
+ return null;
+ }
+
+ public void setValue(Object value) {
+ if(value instanceof Short) {
+ super.setValue(value);
+ }
+ }
+
+ private String getValueAsText() {
+ String result = null;
+ Object value = getValue();
+ if(value != null) {
+ Short sValue = (Short) value;
+ result = sValue.toString();
+ }
+ return result;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/StringEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/StringEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/StringEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/editors/StringEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class StringEditor extends PropertyEditorSupport {
+
+ /**
+ *
+ * @param source
+ */
+ public StringEditor(Object source) {
+ super(source);
+ }
+
+ /**
+ */
+ public StringEditor() {
+ super();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_BooleanPersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_BooleanPersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_BooleanPersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_BooleanPersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_BooleanPersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ boolean value = ((Boolean) oldInstance).booleanValue();
+ return new Expression(oldInstance, Boolean.class, "new",
+ new Object[] { new Boolean(value) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_BytePersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_BytePersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_BytePersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_BytePersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_BytePersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ Byte value = (Byte) oldInstance;
+ return new Expression(oldInstance, Byte.class, "new",
+ new Object[] { new Byte(value.byteValue()) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_CharacterPersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_CharacterPersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_CharacterPersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_CharacterPersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_CharacterPersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ Character value = (Character) oldInstance;
+ return new Expression(oldInstance, Character.class, "new",
+ new Object[] { new Character(value.charValue()) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_ClassPersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_ClassPersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_ClassPersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_ClassPersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_ClassPersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ Class value = (Class) oldInstance;
+ return new Expression(oldInstance, Class.class, "forName",
+ new Object[] { new String(value.getName()) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_DoublePersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_DoublePersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_DoublePersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_DoublePersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_DoublePersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ Double value = (Double) oldInstance;
+ return new Expression(oldInstance, Double.class, "new",
+ new Object[] { new Double(value.doubleValue()) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_FloatPersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_FloatPersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_FloatPersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_FloatPersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_FloatPersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ Float value = (Float) oldInstance;
+ return new Expression(oldInstance, Float.class, "new",
+ new Object[] { new Float(value.floatValue()) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_IntegerPersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_IntegerPersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_IntegerPersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_IntegerPersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_IntegerPersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ Integer value = (Integer) oldInstance;
+ return new Expression(oldInstance, Integer.class, "new",
+ new Object[] { new Integer(value.intValue()) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_LongPersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_LongPersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_LongPersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_LongPersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_LongPersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ Long value = (Long) oldInstance;
+ return new Expression(oldInstance, Long.class, "new",
+ new Object[] { new Long(value.longValue()) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_ShortPersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_ShortPersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_ShortPersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_ShortPersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_ShortPersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ Short value = (Short) oldInstance;
+ return new Expression(oldInstance, Short.class, "new",
+ new Object[] { new Short(value.shortValue()) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_StringPersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_StringPersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_StringPersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/org/apache/harmony/beans/java_lang_StringPersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.beans;
+
+import java.beans.Encoder;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.2.1 $
+ */
+
+public class java_lang_StringPersistenceDelegate extends PersistenceDelegate {
+
+ protected Expression instantiate(Object oldInstance, Encoder out) {
+ String value = (String) oldInstance;
+ return new Expression(oldInstance, String.class, "new",
+ new Object[] { new String(value) });
+ }
+
+ protected void initialize(
+ Class type, Object oldInstance, Object newInstance, Encoder out) {
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/BeanDescriptorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/BeanDescriptorTest.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/BeanDescriptorTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/BeanDescriptorTest.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.6.3 $
+ */
+package java.beans;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * The test checks the class java.beans.BeanDescriptor
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.1.6.3 $
+ */
+
+public class BeanDescriptorTest extends TestCase {
+
+ /**
+ *
+ */
+ public BeanDescriptorTest() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public BeanDescriptorTest(String name) {
+ super(name);
+ }
+
+ /**
+ * The test checks the method testNullaryConstructor()
+ */
+ public void testNullaryConstructor() {
+ BeanDescriptor bd= new BeanDescriptor(String.class);
+ assertEquals(bd.getName(), "String");
+ }
+
+ /**
+ *
+ */
+ public static Test suite() {
+ return new TestSuite(BeanDescriptorTest.class);
+ }
+
+ /**
+ *
+ */
+ public static void main(String[] args) {
+ TestRunner.run(suite());
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/BeansTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/BeansTest.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/BeansTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/BeansTest.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.3.6.4 $
+ */
+package java.beans;
+
+import java.beans.auxiliary.SampleBean;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * The test checks the class java.beans.Beans
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.3.6.4 $
+ */
+
+public class BeansTest extends TestCase {
+
+ /**
+ *
+ */
+ public BeansTest() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public BeansTest(String name) {
+ super(name);
+ }
+
+ /**
+ * The test checks the method instantiate()
+ * using specific classloader for class loading
+ */
+ public void testLoadBySpecificClassLoader() {
+ String beanName = "java.beans.auxiliary.SampleBean";
+
+ try {
+ ClassLoader cls = createSpecificClassLoader();
+ Object bean = Beans.instantiate(cls, beanName);
+
+ assertNotNull(bean);
+ assertEquals(bean.getClass(), SampleBean.class);
+
+ SampleBean sampleBean = (SampleBean) bean;
+ checkValues(sampleBean);
+ } catch (ClassNotFoundException cnfe) {
+ fail("Class with name " + beanName + " is not found");
+ } catch (IOException ioe) {
+ fail("IOException is thrown while loading " + beanName + " class");
+ }
+ }
+
+ /**
+ * The test checks the method instantiate()
+ * using default classloader for class loading
+ */
+ public void testLoadByDefaultClassLoader() {
+ String beanName = "java.beans.auxiliary.SampleBean";
+
+ try {
+ Object bean = Beans.instantiate(null, beanName);
+
+ assertNotNull(bean);
+ assertEquals(bean.getClass(), SampleBean.class);
+
+ SampleBean sampleBean = (SampleBean) bean;
+ checkValues(sampleBean);
+ } catch (ClassNotFoundException cnfe) {
+ fail("Class with name " + beanName + " is not found");
+ } catch (IOException ioe) {
+ fail("IOException is thrown while loading " + beanName + " class");
+ }
+ }
+
+ /**
+ *
+ */
+ public static Test suite() {
+ return new TestSuite(BeansTest.class);
+ }
+
+ /**
+ *
+ */
+ public static void main(String[] args) {
+ TestRunner.run(suite());
+ }
+
+ private ClassLoader createSpecificClassLoader() {
+ return new ClassLoader() {
+ public Class loadClass(String name) throws ClassNotFoundException {
+ Class result = super.loadClass(name);
+ return result;
+ }
+ };
+ }
+
+ private void checkValues(SampleBean sampleBean) {
+ assertEquals(null, sampleBean.getText());
+ }
+}
\ No newline at end of file
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/EventHandlerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/EventHandlerTest.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/EventHandlerTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/EventHandlerTest.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,286 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.4.6.4 $
+ */
+package java.beans;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.beans.EventHandler;
+import java.beans.auxiliary.InvocationObject;
+import java.beans.auxiliary.SampleEvent;
+import java.beans.auxiliary.SampleListener;
+import java.lang.reflect.Method;
+
+/**
+ * The test checks the class java.beans.EventHandler
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.4.6.4 $
+ */
+
+public class EventHandlerTest extends TestCase {
+
+ private Object object;
+ private String methodName;
+ private Object[] params;
+
+ private String text = "something";
+
+ /**
+ *
+ */
+ public EventHandlerTest() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public EventHandlerTest(String name) {
+ super(name);
+ }
+
+ /**
+ * The test checks event handler accessors
+ */
+ public void testAccessors() {
+ InvocationObject invocationObject = new InvocationObject(this);
+ EventHandler handler = new EventHandler(
+ invocationObject, "someText", "source.text", "actionPerformed" );
+ assertEquals(invocationObject, handler.getTarget());
+ assertEquals("someText", handler.getAction());
+ assertEquals("source.text", handler.getEventPropertyName());
+ assertEquals("actionPerformed", handler.getListenerMethodName());
+ }
+
+ /**
+ * The test checks the method invoke() with null listener value
+ */
+ public void testNullListenerMethodName() {
+ InvocationObject invocationObject = new InvocationObject(this);
+
+ EventHandler handler = new EventHandler(
+ invocationObject, "someText", "source.text", null );
+
+ Object proxy = EventHandler.create(ActionListener.class,
+ invocationObject, "someText", "source.text");
+
+ Method m = null;
+ try {
+ m = ActionListener.class.getMethod("actionPerformed",
+ new Class[] { ActionEvent.class } );
+ Object result = handler.invoke(proxy, m,
+ new Object[] { new ActionEvent(this, 0, "") } );
+
+ assertEquals(invocationObject.getSomeText(), getText());
+ } catch (Exception e) {
+ fail("Method actionPerformed not found in interface");
+ }
+ }
+
+ /**
+ * The test checks the method invoke()
+ */
+ public void testInvoke() {
+ InvocationObject invocationObject = new InvocationObject(this);
+
+ EventHandler handler = new EventHandler(
+ invocationObject, "someText", "source.text", "actionPerformed" );
+
+ Object proxy = EventHandler.create(ActionListener.class,
+ invocationObject, "someText", "source.text");
+
+ Method m = null;
+ try {
+ m = ActionListener.class.getMethod("actionPerformed",
+ new Class[] { ActionEvent.class } );
+ Object result = handler.invoke(proxy, m,
+ new Object[] { new ActionEvent(this, 0, "") } );
+
+ assertEquals(invocationObject, handler.getTarget());
+ assertEquals(invocationObject.getSomeText(), getText());
+ } catch (Exception e) {
+ fail("Method actionPerformed not found in interface");
+ }
+ }
+
+ /**
+ * The test checks the method invoke() with null property name
+ */
+ public void testInvokeWithNullPropertyName() {
+ InvocationObject invocationObject = new InvocationObject(this);
+
+ EventHandler handler = new EventHandler(
+ invocationObject, "doSomething", null, null );
+
+ Object proxy = EventHandler.create(SampleListener.class,
+ invocationObject, "doSomething");
+
+ try {
+ Method m = SampleListener.class.getMethod(
+ "fireSampleEvent", new Class[] { SampleEvent.class } );
+ Object result = handler.invoke(proxy, m, null);
+
+ assertEquals(invocationObject, handler.getTarget());
+ assertEquals("doSomething", getMethodName());
+ } catch (Exception e) {
+ fail("Method doSomething not found in interface");
+ }
+ }
+
+ /**
+ * The test checks the object created with the create() method call
+ */
+ public void testCreateWithMethodCall() {
+ Object invocationObject = new InvocationObject(this);
+ ActionListener listener = (ActionListener) EventHandler.create(
+ ActionListener.class, invocationObject, "doSomething");
+ listener.actionPerformed(new ActionEvent(this, 0, ""));
+
+ assertEquals(getObject(), invocationObject);
+ assertEquals("doSomething", getMethodName());
+
+ Object[] params = getParams();
+ if(params.length != 0) {
+ fail("Number of params should be 0");
+ }
+ }
+
+ /**
+ * The test checks the setter is initialized properly
+ */
+ public void testCreateWithSetterCall() {
+ Object invocationObject = new InvocationObject(this);
+ ActionEvent ae = new ActionEvent(this, 0, "");
+ ActionListener listener = (ActionListener) EventHandler.create(
+ ActionListener.class, invocationObject, "someObject", "source");
+ listener.actionPerformed(ae);
+
+ assertEquals(getObject(), invocationObject);
+ assertEquals("setSomeObject", getMethodName());
+
+ Object[] params = getParams();
+ if(params.length != 1) {
+ fail("Number of params should be 1");
+ } else {
+ assertEquals(ae.getSource(), params[0]);
+ }
+ }
+
+ /**
+ * The test checks the object created with the create() method call for
+ * dot-separated property
+ */
+ public void testCreateWithDottedParameterCall() {
+ Object invocationObject = new InvocationObject(this);
+ ActionEvent ae = new ActionEvent(this, 0, "");
+ ActionListener listener = (ActionListener) EventHandler.create(
+ ActionListener.class, invocationObject, "someText", "source.text");
+ listener.actionPerformed(ae);
+
+ assertEquals(getObject(), invocationObject);
+ assertEquals("setSomeText", getMethodName());
+
+ Object[] params = getParams();
+ if(params.length != 1) {
+ fail("Number of params should be 1");
+ } else {
+ assertEquals(((EventHandlerTest) ae.getSource()).getText(),
+ params[0]);
+ }
+ }
+
+ /**
+ * The test checks the event is fired for object created with the create()
+ */
+ public void testCreateWithMethodCallWhichIsSetter() {
+ InvocationObject invocationObject = new InvocationObject(this);
+ SampleEvent event = new SampleEvent("bean");
+
+ SampleListener listener = (SampleListener) EventHandler.create(
+ SampleListener.class,
+ invocationObject, "doSomething", "i", null);
+
+ listener.fireSampleEvent(event);
+
+ assertEquals("doSomething", getMethodName());
+ assertTrue(event.getI() == invocationObject.getIntValue());
+ }
+
+ /**
+ * fireSampleEvent scenario
+ */
+ public void testCreateForStaticMethodAsPropertyGetter() {
+ InvocationObject invocationObject = new InvocationObject(this);
+ SampleEvent event = new SampleEvent("bean");
+
+ SampleListener listener = (SampleListener) EventHandler.create(
+ SampleListener.class,
+ invocationObject, "someValue", "j");
+
+ listener.fireSampleEvent(event);
+
+ assertEquals("setSomeValue", getMethodName());
+ }
+
+ /**
+ *
+ */
+ public static Test suite() {
+ //TestSuite suite = new TestSuite();
+ //suite.addTest(new EventHandlerTest("testCreateForStaticMethodAsPropertyGetter"));
+ //return suite;
+ return new TestSuite(EventHandlerTest.class);
+ }
+
+ /**
+ *
+ */
+ public static void main(String[] args) {
+ TestRunner.run(suite());
+ }
+
+ public void logMethodCall(
+ Object object, String methodName, Object[] params) {
+ this.object = object;
+ this.methodName = methodName;
+ this.params = params;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ private Object getObject() {
+ return object;
+ }
+
+ private String getMethodName() {
+ return methodName;
+ }
+
+ private Object[] getParams() {
+ return params;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/EventSetDescriptorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/EventSetDescriptorTest.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/EventSetDescriptorTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/beans/EventSetDescriptorTest.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.2.6.3 $
+ */
+package java.beans;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import java.beans.EventSetDescriptor;
+import java.beans.auxiliary.OtherBean;
+import java.beans.auxiliary.SampleListener;
+
+/**
+ * The test checks the class java.beans.EventSetDescriptor
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.2.6.3 $
+ */
+
+public class EventSetDescriptorTest extends TestCase {
+
+ /**
+ *
+ */
+ public EventSetDescriptorTest() {
+ super();
+ }
+
+ /**
+ * @param name
+ */
+ public EventSetDescriptorTest(String name) {
+ super(name);
+ }
+
+ /**
+ * The test checks the constructor
+ */
+ public void testEventSetDescriptorConstructor() {
+ try {
+ new EventSetDescriptor(OtherBean.class, "sample",
+ SampleListener.class, "fireSampleEvent");
+ } catch (Exception e) {
+ fail("Exception of " + e.getClass() +
+ " class with message " + e.getMessage() + " is thrown");
+ }
+
+ }
+
+ /**
+ *
+ */
+ public static Test suite() {
+ return new TestSuite(EventSetDescriptorTest.class);
+ }
+
+ /**
+ *
+ */
+ public static void main(String[] args) {
+ TestRunner.run(suite());
+ }
+}