You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/06/28 21:46:19 UTC
svn commit: r417860 [2/12] - in /incubator/openjpa/trunk: ./ openjpa-lib/
openjpa-lib/main/ openjpa-lib/src/ openjpa-lib/src/main/
openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/
openjpa-lib/src/test/ openjpa-lib/src/test/java/ openjpa-lib/src/t...
Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/testlocalizer/LocalizerTestHelper.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/testlocalizer/LocalizerTestHelper.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/testlocalizer/LocalizerTestHelper.java (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/testlocalizer/LocalizerTestHelper.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openjpa.lib.util.testlocalizer;
+
+
+/**
+ * <p>Helper class used so that the localizer.properties file in this package
+ * can be accessed. The properties cannot be in the same package (serp.util)
+ * as the main tester class because other utilities in the source line might
+ * eventually want to use a localizer.properties file for that package.</p>
+ *
+ * @author Abe White
+ */
+public class LocalizerTestHelper {
+}
Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/testlocalizer/LocalizerTestHelper.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/openjpa-lib/src/test/resources/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/resources/localizer.properties?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/resources/localizer.properties (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/resources/localizer.properties Wed Jun 28 12:46:13 2006
@@ -0,0 +1 @@
+test.systemlocal systemvalue1
Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/resources/localizer.properties
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/conf/test/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/conf/test/localizer.properties?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/conf/test/localizer.properties (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/conf/test/localizer.properties Wed Jun 28 12:46:13 2006
@@ -0,0 +1,12 @@
+testKey-name: name
+testKey-desc: desc
+testKey-type: General
+sysKey-name: name
+sysKey-desc: desc
+sysKey-type: General
+pluginKey-name: name
+pluginKey-desc: desc
+pluginKey-type: General
+objectKey-name: name
+objectKey-desc: desc
+objectKey-type: General
Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/conf/test/localizer.properties
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer.properties?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer.properties (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer.properties Wed Jun 28 12:46:13 2006
@@ -0,0 +1,2 @@
+test.local1 value1
+test.local2 value2 {0} sep {1}
Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer.properties
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer_de_DE.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer_de_DE.properties?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer_de_DE.properties (added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer_de_DE.properties Wed Jun 28 12:46:13 2006
@@ -0,0 +1,2 @@
+test.local1 value1_de
+test.local2 value2_de {0} sep {1}
Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/resources/org/apache/openjpa/lib/util/testlocalizer/localizer_de_DE.properties
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/pom.xml?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/pom.xml (added)
+++ incubator/openjpa/trunk/pom.xml Wed Jun 28 12:46:13 2006
@@ -0,0 +1,179 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <packaging>pom</packaging>
+
+ <name>OpenJPA</name>
+ <description>OpenJPA</description>
+ <version>0.0.1</version>
+ <url>http://incubator.apache.org/projects/openjpa</url>
+ <issueManagement>
+ <system>jira</system>
+ <url>http://issues.apache.org/jira/browse/OPENJPA</url>
+ </issueManagement>
+ <inceptionYear>2006</inceptionYear>
+ <mailingLists>
+ <mailingList>
+ <name>OpenJPA Developer List</name>
+ <subscribe>open-jpa-dev-subscribe@incubator.apache.org</subscribe>
+ <unsubscribe>open-jpa-dev-unsubscribe@incubator.apache.org</unsubscribe>
+ <post>open-jpa-dev@incubator.apache.org</post>
+ <archive>http://mail-archives.apache.org/mod_mbox/incubator-open-jpa-dev/</archive>
+ </mailingList>
+ <mailingList>
+ <name>OpenJPA Commits List</name>
+ <subscribe>open-jpa-commits-subscribe@incubator.apache.org</subscribe>
+ <unsubscribe>open-jpa-commits-unsubscribe@incubator.apache.org</unsubscribe>
+ <post>open-jpa-commits@incubator.apache.org</post>
+ <archive>http://mail-archives.apache.org/mod_mbox/incubator-open-jpa-commits/</archive>
+ </mailingList>
+ </mailingLists>
+ <developers>
+ <developer>
+ <name>Patrick Linskey</name>
+ <id>plinskey</id>
+ <organization>BEA Systems, Inc.</organization>
+ <email>plinskey@bea.com</email>
+ </developer>
+ <developer>
+ <name>Abe White</name>
+ <id>awhite</id>
+ <organization>BEA Systems, Inc.</organization>
+ <email>awhite@bea.com</email>
+ </developer>
+ <developer>
+ <name>Steve Kim</name>
+ <id>stkim</id>
+ <organization>BEA Systems, Inc.</organization>
+ <email>stkim@bea.com</email>
+ </developer>
+ <developer>
+ <name>Marc Prud'hommeaux</name>
+ <id>mprudhom</id>
+ <organization>BEA Systems, Inc.</organization>
+ <email>mprudhom@bea.com</email>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>Apache Software License 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <organization>
+ <name>Apache Software Foundation</name>
+ <url>http://www.apache.org</url>
+ </organization>
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/openjpa/${pom.artifactId}</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/openjpa/${pom.artifactId}</developerConnection>
+ <url>https://svn.apache.org/repos/asf/incubator/openjpa/${pom.artifactId}</url>
+ </scm>
+<modules>
+
+ <module>openjpa-lib</module>
+ <module>serp</module>
+
+ </modules>
+ <repositories>
+
+ <repository>
+ <id>central</id>
+ <name>Maven Repository Switchboard</name>
+ <url>http://www.ibiblio.org/maven2</url>
+ </repository>
+
+
+ <repository>
+ <id>swami</id>
+ <name>Swami repository</name>
+ <url>http://m2.ngbw.org</url>
+ </repository>
+
+
+ <repository>
+ <id>java-net</id>
+ <name>dev.java.net repository</name>
+ <url>https://maven-repository.dev.java.net/nonav/repository</url>
+ <layout>legacy</layout>
+ </repository>
+
+ </repositories>
+ <dependencies>
+
+ <dependency>
+
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>compile</scope>
+
+ </dependency>
+
+ </dependencies>
+ <build>
+
+ <plugins>
+
+ <plugin>
+
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jxr-maven-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ <linksource>true</linksource>
+ <links>
+ <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
+ <link>http://java.sun.com/javaee/5/docs/api</link>
+ <link>http://jakarta.apache.org/commons/collections/api-release</link>
+ </links>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ <distributionManagement>
+ <repository>
+ <id>bea-internal</id>
+ <name>Internal BEA OpenJPA test site</name>
+ <url>file:///${user.home}/web/devel/openjpa/dist</url>
+ </repository>
+ <site>
+ <id>bea-internal</id>
+ <name>Internal BEA OpenJPA test sit</name>
+ <url>file:///${user.home}/web/devel/openjpa/site</url>
+ </site>
+ </distributionManagement>
+
+</project>
Propchange: incubator/openjpa/trunk/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/serp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/pom.xml?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/serp/pom.xml (added)
+++ incubator/openjpa/trunk/serp/pom.xml Wed Jun 28 12:46:13 2006
@@ -0,0 +1,41 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>serp</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Serp</name>
+ <description>Serp</description>
+ <url>http://incubator.apache.org/projects/openjpa</url>
+<parent>
+
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>0.0.1</version>
+
+ </parent>
+ <dependencies>
+
+
+ </dependencies>
+ <build>
+
+ <plugins>
+
+ <plugin>
+
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.3</source>
+ <target>1.3</target>
+ </configuration>
+
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+
+</project>
Propchange: incubator/openjpa/trunk/serp/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayInstruction.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayInstruction.java (added)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayInstruction.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package serp.bytecode;
+
+import java.util.*;
+
+
+/**
+ * <p>Any array load or store instruction. This class has
+ * no functionality beyond the {@link TypedInstruction} but is provided
+ * so that users can easily identify array instructions in code if
+ * need be.</p>
+ *
+ * @author Abe White
+ */
+public abstract class ArrayInstruction extends TypedInstruction {
+ ArrayInstruction(Code owner) {
+ super(owner);
+ }
+
+ ArrayInstruction(Code owner, int opcode) {
+ super(owner, opcode);
+ }
+}
Propchange: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayInstruction.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayLoadInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayLoadInstruction.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayLoadInstruction.java (added)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayLoadInstruction.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package serp.bytecode;
+
+import serp.bytecode.visitor.*;
+
+
+/**
+ * <p>Loads a value from an array onto the stack.</p>
+ *
+ * @author Abe White
+ */
+public class ArrayLoadInstruction extends ArrayInstruction {
+ private static final Class[][] _mappings = new Class[][] {
+ { boolean.class, int.class },
+ { void.class, int.class },
+ };
+
+ ArrayLoadInstruction(Code owner) {
+ super(owner);
+ }
+
+ ArrayLoadInstruction(Code owner, int opcode) {
+ super(owner, opcode);
+ }
+
+ public int getLogicalStackChange() {
+ switch (getOpcode()) {
+ case Constants.NOP:
+ return 0;
+
+ default:
+ return -1;
+ }
+ }
+
+ public int getStackChange() {
+ switch (getOpcode()) {
+ case Constants.DALOAD:
+ case Constants.LALOAD:
+ case Constants.NOP:
+ return 0;
+
+ default:
+ return -1;
+ }
+ }
+
+ public String getTypeName() {
+ switch (getOpcode()) {
+ case Constants.IALOAD:
+ return int.class.getName();
+
+ case Constants.LALOAD:
+ return long.class.getName();
+
+ case Constants.FALOAD:
+ return float.class.getName();
+
+ case Constants.DALOAD:
+ return double.class.getName();
+
+ case Constants.AALOAD:
+ return Object.class.getName();
+
+ case Constants.BALOAD:
+ return byte.class.getName();
+
+ case Constants.CALOAD:
+ return char.class.getName();
+
+ case Constants.SALOAD:
+ return short.class.getName();
+
+ default:
+ return null;
+ }
+ }
+
+ public TypedInstruction setType(String type) {
+ type = mapType(type, _mappings, true);
+
+ if (type == null) {
+ return (TypedInstruction) setOpcode(Constants.NOP);
+ }
+
+ switch (type.charAt(0)) {
+ case 'i':
+ return (TypedInstruction) setOpcode(Constants.IALOAD);
+
+ case 'l':
+ return (TypedInstruction) setOpcode(Constants.LALOAD);
+
+ case 'f':
+ return (TypedInstruction) setOpcode(Constants.FALOAD);
+
+ case 'd':
+ return (TypedInstruction) setOpcode(Constants.DALOAD);
+
+ case 'b':
+ return (TypedInstruction) setOpcode(Constants.BALOAD);
+
+ case 'c':
+ return (TypedInstruction) setOpcode(Constants.CALOAD);
+
+ case 's':
+ return (TypedInstruction) setOpcode(Constants.SALOAD);
+
+ default:
+ return (TypedInstruction) setOpcode(Constants.AALOAD);
+ }
+ }
+
+ public void acceptVisit(BCVisitor visit) {
+ visit.enterArrayLoadInstruction(this);
+ visit.exitArrayLoadInstruction(this);
+ }
+}
Propchange: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayLoadInstruction.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayState.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayState.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayState.java (added)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayState.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package serp.bytecode;
+
+import java.util.*;
+
+
+/**
+ * <p>State implementing the behavior of an array class.</p>
+ *
+ * @author Abe White
+ */
+class ArrayState extends State {
+ private String _name = null;
+ private String _componentName = null;
+
+ public ArrayState(String name, String componentName) {
+ _name = name;
+ _componentName = componentName;
+ }
+
+ public int getMagic() {
+ return Constants.VALID_MAGIC;
+ }
+
+ public int getMajorVersion() {
+ return Constants.MAJOR_VERSION;
+ }
+
+ public int getMinorVersion() {
+ return Constants.MINOR_VERSION;
+ }
+
+ public int getAccessFlags() {
+ return Constants.ACCESS_PUBLIC | Constants.ACCESS_FINAL;
+ }
+
+ public int getIndex() {
+ return 0;
+ }
+
+ public int getSuperclassIndex() {
+ return 0;
+ }
+
+ public Collection getInterfacesHolder() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public Collection getFieldsHolder() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public Collection getMethodsHolder() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public Collection getAttributesHolder() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getSuperclassName() {
+ return Object.class.getName();
+ }
+
+ public String getComponentName() {
+ return _componentName;
+ }
+
+ public boolean isPrimitive() {
+ return false;
+ }
+
+ public boolean isArray() {
+ return true;
+ }
+}
Propchange: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayState.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayStoreInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayStoreInstruction.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayStoreInstruction.java (added)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayStoreInstruction.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package serp.bytecode;
+
+import serp.bytecode.visitor.*;
+
+
+/**
+ * <p>Store a value from the stack into an array.</p>
+ *
+ * @author Abe White
+ */
+public class ArrayStoreInstruction extends ArrayInstruction {
+ private static final Class[][] _mappings = new Class[][] {
+ { boolean.class, int.class },
+ { void.class, int.class },
+ };
+
+ ArrayStoreInstruction(Code owner) {
+ super(owner);
+ }
+
+ ArrayStoreInstruction(Code owner, int opcode) {
+ super(owner, opcode);
+ }
+
+ public int getLogicalStackChange() {
+ switch (getOpcode()) {
+ case Constants.NOP:
+ return 0;
+
+ default:
+ return -3;
+ }
+ }
+
+ public int getStackChange() {
+ switch (getOpcode()) {
+ case Constants.DASTORE:
+ case Constants.LASTORE:
+ return -4;
+
+ case Constants.NOP:
+ return 0;
+
+ default:
+ return -3;
+ }
+ }
+
+ public String getTypeName() {
+ switch (getOpcode()) {
+ case Constants.IASTORE:
+ return int.class.getName();
+
+ case Constants.LASTORE:
+ return long.class.getName();
+
+ case Constants.FASTORE:
+ return float.class.getName();
+
+ case Constants.DASTORE:
+ return double.class.getName();
+
+ case Constants.AASTORE:
+ return Object.class.getName();
+
+ case Constants.BASTORE:
+ return byte.class.getName();
+
+ case Constants.CASTORE:
+ return char.class.getName();
+
+ case Constants.SASTORE:
+ return short.class.getName();
+
+ default:
+ return null;
+ }
+ }
+
+ public TypedInstruction setType(String type) {
+ type = mapType(type, _mappings, true);
+
+ if (type == null) {
+ return (TypedInstruction) setOpcode(Constants.NOP);
+ }
+
+ switch (type.charAt(0)) {
+ case 'i':
+ return (TypedInstruction) setOpcode(Constants.IASTORE);
+
+ case 'l':
+ return (TypedInstruction) setOpcode(Constants.LASTORE);
+
+ case 'f':
+ return (TypedInstruction) setOpcode(Constants.FASTORE);
+
+ case 'd':
+ return (TypedInstruction) setOpcode(Constants.DASTORE);
+
+ case 'b':
+ return (TypedInstruction) setOpcode(Constants.BASTORE);
+
+ case 'c':
+ return (TypedInstruction) setOpcode(Constants.CASTORE);
+
+ case 's':
+ return (TypedInstruction) setOpcode(Constants.SASTORE);
+
+ default:
+ return (TypedInstruction) setOpcode(Constants.AASTORE);
+ }
+ }
+
+ public void acceptVisit(BCVisitor visit) {
+ visit.enterArrayStoreInstruction(this);
+ visit.exitArrayStoreInstruction(this);
+ }
+}
Propchange: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ArrayStoreInstruction.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attribute.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attribute.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attribute.java (added)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attribute.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package serp.bytecode;
+
+import serp.bytecode.lowlevel.*;
+
+import serp.bytecode.visitor.*;
+
+import serp.util.*;
+
+import java.io.*;
+
+import java.lang.reflect.*;
+
+import java.util.*;
+
+
+/**
+ * <p>In bytecode attributes are used to represent anything that is not
+ * part of the class structure. This includes the source file name, code of
+ * methods, the line number table, etc. All attributes contain at a minimum
+ * an immutable name that also determines the attribute's type.</p>
+ *
+ * @author Abe White
+ */
+public abstract class Attribute extends Attributes implements VisitAcceptor {
+ private int _nameIndex = 0;
+ private Attributes _owner = null;
+
+ Attribute(int nameIndex, Attributes owner) {
+ _owner = owner;
+ _nameIndex = nameIndex;
+ }
+
+ /**
+ * Create an attribute of the appropriate type based on the
+ * the attribute name.
+ */
+ static Attribute create(String name, Attributes owner) {
+ int nameIndex = owner.getPool().findUTF8Entry(name, true);
+
+ try {
+ Class type = Class.forName("serp.bytecode." + name);
+ Constructor cons = type.getDeclaredConstructor(new Class[] {
+ int.class, Attributes.class
+ });
+
+ return (Attribute) cons.newInstance(new Object[] {
+ Numbers.valueOf(nameIndex), owner
+ });
+ } catch (Throwable t) {
+ return new UnknownAttribute(nameIndex, owner);
+ }
+ }
+
+ /**
+ * Return the {@link Attributes} that owns this attribute. The entity
+ * might be a {@link BCClass}, {@link BCField}, {@link BCMethod}, or other
+ * attribute.
+ */
+ public Attributes getOwner() {
+ return _owner;
+ }
+
+ /**
+ * Return the index in the {@link ConstantPool} of the {@link UTF8Entry}
+ * holding the name of this attribute.
+ */
+ public int getNameIndex() {
+ return _nameIndex;
+ }
+
+ /**
+ * Return the name of this attribute.
+ */
+ public String getName() {
+ return ((UTF8Entry) getPool().getEntry(_nameIndex)).getValue();
+ }
+
+ public Project getProject() {
+ return _owner.getProject();
+ }
+
+ public ConstantPool getPool() {
+ return _owner.getPool();
+ }
+
+ public ClassLoader getClassLoader() {
+ return _owner.getClassLoader();
+ }
+
+ public boolean isValid() {
+ return _owner != null;
+ }
+
+ Collection getAttributesHolder() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * Invalidate this attribute.
+ */
+ void invalidate() {
+ _owner = null;
+ }
+
+ /**
+ * Return the length of the bytecode representation of this attribute
+ * in bytes, excluding the name index.
+ */
+ int getLength() {
+ return 0;
+ }
+
+ /**
+ * Copy the information from the given attribute to this one. Does
+ * nothing by default.
+ */
+ void read(Attribute other) {
+ }
+
+ /**
+ * Read the attribute bytecode from the given stream, up to length
+ * bytes, excluding the name index. Does nothing by default.
+ */
+ void read(DataInput in, int length) throws IOException {
+ }
+
+ /**
+ * Write the attribute bytecode to the given stream, up to length bytes,
+ * excluding the name index. Does nothing by default.
+ */
+ void write(DataOutput out, int length) throws IOException {
+ }
+}
Propchange: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attribute.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attributes.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attributes.java?rev=417860&view=auto
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attributes.java (added)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attributes.java Wed Jun 28 12:46:13 2006
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package serp.bytecode;
+
+import serp.bytecode.lowlevel.*;
+
+import serp.bytecode.visitor.*;
+
+import java.io.*;
+
+import java.util.*;
+
+
+/**
+ * <p>Abstract superclass for all bytecode entities that hold attributes.</p>
+ *
+ * @author Abe White
+ */
+public abstract class Attributes implements BCEntity {
+ /**
+ * Return all the attributes owned by this entity.
+ *
+ * @return all owned attributes, or empty array if none
+ */
+ public Attribute[] getAttributes() {
+ Collection attrs = getAttributesHolder();
+
+ return (Attribute[]) attrs.toArray(new Attribute[attrs.size()]);
+ }
+
+ /**
+ * Return the attribute with the given name. If multiple attributes
+ * share the name, which is returned is undefined.
+ */
+ public Attribute getAttribute(String name) {
+ Collection attrs = getAttributesHolder();
+ Attribute attr;
+
+ for (Iterator itr = attrs.iterator(); itr.hasNext();) {
+ attr = (Attribute) itr.next();
+
+ if (attr.getName().equals(name)) {
+ return attr;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Return all attributes with the given name.
+ *
+ * @return the matching attributes, or empty array if none
+ */
+ public Attribute[] getAttributes(String name) {
+ List matches = new LinkedList();
+
+ Collection attrs = getAttributesHolder();
+ Attribute attr;
+
+ for (Iterator itr = attrs.iterator(); itr.hasNext();) {
+ attr = (Attribute) itr.next();
+
+ if (attr.getName().equals(name)) {
+ matches.add(attr);
+ }
+ }
+
+ return (Attribute[]) matches.toArray(new Attribute[matches.size()]);
+ }
+
+ /**
+ * Set the attributes for this entity; this method is useful for importing
+ * all attributes from another entity. Set to null or empty array if none.
+ */
+ public void setAttributes(Attribute[] attrs) {
+ clearAttributes();
+
+ if (attrs != null) {
+ for (int i = 0; i < attrs.length; i++)
+ addAttribute(attrs[i]);
+ }
+ }
+
+ /**
+ * Import an attribute from another entity, or make a copy of one
+ * on this entity.
+ */
+ public Attribute addAttribute(Attribute attr) {
+ Attribute newAttr = addAttribute(attr.getName());
+ newAttr.read(attr);
+
+ return newAttr;
+ }
+
+ /**
+ * Add an attribute of the given type.
+ */
+ public Attribute addAttribute(String name) {
+ Attribute attr = Attribute.create(name, this);
+ getAttributesHolder().add(attr);
+
+ return attr;
+ }
+
+ /**
+ * Clear all attributes from this entity.
+ */
+ public void clearAttributes() {
+ Collection attrs = getAttributesHolder();
+ Attribute attr;
+
+ for (Iterator itr = attrs.iterator(); itr.hasNext();) {
+ attr = (Attribute) itr.next();
+ itr.remove();
+ attr.invalidate();
+ }
+ }
+
+ /**
+ * Remove all attributes with the given name from this entity.
+ *
+ * @return true if an attribute was removed, false otherwise
+ */
+ public boolean removeAttribute(String name) {
+ return removeAttribute(getAttribute(name));
+ }
+
+ /**
+ * Remove the given attribute. After being removed, the attribute
+ * is invalid, and the result of any operations on it are undefined.
+ *
+ * @return true if the attribute was removed, false otherwise
+ */
+ public boolean removeAttribute(Attribute attribute) {
+ if ((attribute == null) || !getAttributesHolder().remove(attribute)) {
+ return false;
+ }
+
+ attribute.invalidate();
+
+ return true;
+ }
+
+ /**
+ * Convenience method to be called by BCEntities when being visited
+ * by a {@link BCVisitor}; this method will allow the visitor to visit all
+ * attributes of this entity.
+ */
+ void visitAttributes(BCVisitor visit) {
+ Attribute attr;
+
+ for (Iterator itr = getAttributesHolder().iterator(); itr.hasNext();) {
+ attr = (Attribute) itr.next();
+ visit.enterAttribute(attr);
+ attr.acceptVisit(visit);
+ visit.exitAttribute(attr);
+ }
+ }
+
+ /**
+ * Build the attribute list from the given stream.
+ * Relies on the ability of attributes to read themselves, and
+ * requires access to the constant pool, which must already by read.
+ */
+ void readAttributes(DataInput in) throws IOException {
+ Collection attrs = getAttributesHolder();
+ attrs.clear();
+
+ Attribute attribute;
+ String name;
+
+ for (int i = in.readUnsignedShort(); i > 0; i--) {
+ name = ((UTF8Entry) getPool().getEntry(in.readUnsignedShort())).getValue();
+ attribute = addAttribute(name);
+ attribute.read(in, in.readInt());
+ }
+ }
+
+ /**
+ * Writes all the owned attributes to the given stream.
+ * Relies on the ability of attributes to write themselves.
+ */
+ void writeAttributes(DataOutput out) throws IOException {
+ Collection attrs = getAttributesHolder();
+ out.writeShort(attrs.size());
+
+ Attribute attribute;
+ int length;
+
+ for (Iterator itr = attrs.iterator(); itr.hasNext();) {
+ attribute = (Attribute) itr.next();
+ out.writeShort(attribute.getNameIndex());
+ length = attribute.getLength();
+ out.writeInt(length);
+ attribute.write(out, length);
+ }
+ }
+
+ /**
+ * Return the collection used to hold the attributes of this entity.
+ */
+ abstract Collection getAttributesHolder();
+}
Propchange: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Attributes.java
------------------------------------------------------------------------------
svn:executable = *