pax_global_header 0000666 0000000 0000000 00000000064 12556201627 0014520 g ustar 00root root 0000000 0000000 52 comment=9bcdf62f6a801bad18afd621cb580076e141d987
json-smart-v2-2.2/ 0000775 0000000 0000000 00000000000 12556201627 0014005 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/.gitignore 0000664 0000000 0000000 00000000626 12556201627 0016001 0 ustar 00root root 0000000 0000000
/json-smart/target
/json-smart/.settings
/json-smart/.classpath
/json-smart/.project
/parent/.project
/parent/.settings
/json-smart/src/test/java/asm
/asm/.classpath
/asm/.project
/asm/.settings
/asm/targetjson-smart-backport/.classpath
json-smart-backport/.project
json-smart-backport/.settings
asm/target/
json-smart-backport/target/
json-smart/target/
**/.project
**/bin
*.classpath
*.project
*.prefs
json-smart-v2-2.2/README.md 0000664 0000000 0000000 00000002640 12556201627 0015266 0 ustar 00root root 0000000 0000000 # json-smart-v2
== Changelog: ==
*V 2.2*
* rename asm to accessors-smart due to conflict name with asm.ow2.org lib.
* fix OSGI error
* add support for BigDecimal
* improve JSONObject.getAsNumber() helper
* add a Field Remaper
*V 2.1*
* net.minidev.json.mapper renamed to net.minidev.json.writer
* Add ACCEPT_TAILLING_SPACE Parssing Flag.
* Mapper classes now non static.
* Reader mapper are now available in net.minidev.json.reader.JsonReader class
* Writer mapper are now available in net.minidev.json.writer.JsonWriter class
*V 2.0*
* Fix Double Identification [http://code.google.com/p/json-smart/issues/detail?id=44 issue 44]
* Fix Collection Interface Serialisation
* Fix security Exception in ASM code
* Project moved to GitHub
* Fix [http://code.google.com/p/json-smart/issues/detail?id=42 issue 42]
*V 2.0-RC3*
* Add custom data binding inside the ASM layer.
* Add Date support
* Add \x escape sequence support [http://code.google.com/p/json-smart/issues/detail?id=39 issue 39]
* fix issue [http://code.google.com/p/json-smart/issues/detail?id=37 issue 37]
*V 2.0-RC2*
* Fix critical [http://code.google.com/p/json-smart/issues/detail?id=23 issue 23]
* Improve Javadoc in JSONStyle [http://code.google.com/p/json-smart/issues/detail?id=23 issue 24]
*V 2.0-RC1*
* speed improvement in POJO manipulation
* add JSONStyle.LT_COMPRESS predefined generate strct json, but ignoring / escapement.
json-smart-v2-2.2/accessors-smart/ 0000775 0000000 0000000 00000000000 12556201627 0017116 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/.gitignore 0000664 0000000 0000000 00000000011 12556201627 0021076 0 ustar 00root root 0000000 0000000 /target/
json-smart-v2-2.2/accessors-smart/pom.xml 0000664 0000000 0000000 00000004051 12556201627 0020433 0 ustar 00root root 0000000 0000000 4.0.0accessors-smartbundle1.1net.minidevminidev-parent2.2../parent/pom.xmlASM based accessors helper used by json-smartJava reflect give poor performance on getter setter an constructor calls,
accessors-smart use ASM to speed up those calls.
junitjunittestorg.ow2.asmasm5.0.3org.apache.felixmaven-bundle-plugin2.3.7true${project.groupId}.${project.artifactId}${project.artifactId}${project.version}
net.minidev.asm,
net.minidev.asm.ex
asm;groupId=org.ow2.asm;inline=true
json-smart-v2-2.2/accessors-smart/src/ 0000775 0000000 0000000 00000000000 12556201627 0017705 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/main/ 0000775 0000000 0000000 00000000000 12556201627 0020631 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/main/java/ 0000775 0000000 0000000 00000000000 12556201627 0021552 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/main/java/net/ 0000775 0000000 0000000 00000000000 12556201627 0022340 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/ 0000775 0000000 0000000 00000000000 12556201627 0023773 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/ 0000775 0000000 0000000 00000000000 12556201627 0024553 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/ASMUtil.java 0000664 0000000 0000000 00000017207 12556201627 0026703 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
/*
* Copyright 2011 JSON-SMART authors
*
* 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.
*/
import static org.objectweb.asm.Opcodes.CHECKCAST;
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
import java.lang.reflect.Field;
import java.util.HashMap;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Type;
/**
* ASM Utils used to simplify class generation
*
* @author uriel Chemouni
*/
public class ASMUtil {
/**
* Append the call of proper autoboxing method for the given primitif type.
*/
public static void autoBoxing(MethodVisitor mv, Class> clz) {
autoBoxing(mv, Type.getType(clz));
}
/**
* Extract all Accessor for the field of the given class.
*
* @param type
* @return all Accessor available
*/
static public Accessor[] getAccessors(Class> type, FieldFilter filter) {
Class> nextClass = type;
HashMap map = new HashMap();
if (filter == null)
filter = BasicFiledFilter.SINGLETON;
while (nextClass != Object.class) {
Field[] declaredFields = nextClass.getDeclaredFields();
for (Field field : declaredFields) {
String fn = field.getName();
if (map.containsKey(fn))
continue;
Accessor acc = new Accessor(nextClass, field, filter);
if (!acc.isUsable())
continue;
map.put(fn, acc);
}
nextClass = nextClass.getSuperclass();
}
return map.values().toArray(new Accessor[map.size()]);
}
/**
* Append the call of proper autoboxing method for the given primitif type.
*/
protected static void autoBoxing(MethodVisitor mv, Type fieldType) {
switch (fieldType.getSort()) {
case Type.BOOLEAN:
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;");
break;
case Type.BYTE:
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;");
break;
case Type.CHAR:
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;");
break;
case Type.SHORT:
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;");
break;
case Type.INT:
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;");
break;
case Type.FLOAT:
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;");
break;
case Type.LONG:
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;");
break;
case Type.DOUBLE:
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;");
break;
}
}
/**
* Append the call of proper extract primitive type of an boxed object.
*/
protected static void autoUnBoxing1(MethodVisitor mv, Type fieldType) {
switch (fieldType.getSort()) {
case Type.BOOLEAN:
mv.visitTypeInsn(CHECKCAST, "java/lang/Boolean");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z");
break;
case Type.BYTE:
mv.visitTypeInsn(CHECKCAST, "java/lang/Byte");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B");
break;
case Type.CHAR:
mv.visitTypeInsn(CHECKCAST, "java/lang/Character");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C");
break;
case Type.SHORT:
mv.visitTypeInsn(CHECKCAST, "java/lang/Short");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S");
break;
case Type.INT:
mv.visitTypeInsn(CHECKCAST, "java/lang/Integer");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I");
break;
case Type.FLOAT:
mv.visitTypeInsn(CHECKCAST, "java/lang/Float");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Float", "floatValue", "()F");
break;
case Type.LONG:
mv.visitTypeInsn(CHECKCAST, "java/lang/Long");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J");
break;
case Type.DOUBLE:
mv.visitTypeInsn(CHECKCAST, "java/lang/Double");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D");
break;
case Type.ARRAY:
mv.visitTypeInsn(CHECKCAST, fieldType.getInternalName());
break;
default:
mv.visitTypeInsn(CHECKCAST, fieldType.getInternalName());
}
}
/**
* Append the call of proper extract primitive type of an boxed object. this
* methode use Number interface to unbox object
*/
protected static void autoUnBoxing2(MethodVisitor mv, Type fieldType) {
switch (fieldType.getSort()) {
case Type.BOOLEAN:
mv.visitTypeInsn(CHECKCAST, "java/lang/Boolean");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z");
break;
case Type.BYTE:
mv.visitTypeInsn(CHECKCAST, "java/lang/Number");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Number", "byteValue", "()B");
break;
case Type.CHAR:
mv.visitTypeInsn(CHECKCAST, "java/lang/Character");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C");
break;
case Type.SHORT:
mv.visitTypeInsn(CHECKCAST, "java/lang/Number");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Number", "shortValue", "()S");
break;
case Type.INT:
mv.visitTypeInsn(CHECKCAST, "java/lang/Number");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Number", "intValue", "()I");
break;
case Type.FLOAT:
mv.visitTypeInsn(CHECKCAST, "java/lang/Number");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Number", "floatValue", "()F");
break;
case Type.LONG:
mv.visitTypeInsn(CHECKCAST, "java/lang/Number");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Number", "longValue", "()J");
break;
case Type.DOUBLE:
mv.visitTypeInsn(CHECKCAST, "java/lang/Number");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Number", "doubleValue", "()D");
break;
case Type.ARRAY:
mv.visitTypeInsn(CHECKCAST, fieldType.getInternalName());
break;
default:
mv.visitTypeInsn(CHECKCAST, fieldType.getInternalName());
}
}
/**
* return a array of new Label (used for switch/case generation)
*
* @param cnt
* number of label to return
*/
public static Label[] newLabels(int cnt) {
Label[] r = new Label[cnt];
for (int i = 0; i < cnt; i++)
r[i] = new Label();
return r;
}
public static String getSetterName(String key) {
int len = key.length();
char[] b = new char[len + 3];
b[0] = 's';
b[1] = 'e';
b[2] = 't';
char c = key.charAt(0);
if (c >= 'a' && c <= 'z')
c += 'A' - 'a';
b[3] = c;
for (int i = 1; i < len; i++) {
b[i + 3] = key.charAt(i);
}
return new String(b);
}
public static String getGetterName(String key) {
int len = key.length();
char[] b = new char[len + 3];
b[0] = 'g';
b[1] = 'e';
b[2] = 't';
char c = key.charAt(0);
if (c >= 'a' && c <= 'z')
c += 'A' - 'a';
b[3] = c;
for (int i = 1; i < len; i++) {
b[i + 3] = key.charAt(i);
}
return new String(b);
}
public static String getIsName(String key) {
int len = key.length();
char[] b = new char[len + 2];
b[0] = 'i';
b[1] = 's';
char c = key.charAt(0);
if (c >= 'a' && c <= 'z')
c += 'A' - 'a';
b[2] = c;
for (int i = 1; i < len; i++) {
b[i + 2] = key.charAt(i);
}
return new String(b);
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/Accessor.java 0000664 0000000 0000000 00000007513 12556201627 0027166 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
/*
* Copyright 2011 JSON-SMART authors
*
* 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.
*/
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
/**
* Contains all information needed to access a java field.
*
* field, getter setter
*
* this object is used internally by BeansAcces
*
* @see BeansAccess
*
* @author Uriel Chemouni
*/
public class Accessor {
/**
* Field to access
*/
protected Field field;
/**
* Setter Methods if available
*/
protected Method setter;
/**
* getter Methods if available
*/
protected Method getter;
/**
* Filed index in object
*/
protected int index;
/**
* Filed Class
*/
protected Class> type;
/**
* Filed Type using JDK 5+ generics if available
*/
protected Type genericType;
protected String fieldName;
/**
* getter for index
* @return Index
*/
public int getIndex() {
return index;
}
/**
* is the field access using Field access type
* @return if Accessor is public
*/
public boolean isPublic() {
return setter == null;
}
/**
* is the field is an enum field
* @return if Accessor return an Enum Class
*/
public boolean isEnum() {
return type.isEnum();
}
/**
* return the field name
* @return the field name
*/
public String getName() {
return fieldName;
}
/**
* return field Class
* @return field Class
*/
public Class> getType() {
return type;
}
/**
* return generics field Type.
* @return generics field Type.
*/
public Type getGenericType() {
return genericType;
}
/**
* @return true if the field can be read or write
*/
public boolean isUsable() {
return field != null || getter != null || setter != null;
}
/**
* @return true if the field can be read
*/
public boolean isReadable() {
return field != null || getter != null;
}
/**
* @return true if the field can be write
*/
public boolean isWritable() {
return field != null || getter != null;
}
/**
* build accessor for a field
*
* @param c
* the handled class
* @param field
* the field to access
*/
public Accessor(Class> c, Field field, FieldFilter filter) {
this.fieldName = field.getName();
int m = field.getModifiers();
if ((m & (Modifier.STATIC | Modifier.TRANSIENT)) > 0)
return;
if ((m & Modifier.PUBLIC) > 0)
this.field = field;
String name = ASMUtil.getSetterName(field.getName());
try {
setter = c.getDeclaredMethod(name, field.getType());
} catch (Exception e) {
}
boolean isBool = field.getType().equals(Boolean.TYPE);
if (isBool) {
name = ASMUtil.getIsName(field.getName());
} else {
name = ASMUtil.getGetterName(field.getName());
}
try {
getter = c.getDeclaredMethod(name);
} catch (Exception e) {
}
if (getter == null && isBool) {
try {
getter = c.getDeclaredMethod(ASMUtil.getGetterName(field.getName()));
} catch (Exception e) {
}
}
if (this.field == null && getter == null && setter == null)
return;
if (getter != null && !filter.canUse(field, getter))
getter = null;
if (setter != null && !filter.canUse(field, setter))
setter = null;
// disable
if (getter == null && setter == null && this.field == null)
return;
this.type = field.getType();
this.genericType = field.getGenericType();
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/BasicFiledFilter.java 0000664 0000000 0000000 00000001002 12556201627 0030542 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class BasicFiledFilter implements FieldFilter {
public final static BasicFiledFilter SINGLETON = new BasicFiledFilter();
@Override
public boolean canUse(Field field) {
return true;
}
@Override
public boolean canUse(Field field, Method method) {
return true;
}
@Override
public boolean canRead(Field field) {
return true;
}
@Override
public boolean canWrite(Field field) {
return true;
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/BeansAccess.java 0000664 0000000 0000000 00000012333 12556201627 0027572 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
/*
* Copyright 2011 JSON-SMART authors
*
* 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.
*/
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
/**
* Allow access reflect field using runtime generated accessor. BeansAccessor is
* faster than java.lang.reflect.Method.invoke()
*
* @author uriel Chemouni
*/
public abstract class BeansAccess {
private HashMap map;
private Accessor[] accs;
protected void setAccessor(Accessor[] accs) {
int i = 0;
this.accs = accs;
map = new HashMap();
for (Accessor acc : accs) {
acc.index = i++;
map.put(acc.getName(), acc);
}
}
public HashMap getMap() {
return map;
}
public Accessor[] getAccessors() {
return accs;
}
/**
* cache used to store built BeansAccess
*/
private static ConcurrentHashMap, BeansAccess>> cache = new ConcurrentHashMap, BeansAccess>>();
// private final static ConcurrentHashMap> cache;
/**
* return the BeansAccess corresponding to a type
*
* @param type
* to be access
* @return the BeansAccess
*/
static public
BeansAccess
get(Class
type) {
return get(type, null);
}
/**
* return the BeansAccess corresponding to a type
*
* @param type
* to be access
* @return the BeansAccess
*/
static public
) cache.get(type);
if (access != null)
return access;
}
// extract all access methodes
Accessor[] accs = ASMUtil.getAccessors(type, filter);
// create new class name
String className = type.getName();
String accessClassName;
if (className.startsWith("java.util."))
accessClassName = "net.minidev.asm." + className + "AccAccess";
else
accessClassName = className.concat("AccAccess");
// extend class base loader
DynamicClassLoader loader = new DynamicClassLoader(type.getClassLoader());
// try to load existing class
Class> accessClass = null;
try {
accessClass = loader.loadClass(accessClassName);
} catch (ClassNotFoundException ignored) {
}
LinkedList> parentClasses = getParents(type);
// if the class do not exists build it
if (accessClass == null) {
BeansAccessBuilder builder = new BeansAccessBuilder(type, accs, loader);
for (Class> c : parentClasses)
builder.addConversion(BeansAccessConfig.classMapper.get(c));
accessClass = builder.bulid();
}
try {
@SuppressWarnings("unchecked")
BeansAccess
access = (BeansAccess
) accessClass.newInstance();
access.setAccessor(accs);
cache.putIfAbsent(type, access);
// add fieldname alias
for (Class> c : parentClasses)
addAlias(access, BeansAccessConfig.classFiledNameMapper.get(c));
return access;
} catch (Exception ex) {
throw new RuntimeException("Error constructing accessor class: " + accessClassName, ex);
}
}
private static LinkedList> getParents(Class> type) {
LinkedList> m = new LinkedList>();
while (type != null && !type.equals(Object.class)) {
m.addLast(type);
for (Class> c : type.getInterfaces())
m.addLast(c);
type = type.getSuperclass();
}
m.addLast(Object.class);
return m;
}
/**
*
*/
private static void addAlias(BeansAccess> access, HashMap m) {
// HashMap m =
// BeansAccessConfig.classFiledNameMapper.get(type);
if (m == null)
return;
HashMap changes = new HashMap();
for (Entry e : m.entrySet()) {
Accessor a1 = access.map.get(e.getValue());
if (a1 != null)
changes.put(e.getValue(), a1);
}
access.map.putAll(changes);
}
/**
* set field value by field index
*/
abstract public void set(T object, int methodIndex, Object value);
/**
* get field value by field index
*/
abstract public Object get(T object, int methodIndex);
/**
* create a new targeted object
*/
abstract public T newInstance();
/**
* set field value by fieldname
*/
public void set(T object, String methodName, Object value) {
int i = getIndex(methodName);
if (i == -1)
throw new net.minidev.asm.ex.NoSuchFieldException(methodName + " in " + object.getClass() + " to put value : " + value);
set(object, i, value);
}
/**
* get field value by fieldname
*/
public Object get(T object, String methodName) {
return get(object, getIndex(methodName));
}
/**
* Returns the index of the field accessor.
*/
public int getIndex(String name) {
Accessor ac = map.get(name);
if (ac == null)
return -1;
return ac.index;
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/BeansAccessBuilder.java 0000664 0000000 0000000 00000035436 12556201627 0031112 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACONST_NULL;
import static org.objectweb.asm.Opcodes.ALOAD;
import static org.objectweb.asm.Opcodes.ARETURN;
import static org.objectweb.asm.Opcodes.ASTORE;
import static org.objectweb.asm.Opcodes.ATHROW;
import static org.objectweb.asm.Opcodes.BIPUSH;
import static org.objectweb.asm.Opcodes.CHECKCAST;
import static org.objectweb.asm.Opcodes.DUP;
import static org.objectweb.asm.Opcodes.F_SAME;
import static org.objectweb.asm.Opcodes.GETFIELD;
import static org.objectweb.asm.Opcodes.ICONST_1;
import static org.objectweb.asm.Opcodes.ICONST_2;
import static org.objectweb.asm.Opcodes.ICONST_3;
import static org.objectweb.asm.Opcodes.ICONST_4;
import static org.objectweb.asm.Opcodes.ICONST_5;
import static org.objectweb.asm.Opcodes.IFEQ;
import static org.objectweb.asm.Opcodes.IFNE;
import static org.objectweb.asm.Opcodes.IFNULL;
import static org.objectweb.asm.Opcodes.IF_ICMPNE;
import static org.objectweb.asm.Opcodes.ILOAD;
import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
import static org.objectweb.asm.Opcodes.NEW;
import static org.objectweb.asm.Opcodes.PUTFIELD;
import static org.objectweb.asm.Opcodes.RETURN;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
public class BeansAccessBuilder {
static private String METHOD_ACCESS_NAME = Type.getInternalName(BeansAccess.class);
final Class> type;
final Accessor[] accs;
final DynamicClassLoader loader;
final String className;
final String accessClassName;
final String accessClassNameInternal;
final String classNameInternal;
final HashMap, Method> convMtds = new HashMap, Method>();
// Class extends Exception> exeptionClass = net.minidev.asm.ex.NoSuchFieldException.class;
Class extends Exception> exeptionClass = NoSuchFieldException.class;
/**
* Build reflect bytecode from accessor list.
*
* @param type
* type to be access
* @param accs
* used accessor
* @param loader
* Loader used to store the generated class
*/
public BeansAccessBuilder(Class> type, Accessor[] accs, DynamicClassLoader loader) {
this.type = type;
this.accs = accs;
this.loader = loader;
this.className = type.getName();
if (className.startsWith("java."))
this.accessClassName = "net.minidev.asm." + className + "AccAccess";
else
this.accessClassName = className.concat("AccAccess");
this.accessClassNameInternal = accessClassName.replace('.', '/');
this.classNameInternal = className.replace('.', '/');
}
public void addConversion(Iterable> conv) {
if (conv == null)
return;
for (Class> c : conv)
addConversion(c);
}
public void addConversion(Class> conv) {
if (conv == null)
return;
for (Method mtd : conv.getMethods()) {
if ((mtd.getModifiers() & Modifier.STATIC) == 0)
continue;
Class>[] param = mtd.getParameterTypes();
if (param.length != 1)
continue;
if (!param[0].equals(Object.class))
continue;
Class> rType = mtd.getReturnType();
if (rType.equals(Void.TYPE))
continue;
convMtds.put(rType, mtd);
}
}
public Class> bulid() {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
MethodVisitor mv;
boolean USE_HASH = accs.length > 10;
int HASH_LIMIT = 14;
String signature = "Lnet/minidev/asm/BeansAccess;";
cw.visit(Opcodes.V1_6, ACC_PUBLIC + Opcodes.ACC_SUPER, accessClassNameInternal, signature, METHOD_ACCESS_NAME, null);
// init
{
mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, METHOD_ACCESS_NAME, "", "()V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
// set(Object object, int methodIndex, Object value)
mv = cw.visitMethod(ACC_PUBLIC, "set", "(Ljava/lang/Object;ILjava/lang/Object;)V", null, null);
mv.visitCode();
// if no Field simply return
if (accs.length == 0) {
//
// mv.visitInsn(RETURN);
} else if (accs.length > HASH_LIMIT) {
// lots of field Use Switch Statement
mv.visitVarInsn(ILOAD, 2);
Label[] labels = ASMUtil.newLabels(accs.length);
Label defaultLabel = new Label();
mv.visitTableSwitchInsn(0, labels.length - 1, defaultLabel, labels);
int i = 0;
for (Accessor acc : accs) {
mv.visitLabel(labels[i++]);
if (!acc.isWritable()) {
mv.visitInsn(RETURN);
continue;
}
internalSetFiled(mv, acc);
}
mv.visitLabel(defaultLabel);
} else {
Label[] labels = ASMUtil.newLabels(accs.length);
int i = 0;
for (Accessor acc : accs) {
ifNotEqJmp(mv, 2, i, labels[i]);
internalSetFiled(mv, acc);
mv.visitLabel(labels[i]);
mv.visitFrame(F_SAME, 0, null, 0, null);
i++;
}
}
if (exeptionClass != null)
throwExIntParam(mv, exeptionClass);
else
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
// public Object get(Object object, int fieldId)
mv = cw.visitMethod(ACC_PUBLIC, "get", "(Ljava/lang/Object;I)Ljava/lang/Object;", null, null);
mv.visitCode();
// if (USE_HASH)
if (accs.length == 0) {
mv.visitFrame(F_SAME, 0, null, 0, null);
} else if (accs.length > HASH_LIMIT) {
mv.visitVarInsn(ILOAD, 2);
Label[] labels = ASMUtil.newLabels(accs.length);
Label defaultLabel = new Label();
mv.visitTableSwitchInsn(0, labels.length - 1, defaultLabel, labels);
int i = 0;
for (Accessor acc : accs) {
mv.visitLabel(labels[i++]);
mv.visitFrame(F_SAME, 0, null, 0, null);
if (!acc.isReadable()) {
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ARETURN);
continue;
}
mv.visitVarInsn(ALOAD, 1);
mv.visitTypeInsn(CHECKCAST, classNameInternal);
Type fieldType = Type.getType(acc.getType());
if (acc.isPublic()) {
mv.visitFieldInsn(GETFIELD, classNameInternal, acc.getName(), fieldType.getDescriptor());
} else {
String sig = Type.getMethodDescriptor(acc.getter);
mv.visitMethodInsn(INVOKEVIRTUAL, classNameInternal, acc.getter.getName(), sig);
}
ASMUtil.autoBoxing(mv, fieldType);
mv.visitInsn(ARETURN);
}
mv.visitLabel(defaultLabel);
mv.visitFrame(F_SAME, 0, null, 0, null);
} else {
Label[] labels = ASMUtil.newLabels(accs.length);
int i = 0;
for (Accessor acc : accs) {
ifNotEqJmp(mv, 2, i, labels[i]);
mv.visitVarInsn(ALOAD, 1);
mv.visitTypeInsn(CHECKCAST, classNameInternal);
Type fieldType = Type.getType(acc.getType());
if (acc.isPublic()) {
mv.visitFieldInsn(GETFIELD, classNameInternal, acc.getName(), fieldType.getDescriptor());
} else {
if (acc.getter == null)
throw new RuntimeException("no Getter for field " + acc.getName() + " in class " + this.className);
String sig = Type.getMethodDescriptor(acc.getter);
mv.visitMethodInsn(INVOKEVIRTUAL, classNameInternal, acc.getter.getName(), sig);
}
ASMUtil.autoBoxing(mv, fieldType);
mv.visitInsn(ARETURN);
mv.visitLabel(labels[i]);
mv.visitFrame(F_SAME, 0, null, 0, null);
i++;
}
}
if (exeptionClass != null)
throwExIntParam(mv, exeptionClass);
else {
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ARETURN);
}
mv.visitMaxs(0, 0);
mv.visitEnd();
if (!USE_HASH) {
// Object get(Object object, String methodName)
mv = cw.visitMethod(ACC_PUBLIC, "set", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V", null, null);
mv.visitCode();
Label[] labels = ASMUtil.newLabels(accs.length);
int i = 0;
for (Accessor acc : accs) {
mv.visitVarInsn(ALOAD, 2);
mv.visitLdcInsn(acc.fieldName);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z");
mv.visitJumpInsn(IFEQ, labels[i]);
internalSetFiled(mv, acc);
mv.visitLabel(labels[i]);
mv.visitFrame(F_SAME, 0, null, 0, null);
i++;
}
if (exeptionClass != null)
throwExStrParam(mv, exeptionClass);
else
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0); // 2,4
mv.visitEnd();
}
if (!USE_HASH) {
// get(Object object, String methodName)
mv = cw.visitMethod(ACC_PUBLIC, "get", "(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;", null, null);
mv.visitCode();
Label[] labels = ASMUtil.newLabels(accs.length);
int i = 0;
for (Accessor acc : accs) {
mv.visitVarInsn(ALOAD, 2); // methodName
mv.visitLdcInsn(acc.fieldName);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z");
mv.visitJumpInsn(IFEQ, labels[i]);
mv.visitVarInsn(ALOAD, 1); // object
mv.visitTypeInsn(CHECKCAST, classNameInternal);
Type fieldType = Type.getType(acc.getType());
if (acc.isPublic()) {
mv.visitFieldInsn(GETFIELD, classNameInternal, acc.getName(), fieldType.getDescriptor());
} else {
String sig = Type.getMethodDescriptor(acc.getter);
mv.visitMethodInsn(INVOKEVIRTUAL, classNameInternal, acc.getter.getName(), sig);
}
ASMUtil.autoBoxing(mv, fieldType);
mv.visitInsn(ARETURN);
mv.visitLabel(labels[i]);
mv.visitFrame(F_SAME, 0, null, 0, null);
i++;
}
if (exeptionClass != null)
throwExStrParam(mv, exeptionClass);
else {
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ARETURN);
}
mv.visitMaxs(0, 0);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "newInstance", "()Ljava/lang/Object;", null, null);
mv.visitCode();
mv.visitTypeInsn(NEW, classNameInternal);
mv.visitInsn(DUP);
mv.visitMethodInsn(INVOKESPECIAL, classNameInternal, "", "()V");
mv.visitInsn(ARETURN);
mv.visitMaxs(2, 1);
mv.visitEnd();
}
cw.visitEnd();
byte[] data = cw.toByteArray();
// dumpDebug(data, "/tmp/debug-" + accessClassName + ".txt");
return loader.defineClass(accessClassName, data);
}
/**
* Dump Generate Code
*/
@SuppressWarnings("unused")
private void dumpDebug(byte[] data, String destFile) {
// try {
// File debug = new File(destFile);
// int flags = ClassReader.SKIP_DEBUG;
// ClassReader cr = new ClassReader(new ByteArrayInputStream(data));
// cr.accept(new ASMifierClassVisitor(new PrintWriter(debug)),
// ASMifierClassVisitor.getDefaultAttributes(),
// flags);
// } catch (Exception e) {
// }
}
/**
* Dump Set Field Code
*
* @param mv
* @param acc
*/
private void internalSetFiled(MethodVisitor mv, Accessor acc) {
/**
* FNC params
*
* 1 -> object to alter
*
* 2 -> id of field
*
* 3 -> new value
*/
mv.visitVarInsn(ALOAD, 1);
mv.visitTypeInsn(CHECKCAST, classNameInternal);
// get VELUE
mv.visitVarInsn(ALOAD, 3);
Type fieldType = Type.getType(acc.getType());
Class> type = acc.getType();
String destClsName = Type.getInternalName(type);
Method conMtd = convMtds.get(type);
if (conMtd != null) {
// external converion
String clsSig = Type.getInternalName(conMtd.getDeclaringClass());
String mtdName = conMtd.getName();
String mtdSig = Type.getMethodDescriptor(conMtd);
mv.visitMethodInsn(INVOKESTATIC, clsSig, mtdName, mtdSig);
} else if (acc.isEnum()) {
// builtIn Enum Conversion
Label isNull = new Label();
mv.visitJumpInsn(IFNULL, isNull);
mv.visitVarInsn(ALOAD, 3);
// mv.visitTypeInsn(CHECKCAST, "java/lang/String");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "toString", "()Ljava/lang/String;");
mv.visitMethodInsn(INVOKESTATIC, destClsName, "valueOf", "(Ljava/lang/String;)L" + destClsName + ";");
mv.visitVarInsn(ASTORE, 3);
mv.visitLabel(isNull);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
mv.visitVarInsn(ALOAD, 1);
mv.visitTypeInsn(CHECKCAST, this.classNameInternal); // "net/minidev/asm/bean/BEnumPriv"
mv.visitVarInsn(ALOAD, 3);
mv.visitTypeInsn(CHECKCAST, destClsName);
} else if (type.equals(String.class)) {
// built In String Conversion
Label isNull = new Label();
mv.visitJumpInsn(IFNULL, isNull);
mv.visitVarInsn(ALOAD, 3);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "toString", "()Ljava/lang/String;");
mv.visitVarInsn(ASTORE, 3);
mv.visitLabel(isNull);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
mv.visitVarInsn(ALOAD, 1);
mv.visitTypeInsn(CHECKCAST, this.classNameInternal);
mv.visitVarInsn(ALOAD, 3);
mv.visitTypeInsn(CHECKCAST, destClsName);
} else {
// just check Cast
mv.visitTypeInsn(CHECKCAST, destClsName);
}
if (acc.isPublic()) {
mv.visitFieldInsn(PUTFIELD, classNameInternal, acc.getName(), fieldType.getDescriptor());
} else {
String sig = Type.getMethodDescriptor(acc.setter);
mv.visitMethodInsn(INVOKEVIRTUAL, classNameInternal, acc.setter.getName(), sig);
}
mv.visitInsn(RETURN);
}
/**
* add Throws statement with int param 2
*/
private void throwExIntParam(MethodVisitor mv, Class> exCls) {
String exSig = Type.getInternalName(exCls);
mv.visitTypeInsn(NEW, exSig);
mv.visitInsn(DUP);
mv.visitLdcInsn("mapping " + this.className + " failed to map field:");
mv.visitVarInsn(ILOAD, 2);
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "toString", "(I)Ljava/lang/String;");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "concat", "(Ljava/lang/String;)Ljava/lang/String;");
mv.visitMethodInsn(INVOKESPECIAL, exSig, "", "(Ljava/lang/String;)V");
mv.visitInsn(ATHROW);
}
/**
* add Throws statement with String param 2
*/
private void throwExStrParam(MethodVisitor mv, Class> exCls) {
String exSig = Type.getInternalName(exCls);
mv.visitTypeInsn(NEW, exSig);
mv.visitInsn(DUP);
mv.visitLdcInsn("mapping " + this.className + " failed to map field:");
mv.visitVarInsn(ALOAD, 2);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "concat", "(Ljava/lang/String;)Ljava/lang/String;");
mv.visitMethodInsn(INVOKESPECIAL, exSig, "", "(Ljava/lang/String;)V");
mv.visitInsn(ATHROW);
}
/**
* dump a Jump if not EQ
*/
private void ifNotEqJmp(MethodVisitor mv, int param, int value, Label label) {
mv.visitVarInsn(ILOAD, param);
if (value == 0) {
/* notest forvalue 0 */
mv.visitJumpInsn(IFNE, label);
} else if (value == 1) {
mv.visitInsn(ICONST_1);
mv.visitJumpInsn(IF_ICMPNE, label);
} else if (value == 2) {
mv.visitInsn(ICONST_2);
mv.visitJumpInsn(IF_ICMPNE, label);
} else if (value == 3) {
mv.visitInsn(ICONST_3);
mv.visitJumpInsn(IF_ICMPNE, label);
} else if (value == 4) {
mv.visitInsn(ICONST_4);
mv.visitJumpInsn(IF_ICMPNE, label);
} else if (value == 5) {
mv.visitInsn(ICONST_5);
mv.visitJumpInsn(IF_ICMPNE, label);
} else if (value >= 6) {
mv.visitIntInsn(BIPUSH, value);
mv.visitJumpInsn(IF_ICMPNE, label);
} else {
throw new RuntimeException("non supported negative values");
}
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/BeansAccessConfig.java 0000664 0000000 0000000 00000003634 12556201627 0030724 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import java.util.HashMap;
import java.util.LinkedHashSet;
public class BeansAccessConfig {
/**
* Field type convertor for all classes
*
* Convertor classes should contains mapping method Prototyped as:
*
* public static DestinationType Method(Object data);
*
* @see DefaultConverter
*/
//static protected LinkedHashSet> globalMapper = new LinkedHashSet>();
/**
* Field type convertor for custom Class
*
* Convertor classes should contains mapping method Prototyped as:
*
* public static DestinationType Method(Object data);
*
* @see DefaultConverter
*/
static protected HashMap, LinkedHashSet>> classMapper = new HashMap, LinkedHashSet>>();
/**
* FiledName remapper for a specific class or interface
*/
static protected HashMap, HashMap> classFiledNameMapper = new HashMap, HashMap>();
static {
addTypeMapper(Object.class, DefaultConverter.class);
addTypeMapper(Object.class, ConvertDate.class);
}
// /**
// * Field type convertor for all classes
// *
// * Convertor classes should contains mapping method Prototyped as:
// *
// * public static DestinationType Method(Object data);
// *
// * @see DefaultConverter
// */
// public static void addGlobalTypeMapper(Class> mapper) {
// synchronized (globalMapper) {
// globalMapper.add(mapper);
// }
// }
/**
* Field type convertor for all classes
*
* Convertor classes should contains mapping method Prototyped as:
*
* public static DestinationType Method(Object data);
*
* @see DefaultConverter
*/
public static void addTypeMapper(Class> clz, Class> mapper) {
synchronized (classMapper) {
LinkedHashSet> h = classMapper.get(clz);
if (h == null) {
h = new LinkedHashSet>();
classMapper.put(clz, h);
}
h.add(mapper);
}
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/ConvertDate.java 0000664 0000000 0000000 00000017072 12556201627 0027643 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class ConvertDate {
static TreeMap monthsTable = new TreeMap(new StringCmpNS()); // StringCmpNS.COMP
static TreeMap daysTable = new TreeMap(new StringCmpNS()); // StringCmpNS.COMP
private static HashSet voidData = new HashSet();
public static class StringCmpNS implements Comparator {
@Override
public int compare(String o1, String o2) {
return o1.compareToIgnoreCase(o2);
}
}
public static Integer getMonth(String month) {
return monthsTable.get(month);
}
private static Integer parseMonth(String s1) {
if (Character.isDigit(s1.charAt(0))) {
return Integer.parseInt(s1) - 1;
} else {
Integer month = monthsTable.get(s1);
if (month == null)
throw new NullPointerException("can not parse " + s1 + " as month");
return month.intValue();
}
}
static {
voidData.add("CET");
voidData.add("MEZ");
voidData.add("Uhr");
voidData.add("h");
voidData.add("pm");
voidData.add("PM");
voidData.add("o'clock");
// for (int c = 1; c <= 31; c++) {
// String s = Integer.toString(c);
// if (c < 10)
// daysTable.put("0".concat(s), c - 1);
// daysTable.put(s, c - 1);
// }
// for (int c = 1; c <= 12; c++) {
// String s = Integer.toString(c);
// if (c < 10)
// monthsTable.put("0".concat(s), c - 1);
// monthsTable.put(s, c - 1);
// }
for (Locale locale : DateFormatSymbols.getAvailableLocales()) {
if ("ja".equals(locale.getLanguage()))
continue;
if ("ko".equals(locale.getLanguage()))
continue;
if ("zh".equals(locale.getLanguage()))
continue;
DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale);
String[] keys = dfs.getMonths();
for (int i = 0; i < keys.length; i++) {
if (keys[i].length() == 0)
continue;
fillMap(monthsTable, keys[i], Integer.valueOf(i));
}
keys = dfs.getShortMonths();
for (int i = 0; i < keys.length; i++) {
String s = keys[i];
if (s.length() == 0)
continue;
if (Character.isDigit(s.charAt(s.length() - 1)))
continue;
fillMap(monthsTable, keys[i], Integer.valueOf(i));
fillMap(monthsTable, keys[i].replace(".", ""), Integer.valueOf(i));
}
keys = dfs.getWeekdays();
for (int i = 0; i < keys.length; i++) {
String s = keys[i];
if (s.length() == 0)
continue;
fillMap(daysTable, s, Integer.valueOf(i));
fillMap(daysTable, s.replace(".", ""), Integer.valueOf(i));
}
keys = dfs.getShortWeekdays();
for (int i = 0; i < keys.length; i++) {
String s = keys[i];
if (s.length() == 0)
continue;
fillMap(daysTable, s, Integer.valueOf(i));
fillMap(daysTable, s.replace(".", ""), Integer.valueOf(i));
}
}
}
private static void fillMap(TreeMap map, String key, Integer value) {
map.put(key, value);
key = key.replace("é", "e");
key = key.replace("û", "u");
map.put(key, value);
}
/**
* try read a Date from a Object
*/
public static Date convertToDate(Object obj) {
if (obj == null)
return null;
if (obj instanceof Date)
return (Date) obj;
if (obj instanceof String) {
StringTokenizer st = new StringTokenizer((String) obj, " -/:,.+");
String s1 = "";
if (!st.hasMoreTokens())
return null;
s1 = st.nextToken();
if (s1.length() == 4 && Character.isDigit(s1.charAt(0)))
return getYYYYMMDD(st, s1);
// skip Day if present.
if (daysTable.containsKey(s1)) {
if (!st.hasMoreTokens())
return null;
s1 = st.nextToken();
}
if (monthsTable.containsKey(s1))
return getMMDDYYYY(st, s1);
if (Character.isDigit(s1.charAt(0)))
return getDDMMYYYY(st, s1);
return null;
}
throw new RuntimeException("Primitive: Can not convert " + obj.getClass().getName() + " to int");
}
private static Date getYYYYMMDD(StringTokenizer st, String s1) {
GregorianCalendar cal = new GregorianCalendar(2000, 0, 0, 0, 0, 0);
cal.setTimeInMillis(0);
int year = Integer.parseInt(s1);
cal.set(Calendar.YEAR, year);
if (!st.hasMoreTokens())
return cal.getTime();
s1 = st.nextToken();
cal.set(Calendar.MONTH, parseMonth(s1));
if (!st.hasMoreTokens())
return cal.getTime();
s1 = st.nextToken();
if (Character.isDigit(s1.charAt(0))) {
if (s1.length()==5 && s1.charAt(2) == 'T') {
// TIME + TIMEZONE
int day = Integer.parseInt(s1.substring(0,2));
cal.set(Calendar.DAY_OF_MONTH, day);
return addHour(st, cal, s1.substring(3));
}
int day = Integer.parseInt(s1);
cal.set(Calendar.DAY_OF_MONTH, day);
return addHour(st, cal, null);
}
return cal.getTime();
}
private static int getYear(String s1) {
int year = Integer.parseInt(s1);
// CET ?
if (year < 100) {
if (year > 23)
year += 2000;
else
year += 1900;
}
return year;
}
private static Date getMMDDYYYY(StringTokenizer st, String s1) {
GregorianCalendar cal = new GregorianCalendar(2000, 0, 0, 0, 0, 0);
Integer month = monthsTable.get(s1);
if (month == null)
throw new NullPointerException("can not parse " + s1 + " as month");
cal.set(Calendar.MONTH, month);
if (!st.hasMoreTokens())
return null;
s1 = st.nextToken();
// DAY
int day = Integer.parseInt(s1);
cal.set(Calendar.DAY_OF_MONTH, day);
if (!st.hasMoreTokens())
return null;
s1 = st.nextToken();
if (Character.isLetter(s1.charAt(0))) {
if (!st.hasMoreTokens())
return null;
s1 = st.nextToken();
}
cal.set(Calendar.YEAR, getYear(s1));
// /if (st.hasMoreTokens())
// return null;
// s1 = st.nextToken();
return addHour(st, cal, null);
// return cal.getTime();
}
private static Date getDDMMYYYY(StringTokenizer st, String s1) {
GregorianCalendar cal = new GregorianCalendar(2000, 0, 0, 0, 0, 0);
int day = Integer.parseInt(s1);
cal.set(Calendar.DAY_OF_MONTH, day);
if (!st.hasMoreTokens())
return null;
s1 = st.nextToken();
cal.set(Calendar.MONTH, parseMonth(s1));
if (!st.hasMoreTokens())
return null;
s1 = st.nextToken();
cal.set(Calendar.YEAR, getYear(s1));
return addHour(st, cal, null);
}
private static Date addHour(StringTokenizer st, Calendar cal, String s1) {
// String s1;
if (s1 == null) {
if (!st.hasMoreTokens())
return cal.getTime();
s1 = st.nextToken();
}
cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(s1));
if (!st.hasMoreTokens())
return cal.getTime();
s1 = st.nextToken();
s1 = trySkip(st, s1, cal);
if (s1 == null)
return cal.getTime();
// if (s1.equalsIgnoreCase("h")) {
// if (!st.hasMoreTokens())
// return cal.getTime();
// s1 = st.nextToken();
// }
cal.set(Calendar.MINUTE, Integer.parseInt(s1));
if (!st.hasMoreTokens())
return cal.getTime();
s1 = st.nextToken();
s1 = trySkip(st, s1, cal);
if (s1 == null)
return cal.getTime();
cal.set(Calendar.SECOND, Integer.parseInt(s1));
if (!st.hasMoreTokens())
return cal.getTime();
s1 = st.nextToken();
s1 = trySkip(st, s1, cal);
if (s1 == null)
return cal.getTime();
// TODO ADD TIME ZONE
s1 = trySkip(st, s1, cal);
// if (s1.equalsIgnoreCase("pm"))
// cal.add(Calendar.HOUR_OF_DAY, 12);
return cal.getTime();
}
private static String trySkip(StringTokenizer st, String s1, Calendar cal) {
while (voidData.contains(s1)) {
if (s1.equalsIgnoreCase("pm"))
cal.add(Calendar.HOUR_OF_DAY, 12);
if (!st.hasMoreTokens())
return null;
s1 = st.nextToken();
}
return s1;
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/DefaultConverter.java 0000664 0000000 0000000 00000013134 12556201627 0030674 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import net.minidev.asm.ex.ConvertException;
public class DefaultConverter {
public static int convertToint(Object obj) {
if (obj == null)
return 0;
if (obj instanceof Number)
return ((Number) obj).intValue();
if (obj instanceof String)
return Integer.parseInt((String) obj);
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to int");
}
public static Integer convertToInt(Object obj) {
if (obj == null)
return null;
Class> c = obj.getClass();
if (c == Integer.class)
return (Integer) obj;
if (obj instanceof Number)
return Integer.valueOf(((Number) obj).intValue());
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to Integer");
}
public static short convertToshort(Object obj) {
if (obj == null)
return 0;
if (obj instanceof Number)
return ((Number) obj).shortValue();
if (obj instanceof String)
return Short.parseShort((String) obj);
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to short");
}
public static Short convertToShort(Object obj) {
if (obj == null)
return null;
Class> c = obj.getClass();
if (c == Short.class)
return (Short) obj;
if (obj instanceof Number)
return Short.valueOf(((Number) obj).shortValue());
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to Short");
}
public static long convertTolong(Object obj) {
if (obj == null)
return 0;
if (obj instanceof Number)
return ((Number) obj).longValue();
if (obj instanceof String)
return Long.parseLong((String) obj);
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to long");
}
public static Long convertToLong(Object obj) {
if (obj == null)
return null;
Class> c = obj.getClass();
if (c == Long.class)
return (Long) obj;
if (obj instanceof Number)
return Long.valueOf(((Number) obj).longValue());
throw new ConvertException("Primitive: Can not convert value '" + obj+ "' As " + obj.getClass().getName() + " to Long");
}
public static byte convertTobyte(Object obj) {
if (obj == null)
return 0;
if (obj instanceof Number)
return ((Number) obj).byteValue();
if (obj instanceof String)
return Byte.parseByte((String) obj);
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to byte");
}
public static Byte convertToByte(Object obj) {
if (obj == null)
return null;
Class> c = obj.getClass();
if (c == Byte.class)
return (Byte) obj;
if (obj instanceof Number)
return Byte.valueOf(((Number) obj).byteValue());
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to Byte");
}
public static float convertTofloat(Object obj) {
if (obj == null)
return 0f;
if (obj instanceof Number)
return ((Number) obj).floatValue();
if (obj instanceof String)
return Float.parseFloat((String) obj);
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to float");
}
public static Float convertToFloat(Object obj) {
if (obj == null)
return null;
Class> c = obj.getClass();
if (c == Float.class)
return (Float) obj;
if (obj instanceof Number)
return Float.valueOf(((Number) obj).floatValue());
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to Float");
}
public static double convertTodouble(Object obj) {
if (obj == null)
return 0.0;
if (obj instanceof Number)
return ((Number) obj).doubleValue();
if (obj instanceof String)
return Double.parseDouble((String) obj);
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to float");
}
public static Double convertToDouble(Object obj) {
if (obj == null)
return null;
Class> c = obj.getClass();
if (c == Double.class)
return (Double) obj;
if (obj instanceof Number)
return Double.valueOf(((Number) obj).doubleValue());
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to Float");
}
public static char convertTochar(Object obj) {
if (obj == null)
return ' ';
if (obj instanceof String)
if (((String) obj).length() > 0)
return ((String) obj).charAt(0);
else
return ' ';
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to char");
}
public static Character convertToChar(Object obj) {
if (obj == null)
return null;
Class> c = obj.getClass();
if (c == Character.class)
return (Character) obj;
if (obj instanceof String)
if (((String) obj).length() > 0)
return ((String) obj).charAt(0);
else
return ' ';
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to Character");
}
public static boolean convertTobool(Object obj) {
if (obj == null)
return false;
if (obj.getClass() == Boolean.class)
return ((Boolean) obj).booleanValue();
if (obj instanceof String)
return Boolean.parseBoolean((String) obj);
if (obj instanceof Number) {
if (obj.toString().equals("0"))
return false;
else
return true;
}
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to boolean");
}
public static Boolean convertToBool(Object obj) {
if (obj == null)
return null;
Class> c = obj.getClass();
if (c == Boolean.class)
return (Boolean) obj;
if (obj instanceof String)
return Boolean.parseBoolean((String) obj);
throw new ConvertException("Primitive: Can not convert " + obj.getClass().getName() + " to Boolean");
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/DynamicClassLoader.java 0000664 0000000 0000000 00000005544 12556201627 0031127 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
/*
* Copyright 2011 JSON-SMART authors
*
* 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.
*/
import java.lang.reflect.Method;
/**
* Simple extension from ClassLoader overiding the loadClass(String name,
* boolean resolve) method and allowing to register new classes
*
* @author uriel
*
*/
class DynamicClassLoader extends ClassLoader {
DynamicClassLoader(ClassLoader parent) {
super(parent);
}
private final static String BEAN_AC = BeansAccess.class.getName();
/**
* Predefined define defineClass method signature (name, bytes, offset,
* length)
*/
private final static Class>[] DEF_CLASS_SIG = new Class[] { String.class, byte[].class, int.class, int.class };
/**
*
* @param parent used to choose the ClassLoader
* @param clsName C
* @param clsData
* @return
*/
public static Class directLoad(Class extends T> parent, String clsName, byte[] clsData) {
DynamicClassLoader loader = new DynamicClassLoader(parent.getClassLoader());
@SuppressWarnings("unchecked")
Class clzz = (Class) loader.defineClass(clsName, clsData);
return clzz;
}
public static T directInstance(Class extends T> parent, String clsName, byte[] clsData) throws InstantiationException, IllegalAccessException {
Class clzz = directLoad(parent, clsName, clsData);
return clzz.newInstance();
}
@Override
protected synchronized java.lang.Class> loadClass(String name, boolean resolve) throws ClassNotFoundException {
/*
* check class by fullname as String.
*/
if (name.equals(BEAN_AC))
return BeansAccess.class;
/*
* Use default class loader
*/
return super.loadClass(name, resolve);
}
/**
* Call defineClass into the parent classLoader using the
* method.setAccessible(boolean) hack
*
* @see ClassLoader#defineClass(String, byte[], int, int)
*/
Class> defineClass(String name, byte[] bytes) throws ClassFormatError {
try {
// Attempt to load the access class in the same loader, which makes
// protected and default access members accessible.
Method method = ClassLoader.class.getDeclaredMethod("defineClass", DEF_CLASS_SIG);
method.setAccessible(true);
return (Class>) method.invoke(getParent(), new Object[] { name, bytes, Integer.valueOf(0), Integer.valueOf(bytes.length) });
} catch (Exception ignored) {
}
return defineClass(name, bytes, 0, bytes.length);
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/FieldFilter.java 0000664 0000000 0000000 00000000707 12556201627 0027613 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* allow to control read/write access to field
*
*/
public interface FieldFilter {
/**
* NOT Implemented YET
*/
public boolean canUse(Field field);
public boolean canUse(Field field, Method method);
/**
* NOT Implemented YET
*/
public boolean canRead(Field field);
/**
* NOT Implemented YET
*/
public boolean canWrite(Field field);
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/ex/ 0000775 0000000 0000000 00000000000 12556201627 0025167 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/ex/ConvertException.java 0000664 0000000 0000000 00000000370 12556201627 0031331 0 ustar 00root root 0000000 0000000 package net.minidev.asm.ex;
public class ConvertException extends RuntimeException {
private static final long serialVersionUID = 1L;
public ConvertException() {
super();
}
public ConvertException(String message) {
super(message);
}
}
json-smart-v2-2.2/accessors-smart/src/main/java/net/minidev/asm/ex/NoSuchFieldException.java 0000664 0000000 0000000 00000000563 12556201627 0032060 0 ustar 00root root 0000000 0000000 package net.minidev.asm.ex;
/**
* Same exception as java.lang.NoSuchFieldException but extends RuntimException
*
* @author uriel
*
*/
public class NoSuchFieldException extends RuntimeException {
private static final long serialVersionUID = 1L;
public NoSuchFieldException() {
super();
}
public NoSuchFieldException(String message) {
super(message);
}
}
json-smart-v2-2.2/accessors-smart/src/test/ 0000775 0000000 0000000 00000000000 12556201627 0020664 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/test/java/ 0000775 0000000 0000000 00000000000 12556201627 0021605 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/test/java/net/ 0000775 0000000 0000000 00000000000 12556201627 0022373 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/ 0000775 0000000 0000000 00000000000 12556201627 0024026 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/ 0000775 0000000 0000000 00000000000 12556201627 0024606 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/ASMTest.java 0000664 0000000 0000000 00000005705 12556201627 0026740 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import java.util.HashMap;
import junit.framework.TestCase;
import net.minidev.asm.bean.BTest;
public class ASMTest extends TestCase {
@SuppressWarnings({ "unused" })
public void testGet() throws Exception {
long T1;
BeansAccess acBT = BeansAccess.get(BTest.class);
// BeansAccess acHand = new BTestBeansAccessB();
HashMap m = new HashMap();
m.put("A", "ab");
m.put("B", "Bc");
m.put("C", "cD");
m.put("D", "de");
m.put("E", "ef");
// String clsPath = FastMap1Builder.getName(m.size());
// String clsName = clsPath.replace("/", ".");
byte[] data;
// data = FastMap1Builder.dump(m.size());
// data = FastMap2Builder.dump(m);
// data = FastMapTestDump.dump(clsPath);
// DynamicClassLoader loader = new
// DynamicClassLoader(BTest.class.getClassLoader());
// byte[] data = BTestBeansAccessDump.dump();
// Class cls = (Class) loader.defineClass(clsName,
// data);
// Constructor c = (Constructor)
// cls.getConstructors()[0];
// FastMap f = c.newInstance(m);
// f = new FastMapTest_2(m);
// f = new FastMapTest_3();
// f = new FastMapTest_2(m);
// f = new FastMapTest_3();
// System.out.println(m.get("A"));
// 4 entré
// map => 1.279
// fastMap => 3.323
// FastMapTest_1 3.323
// FastMapTest_2 3.323
// FastMapTest_3 0.015
// 3 entry
// map => 0.983
// fastmap => 1.014
// 2 entry
// map => 0,920
// fastMap => 0,608
// 7 entry
// f 2.667
// m 0,640
// 6 entree
// f 2.215
// m 0,608
// 4 entree
// f 0.032
// m 0,593
// 5 entree
// f
// m 0.609
// V2 2.402
// V3 2.247
// for (int i = 0; i < 20000; i++) {
// f.get("A");
// f.get("B");
// f.get("C");
// f.get("D");
// f.get("E");
// f.get("F");
// f.get("G");
// f.get("H");
// f.get("I");
// }
// System.gc();
// long T = System.nanoTime();
// for (int i = 0; i < 20000000; i++) {
// m.get("A");
// m.get("B");
// m.get("C");
// m.get("D");
// m.get("E");
// m.get("F");
// m.get("G");
// m.get("H");
// m.get("I");
// }
// T = System.nanoTime() - T;
// System.out.println(NumberFormat.getInstance().format(T));
// 10 774 968
// 596 295 451
// 2 321 087 341
BeansAccess ac;
ac = acBT;
// ac = acHand;
// ac = acASMHand;
subtext(ac);
// T1 = System.currentTimeMillis();
// for (int i = 0; i < 2000000; i++)
// subtext(ac);
// T1 = System.currentTimeMillis() - T1;
// System.out.println("// Time: " + T1);
}
private void subtext(BeansAccess acc) {
BTest t = new BTest();
acc.set(t, "pubBoolValue", true);
acc.set(t, "pubIntValue", 13);
acc.set(t, "pubStrValue", "Test");
acc.set(t, "privIntValue", 16);
acc.set(t, "privStrValue", "test Priv");
assertEquals(Integer.valueOf(13), acc.get(t, "pubIntValue"));
acc.set(t, "pubIntValue", 14);
assertEquals(Integer.valueOf(14), acc.get(t, "pubIntValue"));
}
} json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/BTestBeansAccessB.java 0000664 0000000 0000000 00000011644 12556201627 0030675 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import net.minidev.asm.bean.BTest;
import net.minidev.asm.bean.TEnum;
@SuppressWarnings("rawtypes")
public class BTestBeansAccessB extends BeansAccess {
public BTestBeansAccessB() {
Accessor[] accs = ASMUtil.getAccessors(BTest.class, null);
super.setAccessor(accs);
}
/**
* set field value by fieldname
*/
@Override
public void set(Object object, String methodName, Object value) {
if ("privIntValue".equals(methodName)) {
((BTest) object).setPrivIntValue(DefaultConverter.convertToint(value));
return;
}
if ("privStrValue".equals(methodName)) {
if (value != null)
value = value.toString();
((BTest) object).setPrivStrValue((String) value);
return;
}
if ("pubStrValue".equals(methodName)) {
if (value != null)
value = value.toString();
((BTest) object).pubStrValue = (String) value;
return;
}
if ("pubIntValue".equals(methodName)) {
((BTest) object).pubIntValue = DefaultConverter.convertToint(value);
return;
}
if ("pubBoolValue".equals(methodName)) {
((BTest) object).pubBoolValue = DefaultConverter.convertTobool(value);
return;
}
if ("pubIntegerValue".equals(methodName)) {
((BTest) object).pubIntegerValue = DefaultConverter.convertToInt(value);
return;
}
if ("pubTEnum".equals(methodName)) {
((BTest) object).pubTEnum = TEnum.valueOf((String) value);
return;
}
}
/**
* get field value by fieldname
*/
@Override
public Object get(Object object, String methodName) {
if ("privIntValue".equals(methodName))
return ((BTest) object).getPrivIntValue();
if ("privStrValue".equals(methodName))
return ((BTest) object).getPrivStrValue();
if ("pubStrValue".equals(methodName))
return ((BTest) object).pubStrValue;
if ("pubIntValue".equals(methodName))
return ((BTest) object).pubIntValue;
if ("privStrValue".equals(methodName))
return ((BTest) object).pubBoolValue;
if ("pubIntegerValue".equals(methodName))
return ((BTest) object).pubIntegerValue;
if ("pubTEnum".equals(methodName))
return ((BTest) object).pubTEnum;
return null;
}
@Override
public void set(Object object, int methodIndex, Object value) {
switch (methodIndex) {
case 0: // privIntValue;
((BTest) object).setPrivIntValue(((Number) value).intValue());
break;
case 1: // privStrValue;
((BTest) object).setPrivStrValue((String) value);
break;
case 2: // pubStrValue;
((BTest) object).pubStrValue = (String) value;
break;
case 3: // pubIntValue;
((BTest) object).pubIntValue = ((Number) value).intValue();
break;
case 4: // pubBoolValue;
((BTest) object).pubBoolValue = ((Boolean) value).booleanValue();
break;
case 5:
((BTest) object).pubIntegerValue = DefaultConverter.convertToInt(value);
break;
case 6:
((BTest) object).pubTEnum = TEnum.valueOf((String) value);
break;
default:
break;
}
}
public void setInt(Object object, int methodIndex, Object value) {
if (methodIndex == 0) {
((BTest) object).setPrivIntValue(((Number) value).intValue());
return;
}
if (methodIndex == 1) {
((BTest) object).setPrivStrValue((String) value);
return;
}
if (methodIndex == 2) {
((BTest) object).pubStrValue = (String) value;
return;
}
if (methodIndex == 3) {
((BTest) object).pubIntValue = ((Number) value).intValue();
return;
}
if (methodIndex == 4) {
((BTest) object).pubBoolValue = ((Boolean) value).booleanValue();
return;
}
if (methodIndex == 5) {
((BTest) object).pubBoolValue = ((Boolean) value).booleanValue();
return;
}
if (methodIndex == 0) {
((BTest) object).pubBoolValue = ((Boolean) value).booleanValue();
return;
}
if (methodIndex == 7) {
((BTest) object).pubBoolValue = ((Boolean) value).booleanValue();
return;
}
if (methodIndex == 8) {
((BTest) object).pubBoolValue = ((Boolean) value).booleanValue();
return;
}
}
@Override
public Object get(Object object, int methodIndex) {
switch (methodIndex) {
case 0: // privIntValue;
return ((BTest) object).getPrivIntValue();
case 1: // privStrValue;
return ((BTest) object).getPrivStrValue();
case 2: // pubStrValue;
return ((BTest) object).pubStrValue;
case 3: // pubIntValue;
return ((BTest) object).pubIntValue;
case 4: // privStrValue;
return ((BTest) object).pubBoolValue;
case 5: // privStrValue;
return ((BTest) object).pubIntegerValue;
case 6: // privStrValue;
return ((BTest) object).pubTEnum;
default:
break;
}
return null;
}
// public Object getInt(Object object, int methodIndex) {
// if (methodIndex == 0)
// return ((BTest) object).getPrivIntValue();
// if (methodIndex == 1)
// return ((BTest) object).getPrivStrValue();
// if (methodIndex == 2)
// return ((BTest) object).pubStrValue;
// if (methodIndex == 3)
// return ((BTest) object).pubIntValue;
// if (methodIndex == 4)
// return ((BTest) object).pubBoolValue;
// return null;
// }
@Override
public Object newInstance() {
return new BTest();
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/TestDateConvert.java 0000664 0000000 0000000 00000004670 12556201627 0030536 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import junit.framework.TestCase;
public class TestDateConvert extends TestCase {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
public void testDateFR() throws Exception {
String expectedDateText = "23/01/2012 13:42:12";
ArrayList tests = new ArrayList();
tests.add("23 janvier 2012 13:42:12");
tests.add("lundi 23 janvier 2012 13:42:12");
tests.add("2012-01-23 13:42:12");
//
for (String testDate : tests) {
Date parsed = null;
try {
parsed = ConvertDate.convertToDate(testDate);
} catch (Exception e) {
System.err.println("can not parse:" + testDate);
e.printStackTrace();
}
assertEquals(expectedDateText, sdf.format(parsed));
}
}
public void testAdvanceTimeStamp() throws Exception {
String testDate = "2014-08-27T12:53:10+02:00";
ConvertDate.convertToDate(testDate);
}
public void testDateUS() throws Exception {
testDateLocalized(Locale.US);
}
public void testDateFRANCE() throws Exception {
testDateLocalized(Locale.FRANCE);
}
public void testDateCANADA() throws Exception {
testDateLocalized(Locale.CANADA);
}
public void testDateGERMANY() throws Exception {
testDateLocalized(Locale.GERMANY);
}
public void testDateITALY() throws Exception {
testDateLocalized(Locale.ITALY);
}
// MISSING JAPAN / CHINA
public void testDateLocalized(Locale locale) throws Exception {
// PM
fullTestDate(sdf.parse("23/01/2012 13:42:59"), locale);
// AM
fullTestDate(sdf.parse("23/01/2012 01:42:59"), locale);
}
public void fullTestDate(Date expectedDate, Locale locale) throws Exception {
String expectedDateText = sdf.format(expectedDate);
int[] types = new int[] { DateFormat.MEDIUM, DateFormat.LONG, DateFormat.FULL };
for (int frm : types) {
DateFormat FormatEN = DateFormat.getDateTimeInstance(frm, frm, locale);
String testDate = FormatEN.format(expectedDate);
Date parse = null;
try {
parse = ConvertDate.convertToDate(testDate);
} catch (Exception e) {
System.err.println("can not parse:" + testDate + " - DateFormat." + frm);
e.printStackTrace();
}
String resultStr = sdf.format(parse);
//System.err.println("TEST: " + testDate + " readed as: " + resultStr);
if (testDate.contains("59"))
assertEquals(expectedDateText, resultStr);
}
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/TestNewInstance.java 0000664 0000000 0000000 00000000441 12556201627 0030526 0 ustar 00root root 0000000 0000000 package net.minidev.asm;
import java.util.TreeMap;
import junit.framework.TestCase;
public class TestNewInstance extends TestCase {
public void testLangUtilPkg() {
@SuppressWarnings("rawtypes")
BeansAccess acTm = BeansAccess.get(TreeMap.class);
acTm.newInstance();
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/ 0000775 0000000 0000000 00000000000 12556201627 0025513 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BBoolPriv.java 0000664 0000000 0000000 00000000303 12556201627 0030210 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BBoolPriv {
private boolean value;
public boolean isValue() {
return value;
}
public void setValue(boolean value) {
this.value = value;
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BBoolPub.java 0000664 0000000 0000000 00000000120 12556201627 0030013 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BBoolPub {
public boolean value;
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BBooleanPriv.java 0000664 0000000 0000000 00000000307 12556201627 0030700 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BBooleanPriv {
private Boolean value;
public Boolean getValue() {
return value;
}
public void setValue(Boolean value) {
this.value = value;
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BBooleanPub.java 0000664 0000000 0000000 00000000123 12556201627 0030502 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BBooleanPub {
public Boolean value;
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BEnumPriv.java 0000664 0000000 0000000 00000000276 12556201627 0030232 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BEnumPriv {
private TEnum value;
public TEnum getValue() {
return value;
}
public void setValue(TEnum value) {
this.value = value;
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BEnumPrivAc.java 0000664 0000000 0000000 00000003067 12556201627 0030477 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
import net.minidev.asm.BeansAccess;
@SuppressWarnings("rawtypes")
public class BEnumPrivAc extends BeansAccess {
@Override
public void set(Object object, int methodIndex, Object value) {
if (methodIndex == 0) {
if (value != null)
// value = TEnum.valueOf((String) value);
value = TEnum.valueOf(value.toString());
((BEnumPriv) object).setValue((TEnum) value);
return;
}
throw new net.minidev.asm.ex.NoSuchFieldException("mapping BEnumPriv failed to map field:".concat(Integer.toString(methodIndex)));
}
@Override
public Object get(Object object, int methodIndex) {
if (methodIndex == 0) {
return ((BEnumPriv) object).getValue();
}
throw new net.minidev.asm.ex.NoSuchFieldException("mapping BEnumPriv failed to map field:".concat(Integer.toString(methodIndex)));
}
@Override
public void set(Object object, String methodIndex, Object value) {
if (methodIndex.equals("value")) {
if (value != null)
// value = TEnum.valueOf((String) value);
value = TEnum.valueOf(value.toString());
((BEnumPriv) object).setValue((TEnum) value);
return;
}
throw new net.minidev.asm.ex.NoSuchFieldException("mapping BEnumPriv failed to map field:".concat(methodIndex));
}
@Override
public Object get(Object object, String methodIndex) {
if (methodIndex.equals("value")) {
return ((BEnumPriv) object).getValue();
}
throw new net.minidev.asm.ex.NoSuchFieldException("mapping BEnumPriv failed to map field:".concat(methodIndex));
}
@Override
public Object newInstance() {
return new BEnumPriv();
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BEnumPub.java 0000664 0000000 0000000 00000000116 12556201627 0030031 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BEnumPub {
public TEnum value;
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BLongPriv.java 0000664 0000000 0000000 00000000273 12556201627 0030222 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BLongPriv {
private Long value;
public Long getValue() {
return value;
}
public void setValue(Long value) {
this.value = value;
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BLongPrivAc.java 0000664 0000000 0000000 00000001735 12556201627 0030472 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
import net.minidev.asm.BeansAccess;
import net.minidev.asm.DefaultConverter;
@SuppressWarnings("rawtypes")
public class BLongPrivAc extends BeansAccess {
@Override
public void set(Object object, int methodIndex, Object value) {
if (methodIndex == 0) {
((BLongPriv) object).setValue(DefaultConverter.convertToLong(value));
return;
}
}
@Override
public Object get(Object object, int methodIndex) {
if (methodIndex == 0) {
return ((BLongPriv) object).getValue();
}
return null;
}
@Override
public void set(Object object, String methodIndex, Object value) {
if (methodIndex.equals("value")) {
((BLongPriv) object).setValue(DefaultConverter.convertToLong(value));
return;
}
}
@Override
public Object get(Object object, String methodIndex) {
if (methodIndex.equals("value")) {
return ((BLongPriv) object).getValue();
}
return null;
}
@Override
public Object newInstance() {
return new BLongPriv();
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BLongPub.java 0000664 0000000 0000000 00000000115 12556201627 0030023 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BLongPub {
public Long value;
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BLongPubAc.java 0000664 0000000 0000000 00000001711 12556201627 0030272 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
import net.minidev.asm.BeansAccess;
import net.minidev.asm.DefaultConverter;
@SuppressWarnings("rawtypes")
public class BLongPubAc extends BeansAccess {
@Override
public void set(Object object, int methodIndex, Object value) {
if (methodIndex == 0) {
((BLongPub) object).value = DefaultConverter.convertToLong(value);
return;
}
}
@Override
public Object get(Object object, int methodIndex) {
if (methodIndex == 0) {
return ((BLongPub) object).value;
}
return null;
}
@Override
public void set(Object object, String methodIndex, Object value) {
if (methodIndex.equals("value")) {
((BLongPub) object).value = DefaultConverter.convertToLong(value);
return;
}
}
@Override
public Object get(Object object, String methodIndex) {
if (methodIndex.equals("value")) {
return ((BLongPub) object).value;
}
return null;
}
@Override
public Object newInstance() {
return new BLongPub();
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BObjectPriv.java 0000664 0000000 0000000 00000000303 12556201627 0030523 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BObjectPriv {
private Object value;
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BObjectPub.java 0000664 0000000 0000000 00000000121 12556201627 0030327 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BObjectPub {
public Object value;
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BStrPriv.java 0000664 0000000 0000000 00000000301 12556201627 0030063 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BStrPriv {
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BStrPrivAc.java 0000664 0000000 0000000 00000001750 12556201627 0030340 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
import net.minidev.asm.BeansAccess;
@SuppressWarnings("rawtypes")
public class BStrPrivAc extends BeansAccess {
@Override
public void set(Object object, int methodIndex, Object value) {
if (methodIndex == 0) {
if (value != null)
value = value.toString();
((BStrPriv) object).setValue((String) value);
return;
}
}
@Override
public Object get(Object object, int methodIndex) {
if (methodIndex == 0) {
return ((BStrPriv) object).getValue();
}
return null;
}
@Override
public void set(Object object, String methodIndex, Object value) {
if (methodIndex.equals("value")) {
if (value != null)
value = value.toString();
((BStrPriv) object).setValue((String) value);
return;
}
}
@Override
public Object get(Object object, String methodIndex) {
if (methodIndex.equals("value")) {
return ((BStrPriv) object).getValue();
}
return null;
}
@Override
public Object newInstance() {
return new BStrPriv();
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BStrPub.java 0000664 0000000 0000000 00000000116 12556201627 0027675 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BStrPub {
public String value;
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BStrPubAc.java 0000664 0000000 0000000 00000001723 12556201627 0030146 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
import net.minidev.asm.BeansAccess;
@SuppressWarnings("rawtypes")
public class BStrPubAc extends BeansAccess {
@Override
public void set(Object object, int methodIndex, Object value) {
if (methodIndex == 0) {
if (value != null)
value = value.toString();
((BStrPub)object).value = (String) value;
return;
}
}
@Override
public Object get(Object object, int methodIndex) {
if (methodIndex == 0) {
return ((BStrPub)object).value;
}
return null;
}
@Override
public void set(Object object, String methodIndex, Object value) {
if (methodIndex.equals("value")) {
if (value != null)
value = value.toString();
((BStrPub) object).value = (String) value;
return;
}
}
@Override
public Object get(Object object, String methodIndex) {
if (methodIndex.equals("value")) {
return ((BStrPub) object).value;
}
return null;
}
@Override
public BStrPub newInstance() {
return new BStrPub();
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/BTest.java 0000664 0000000 0000000 00000001336 12556201627 0027402 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public class BTest {
public int pubIntValue;
public String pubStrValue;
private int privIntValue;
private String privStrValue;
public boolean pubBoolValue;
public Integer pubIntegerValue;
public TEnum pubTEnum;
public void setPrivIntValue(int privIntValue) {
this.privIntValue = privIntValue;
}
public int getPrivIntValue() {
return privIntValue;
}
public void setPrivStrValue(String privStrValue) {
this.privStrValue = privStrValue;
}
public String getPrivStrValue() {
return privStrValue;
}
public String toString() {
return "Public(i:" + pubIntValue + " s:" + pubStrValue + "B: " + pubBoolValue + ") Private(i:" + privIntValue
+ " s:" + privStrValue + ")";
}
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/TEnum.java 0000664 0000000 0000000 00000000101 12556201627 0027376 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
public enum TEnum {
V1, V2, V3
}
json-smart-v2-2.2/accessors-smart/src/test/java/net/minidev/asm/bean/TestAsmAtom.java 0000664 0000000 0000000 00000005354 12556201627 0030566 0 ustar 00root root 0000000 0000000 package net.minidev.asm.bean;
import junit.framework.TestCase;
import net.minidev.asm.BeansAccess;
public class TestAsmAtom extends TestCase {
public void testpub() throws Exception {
// int fieldID = 0;
String fieldID = "value";
{
BeansAccess ac = BeansAccess.get(BStrPub.class);
BStrPub p = ac.newInstance();
String val = "toto";
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BLongPub.class);
BLongPub p = ac.newInstance();
Long val = 123L;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BBooleanPub.class);
BBooleanPub p = ac.newInstance();
Boolean val = Boolean.TRUE;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BBoolPub.class);
BBoolPub p = ac.newInstance();
Boolean val = Boolean.TRUE;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BEnumPriv.class);
BEnumPriv p = ac.newInstance();
TEnum val = TEnum.V2;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BObjectPriv.class);
BObjectPriv p = ac.newInstance();
TEnum val = TEnum.V2;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
}
public void testPriv() throws Exception {
// int fieldID = 0;
String fieldID = "value";
{
BeansAccess ac = BeansAccess.get(BStrPriv.class);
BStrPriv p = ac.newInstance();
String val = "toto";
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BLongPriv.class);
BLongPriv p = ac.newInstance();
Long val = 123L;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BBooleanPriv.class);
BBooleanPriv p = ac.newInstance();
Boolean val = Boolean.TRUE;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BBoolPriv.class);
BBoolPriv p = ac.newInstance();
Boolean val = Boolean.TRUE;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BEnumPub.class);
BEnumPub p = ac.newInstance();
TEnum val = TEnum.V2;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
{
BeansAccess ac = BeansAccess.get(BObjectPub.class);
BObjectPub p = ac.newInstance();
TEnum val = TEnum.V2;
ac.set(p, fieldID, val);
assertEquals(val, ac.get(p, fieldID));
}
}
} json-smart-v2-2.2/json-smart-backport/ 0000775 0000000 0000000 00000000000 12556201627 0017705 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/json-smart-backport/pom.xml 0000664 0000000 0000000 00000003041 12556201627 0021220 0 ustar 00root root 0000000 0000000 4.0.0json-smart-backportbundle2.1.1net.minidevparent2.1.0../parent/pom.xmlJson smart Back PortContains Backported port from versions before 2.1.0 junitjunittestnet.minidevjson-smartorg.apache.felixmaven-bundle-plugin2.3.7true${project.groupId}.${project.artifactId}${project.artifactId}${project.version}net.minidev.json.mapper
json-smart-v2-2.2/json-smart/ 0000775 0000000 0000000 00000000000 12556201627 0016102 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/json-smart/ChangeLog.txt 0000664 0000000 0000000 00000000326 12556201627 0020473 0 ustar 00root root 0000000 0000000 Version 1.0.4 (2011/05/02)
* First Public version
Version 1.0.4-1 (2011/05/03)
* Performance Improvement
Version 1.0.4-2 (2011/05/06)
* add support for non protected string starting with digits.
* add Junit tests
json-smart-v2-2.2/json-smart/LICENSE.txt 0000664 0000000 0000000 00000026135 12556201627 0017734 0 ustar 00root root 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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. json-smart-v2-2.2/json-smart/pom.xml 0000664 0000000 0000000 00000004413 12556201627 0017421 0 ustar 00root root 0000000 0000000 4.0.0json-smartbundlenet.minidevminidev-parent2.2../parent/pom.xmlJSON Small and Fast Parser
JSON (JavaScript Object Notation) is a lightweight data-interchange format.
It is easy for humans to read and write. It is easy for machines to parse and generate.
It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition
- December 1999. JSON is a text format that is completely language independent but uses
conventions that are familiar to programmers of the C-family of languages, including C, C++, C#,
Java, JavaScript, Perl, Python, and many others.
These properties make JSON an ideal data-interchange language.
junitjunittestnet.minidevaccessors-smartorg.apache.felixmaven-bundle-plugin2.3.7true${project.groupId}.${project.artifactId}${project.artifactId}${project.version}
net.minidev.json,
net.minidev.json.annotate,
net.minidev.json.parser,
net.minidev.json.reader,
net.minidev.json.writer
accessors-smart;groupId=net.minidev;inline=true
json-smart-v2-2.2/json-smart/readme.txt 0000664 0000000 0000000 00000000052 12556201627 0020075 0 ustar 00root root 0000000 0000000 @see:
http://code.google.com/p/json-smart/ json-smart-v2-2.2/json-smart/src/ 0000775 0000000 0000000 00000000000 12556201627 0016671 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/json-smart/src/main/ 0000775 0000000 0000000 00000000000 12556201627 0017615 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/json-smart/src/main/java/ 0000775 0000000 0000000 00000000000 12556201627 0020536 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/json-smart/src/main/java/net/ 0000775 0000000 0000000 00000000000 12556201627 0021324 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/json-smart/src/main/java/net/minidev/ 0000775 0000000 0000000 00000000000 12556201627 0022757 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/json-smart/src/main/java/net/minidev/json/ 0000775 0000000 0000000 00000000000 12556201627 0023730 5 ustar 00root root 0000000 0000000 json-smart-v2-2.2/json-smart/src/main/java/net/minidev/json/JSONArray.java 0000664 0000000 0000000 00000006615 12556201627 0026353 0 ustar 00root root 0000000 0000000 package net.minidev.json;
/*
* Copyright 2011 JSON-SMART authors
*
* 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.
*/
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.minidev.json.reader.JsonWriter;
/**
* A JSON array. JSONObject supports java.util.List interface.
*
* @author FangYidong
* @author Uriel Chemouni
*/
public class JSONArray extends ArrayList