jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1130162 - in /jackrabbit/sandbox/jackrabbit-j3/src: main/java/org/apache/jackrabbit/j3/mc/ test/java/org/apache/jackrabbit/j3/
Date Wed, 01 Jun 2011 14:33:34 GMT
Author: thomasm
Date: Wed Jun  1 14:33:33 2011
New Revision: 1130162

URL: http://svn.apache.org/viewvc?rev=1130162&view=rev
Log:
Don't use javax.jcr.PropertyType in the mc package. Also slightly improves performance.

Added:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/PropertyType.java
Modified:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBundle.java

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java?rev=1130162&r1=1130161&r2=1130162&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java
(original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Bundle.java
Wed Jun  1 14:33:33 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.j3.mc;
 
-import javax.jcr.PropertyType;
 import org.apache.jackrabbit.j3.util.Constants;
 import org.apache.jackrabbit.j3.util.ExceptionFactory;
 

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/PropertyType.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/PropertyType.java?rev=1130162&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/PropertyType.java
(added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/PropertyType.java
Wed Jun  1 14:33:33 2011
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3.mc;
+
+/**
+ * The property types.
+ */
+public class PropertyType {
+
+    public static final int UNDEFINED = 0, STRING = 1, BINARY = 2, LONG = 3, DOUBLE = 4,
DATE = 5, BOOLEAN = 6,
+            NAME = 7, PATH = 8, REFERENCE = 9, WEAKREFERENCE = 10, URI = 11, DECIMAL = 12;
+
+    private static final String[] NAMES = { "undefined", "String", "Binary", "Long", "Double",
"Date", "Boolean",
+            "Name", "Path", "Reference", "WeakReference", "URI", "Decimal" };
+
+    public static String nameFromValue(int type) {
+        return NAMES[type];
+    }
+
+    public static int valueFromName(String name) {
+        switch (name.length()) {
+        case 3:
+            if ("URI".equals(name)) {
+                return URI;
+            }
+            break;
+        case 4:
+            if ("Long".equals(name)) {
+                return LONG;
+            } else if ("Date".equals(name)) {
+                return DATE;
+            } else if ("Name".equals(name)) {
+                return NAME;
+            } else if ("Path".equals(name)) {
+                return PATH;
+            }
+            break;
+        case 6:
+            if ("String".equals(name)) {
+                return STRING;
+            } else if ("Double".equals(name)) {
+                    return DOUBLE;
+            } else if ("Binary".equals(name)) {
+                return BINARY;
+            }
+            break;
+        case 7:
+            if ("Boolean".equals(name)) {
+                return BOOLEAN;
+            } else if ("Decimal".equals(name)) {
+                return DECIMAL;
+            }
+            break;
+        case 9:
+            if ("Reference".equals(name)) {
+                return REFERENCE;
+            } else if ("undefined".equals(name)) {
+                return UNDEFINED;
+            }
+            break;
+        case 13:
+            if ("WeakReference".equals(name)) {
+                return WEAKREFERENCE;
+            }
+            break;
+        }
+        throw new IllegalArgumentException("unknown type: " + name);
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java?rev=1130162&r1=1130161&r2=1130162&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java Wed
Jun  1 14:33:33 2011
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.j3.mc;
 
 import java.util.Arrays;
 import java.util.HashMap;
-import javax.jcr.PropertyType;
 import org.apache.jackrabbit.j3.json.JsopTokenizer;
 import org.apache.jackrabbit.j3.util.Constants;
 import org.apache.jackrabbit.j3.util.ExceptionFactory;

Modified: jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java?rev=1130162&r1=1130161&r2=1130162&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java Wed
Jun  1 14:33:33 2011
@@ -37,6 +37,8 @@ public class TestAll extends TestCase {
 
         int todo;
 
+        // data store: encode the length in the identifier (to avoid file reads when requesting
the length)
+
         // many child nodes
         // possibly using a Htree - see also http://en.wikipedia.org/wiki/Htree
 

Modified: jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBundle.java?rev=1130162&r1=1130161&r2=1130162&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBundle.java
(original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBundle.java
Wed Jun  1 14:33:33 2011
@@ -16,9 +16,9 @@
  */
 package org.apache.jackrabbit.j3;
 
-import javax.jcr.PropertyType;
 import junit.framework.TestCase;
 import org.apache.jackrabbit.j3.mc.Bundle;
+import org.apache.jackrabbit.j3.mc.PropertyType;
 import org.apache.jackrabbit.j3.mc.Val;
 
 /**
@@ -26,6 +26,13 @@ import org.apache.jackrabbit.j3.mc.Val;
  */
 public class TestBundle extends TestCase {
 
+    public void testPropertyType() {
+        for (int i = PropertyType.UNDEFINED; i <= PropertyType.DECIMAL; i++) {
+            String s = PropertyType.nameFromValue(i);
+            assertEquals(i, PropertyType.valueFromName(s));
+        }
+    }
+
     public void testNodeId() {
         try {
             Val.getNodeId(268435456, 0);
@@ -114,7 +121,7 @@ public class TestBundle extends TestCase
         testLength(Val.get(PropertyType.REFERENCE, "abc:def"));
         testLength(Val.get(PropertyType.WEAKREFERENCE, "abc:def"));
         testLength(Val.get(Val.TYPE_BINARY_REFERENCE, "0x1234"));
-        testLength(Val.get("long string with strange characters äöü \u1234"));
+        testLength(Val.get("long string with strange characters ��� \u1234"));
         testLength(Val.get(new byte[1024]));
         testLength(Val.get(new byte[1024 * 1024]));
         testLength(true, Val.get(Val.get("Hello World 1"), Val.get("Hello World 2"), Val.get("Hello
World 3")));



Mime
View raw message