| 1 | |
package org.webslinger.resolver; |
| 2 | |
|
| 3 | |
import org.webslinger.io.Charsets; |
| 4 | |
import org.webslinger.io.IOUtil; |
| 5 | |
|
| 6 | |
public abstract class BasicTypeResolver<T> implements ObjectResolver<T> { |
| 7 | 25 | protected BasicTypeResolver() { |
| 8 | 25 | } |
| 9 | |
|
| 10 | |
public boolean contains(T object, String name) { |
| 11 | 0 | return false; |
| 12 | |
} |
| 13 | |
|
| 14 | |
public Object get(T object, String name) { |
| 15 | 0 | return null; |
| 16 | |
} |
| 17 | |
|
| 18 | |
public void set(T object, String name, Object value) { |
| 19 | 0 | } |
| 20 | |
|
| 21 | |
public String[] list(T object) { |
| 22 | 0 | return null; |
| 23 | |
} |
| 24 | |
|
| 25 | |
public boolean hasChildren(T object) { |
| 26 | 0 | return false; |
| 27 | |
} |
| 28 | |
|
| 29 | |
public Class getType(T object, String name) { |
| 30 | 0 | return String.class; |
| 31 | |
} |
| 32 | |
|
| 33 | |
public char[] getChars(T object) throws Exception { |
| 34 | 57 | return getString(object).toCharArray(); |
| 35 | |
} |
| 36 | |
|
| 37 | |
public T newObject(Class<? extends T> wantedType, char[] chars, int offset, int length) throws Exception { |
| 38 | 839 | return newObject(wantedType, new String(chars, offset, length)); |
| 39 | |
} |
| 40 | |
|
| 41 | |
protected abstract String getString(T object); |
| 42 | |
protected abstract T newObject(Class<? extends T> wantedType, String value) throws Exception; |
| 43 | |
|
| 44 | 49 | public abstract static class BasicTypeResolverInfo<T> implements ObjectResolverInfo<T>, ObjectCreatorInfo<T> { |
| 45 | |
public ObjectCreator<T> getCreator() { |
| 46 | 24 | return getResolver(); |
| 47 | |
} |
| 48 | |
} |
| 49 | |
} |