for (Field eachField : eachClass.getFields())\r
{\r
int fieldModifier = eachField.getModifiers();\r
- if (Modifier.isPublic(fieldModifier) || !Modifier.isTransient(fieldModifier))\r
+ if (Modifier.isPublic(fieldModifier) && !Modifier.isTransient(fieldModifier))\r
{\r
Class< ? > fieldType = eachField.getType();\r
String paramName = getCanonicalParameterName(eachField.getName());\r
{\r
// relation adder\r
Pair<String, String> relName = pickRelationName(paramPart);\r
+ if (relName == null)\r
+ {\r
+ // infer relation node names\r
+ relName = new Pair<String, String>(argTypes[0].getSimpleName(), argTypes[1].getSimpleName());\r
+ }\r
+\r
relationSetterContainer.add(RelationSetter.newRelationSetter(relName.getFirst(), relName\r
.getSecond(), eachMethod));\r
break;\r
import org.xerial.relation.schema.SchemaBuilder;
import org.xerial.util.ArrayDeque;
import org.xerial.util.Deque;
+import org.xerial.util.bean.TypeConverter;
import org.xerial.util.bean.TypeInfo;
import org.xerial.util.log.Logger;
import org.xerial.util.tree.TreeWalker;
if (TypeInfo.isBasicType(nodeType))
{
- instance = node.nodeValue;
+ instance = TypeConverter.convertToBasicType(nodeType, node.nodeValue);
}
else
{
final QuerySet query;
final AmoebaJoinHandler handler;
+ private final static String EMPTY_NODE_NAME = "";
+
// for running amoeba join
- long nodeCount = -1;
- Lattice<String> nodeNameLattice = new Lattice<String>();
- LatticeCursor<String> latticeCursor;
+ private long nodeCount = -1;
+ private Lattice<String> nodeNameLattice = new Lattice<String>();
+ private LatticeCursor<String> latticeCursor;
- Deque<String> currentPath = new ArrayDeque<String>();
- Deque<LatticeNode<String>> stateStack = new ArrayDeque<LatticeNode<String>>();
+ private Deque<String> currentPath = new ArrayDeque<String>();
+ private Deque<LatticeNode<String>> stateStack = new ArrayDeque<LatticeNode<String>>();
// HashedChainMap<String, XMLNode> nodeStackOfEachTag = new HashedChainMap<String, XMLNode>();
- HashedDeque<String, Node> nodeStackOfEachTag = new HashedDeque<String, Node>();
+ private HashedDeque<String, Node> nodeStackOfEachTag = new HashedDeque<String, Node>();
- HashMap<Edge, List<Operation>> operationSetOnForward = new HashMap<Edge, List<Operation>>();
- HashMap<Edge, List<Operation>> operationSetOnBack = new HashMap<Edge, List<Operation>>();
- HashMap<Edge, List<TextOperation>> operatSetOnText = new HashMap<Edge, List<TextOperation>>();
+ private HashMap<Edge, List<Operation>> operationSetOnForward = new HashMap<Edge, List<Operation>>();
+ private HashMap<Edge, List<Operation>> operationSetOnBack = new HashMap<Edge, List<Operation>>();
+ private HashMap<Edge, List<TextOperation>> operatSetOnText = new HashMap<Edge, List<TextOperation>>();
public StreamAmoebaJoin(QuerySet query, AmoebaJoinHandler handler) throws IOException
{
forward(currentNode);
- currentPath.addLast(nodeName);
+ currentPath.addLast(nodeName != null ? nodeName : EMPTY_NODE_NAME);
// for tree nodes
if (query.isTreeNode(nodeName))
import org.xerial.json.JSONArray;\r
import org.xerial.json.JSONBoolean;\r
import org.xerial.json.JSONDouble;\r
-import org.xerial.json.JSONException;\r
import org.xerial.json.JSONInteger;\r
import org.xerial.json.JSONLong;\r
import org.xerial.json.JSONObject;\r
* a bean class\r
* @param jsonData\r
* a string representation of a JSON data\r
+ * @throws IOException\r
* @throws InvalidJSONDataException\r
* when the input json data is invalid (cannot interpret as a\r
* JSON object)\r
// parse the input JSON data\r
try\r
{\r
- JSONObject inputJson = new JSONObject(jsonData);\r
- populateBean(bean, inputJson);\r
+ populateBeanWithJSON(bean, new StringReader(jsonData));\r
}\r
- catch (JSONException e)\r
+ catch (IOException e)\r
{\r
- throw new BeanException(BeanErrorCode.InvalidJSONData, e);\r
+ throw new BeanException(BeanErrorCode.IOError, e);\r
}\r
+\r
}\r
\r
/**\r
import org.antlr.runtime.tree.Tree;
import org.w3c.dom.Element;
import org.xerial.core.XerialException;
+import org.xerial.lens.ObjectMapper;
import org.xerial.silk.SilkWalker;
import org.xerial.util.bean.ANTLRWalker;
import org.xerial.util.bean.JSONStreamWalker;
*/
protected static <E> E createTypedBean(TreeWalker treeWalker, Class<E> beanType) throws XerialException
{
- return beanType.cast(createBean(treeWalker, new BeanBindingProcess(beanType)));
+ //return beanType.cast(createBean(treeWalker, new BeanBindingProcess(beanType)));
+ return new ObjectMapper().map(beanType, treeWalker);
}
/**
*/
protected static Object createBean(TreeWalker treeWalker, Object bean) throws XerialException
{
- return createBean(treeWalker, new BeanBindingProcess(bean));
+ //return createBean(treeWalker, new BeanBindingProcess(bean));
+ return new ObjectMapper().map(bean, treeWalker);
}
protected static Object createBean(TreeWalker treeWalker, BeanBindingProcess beanBindingVisitor)
}
@Test
- public void populate() throws JSONException, BeanException
+ public void populate() throws JSONException, BeanException, IOException
{
Person s = new Person(10, "leo");
Person s2 = new Person();
}
@Test
- public void populateArray() throws JSONException, BeanException
+ public void populateArray() throws JSONException, BeanException, IOException
{
Book s1 = new Book("Data on the Web", new String[] { "Abiteboul", "Buneman" });
Book s2 = new Book();
}
@Test
- public void doNotUsePrivateSetter() throws JSONException, BeanException
+ public void doNotUsePrivateSetter() throws JSONException, BeanException, IOException
{
PrivateGetterSetter p = new PrivateGetterSetter(0.0);
BeanUtil.populateBeanWithJSON(p, "{\"value\" : 1.34}");
}
@Test
- public void beanWithCollectionParameters() throws BeanException
+ public void beanWithCollectionParameters() throws BeanException, IOException
{
String[] name = { "taro", "leo" };
Vector<String> v = new Vector<String>();