Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2014,2015 Ahome' Innovation Technologies. All rights reserved.
*
* 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 com.ait.tooling.json;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import com.ait.tooling.common.api.json.JSONObjectDefinition;
import com.ait.tooling.common.api.json.JSONType;
public class JSONObject extends LinkedHashMap implements JSONObjectDefinition, IJSONStreamAware
{
private static final long serialVersionUID = -6811236788038367702L;
public JSONObject()
{
}
public JSONObject(Map map)
{
putAll(Objects.requireNonNull(map));
}
public JSONObject(final List> list)
{
put("list", Objects.requireNonNull(list));
}
public JSONObject(final String name, final Object value)
{
put(Objects.requireNonNull(name), value);
}
public void dumpClassNames(final PrintWriter out)
{
Objects.requireNonNull(out);
for (String key : keys())
{
final Object o = get(key);
if (null == o)
{
out.println("JSONObject[" + key + "]=null");
}
else
{
out.println("JSONObject[" + key + "]=" + o.getClass().getName());
}
}
}
public void dumpClassNames(final PrintStream out)
{
Objects.requireNonNull(out);
for (String key : keys())
{
final Object o = get(key);
if (null == o)
{
out.println("JSONObject[" + key + "]=null");
}
else
{
out.println("JSONObject[" + key + "]=" + o.getClass().getName());
}
}
}
@SuppressWarnings("unchecked")
public JSONObject accumulate(final String ikey, final Object value)
{
final String name = Objects.requireNonNull(ikey);
final Object found = get(name);
if (null == found)
{
put(name, value);
}
else if (found instanceof List)
{
((List