/*
 * Copyright 2013 Takao Nakaguchi.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jsonman;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import net.arnx.jsonic.JSON;

import org.jsonman.node.ArrayNode;
import org.jsonman.node.BooleanNode;
import org.jsonman.node.MapNode;
import org.jsonman.node.NumberNode;
import org.jsonman.node.StringNode;

public class NodeFactory {
	@SuppressWarnings("unchecked")
	public static Node create(Object value){
		if(value == null){
			return new StringNode(null);
		} else if(value instanceof Node){
			return (Node)value;
		} else if(value instanceof List){
			return new ArrayNode((List<Object>)value);
		} else if(value instanceof Map){
			return new MapNode((Map<String, Object>)value);
		} else if(value instanceof Number){
			return new NumberNode((Number)value);
		} else if(value instanceof String){
			return new StringNode((String)value);
		} else if(value instanceof Boolean){
			return new BooleanNode((Boolean)value);
		} else if(value.getClass().isArray()){
			return new ArrayNode(Arrays.asList((Object[])value));
		} else{
			throw new IllegalArgumentException("No suitable node class for " + value.getClass());
		}
	}

	public static Node create(InputStream is) throws IOException{
		return create(JSON.decode(is));
	}
}

@@ -619,64 +619,8 @@
 n;%0A%0A
-import java.io.IOException;%0Aimport java.io.InputStream;%0A
 impo
@@ -690,38 +690,8 @@
 p;%0A%0A
-import net.arnx.jsonic.JSON;%0A%0A
 impo
@@ -1692,108 +1692,7 @@
 %7D%0A%09%7D
-%0A%0A%09public static Node create(InputStream is) throws IOException%7B%0A%09%09return create(JSON.decode(is));%0A%09%7D
 %0A%7D%0A

remove method create(InputStream) to avoid dependency to Jsonic.