本文整理汇总了Java中org.json.simple.parser.ContentHandler类的典型用法代码示例。如果您正苦于以下问题:Java ContentHandler类的具体用法?Java ContentHandler怎么用?Java ContentHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentHandler类属于org.json.simple.parser包,在下文中一共展示了ContentHandler类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromJson
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
public VPackSlice fromJson(final String json, final boolean includeNullValues) throws VPackException {
final VPackBuilder builder = new VPackBuilder();
final JSONParser parser = new JSONParser();
final ContentHandler contentHandler = new VPackContentHandler(builder, includeNullValues, this);
try {
parser.parse(json, contentHandler);
} catch (final ParseException e) {
throw new VPackBuilderException(e);
}
return builder.slice();
}
示例2: getContentHandler
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
protected ContentHandler getContentHandler() {
return new BaseContentHandler() {
public boolean primitive(Object value) throws ParseException, IOException {
String key = (String) objects.peek();
if ("text".equals(key)) {
query = (String) value;
} else if ("id".equals(key)) {
String parentKey = (String) objects.elementAt(objects.size() - 2);
if ("persons".equals(parentKey)) {
persons++;
} else if ("texts".equals(parentKey)) {
texts++;
} else if ("books".equals(parentKey)) {
books++;
} else if ("series".equals(parentKey)) {
series++;
} else if ("sequences".equals(parentKey)) {
sequences++;
} else if ("labels".equals(parentKey)) {
labels++;
} else if ("categories".equals(parentKey)) {
categories++;
}
}
return true;
}
};
}
示例3: getContentHandler
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
protected ContentHandler getContentHandler() {
return new BaseContentHandler() {
public boolean endArray() throws ParseException, IOException {
return !SERIES_KEY.equals(getParentKey());
}
public boolean startObject() throws ParseException, IOException {
if (SERIES_KEY.equals(getParentKey())) {
series.add(new Serie());
}
return true;
}
public boolean primitive(Object value) throws ParseException, IOException {
String key = (String) objects.peek();
if ("slug".equals(key)) {
if (SERIES_KEY.equals(getParentKey(2))) {
getLast().setSlug((String) value);
}
} else if ("name".equals(key)) {
if (SERIES_KEY.equals(getParentKey(2))) {
getLast().setName((String) value);
}
}
return true;
}
};
}
示例4: getContentHandler
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
protected ContentHandler getContentHandler() {
return new BaseContentHandler() {
public boolean endArray() throws ParseException, IOException {
return !TEXTS_KEY.equals(getParentKey());
}
public boolean startObject() throws ParseException, IOException {
if (TEXTS_KEY.equals(getParentKey())) {
texts.add(new Text());
}
return true;
}
public boolean primitive(Object value) throws ParseException, IOException {
String key = (String) objects.peek();
if ("id".equals(key)) {
if (TEXTS_KEY.equals(getParentKey(2))) {
getLast().setId(((Long) value).intValue());
}
} else if ("title".equals(key)) {
if (TEXTS_KEY.equals(getParentKey(2))) {
getLast().setTitle((String) value);
}
}
return true;
}
};
}
示例5: getContentHandler
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
protected ContentHandler getContentHandler() {
return new BaseContentHandler() {
public boolean endArray() throws ParseException, IOException {
return !SEQUENCES_KEY.equals(getParentKey());
}
public boolean startObject() throws ParseException, IOException {
if (SEQUENCES_KEY.equals(getParentKey())) {
sequences.add(new Sequence());
}
return true;
}
public boolean primitive(Object value) throws ParseException, IOException {
String key = (String) objects.peek();
if ("slug".equals(key)) {
if (SEQUENCES_KEY.equals(getParentKey(2))) {
getLast().setSlug((String) value);
}
} else if ("name".equals(key)) {
if (SEQUENCES_KEY.equals(getParentKey(2))) {
getLast().setName((String) value);
}
} else if ("nrOfBooks".equals(key)) {
if (SEQUENCES_KEY.equals(getParentKey(2))) {
getLast().setNumberOfBooks(((Long) value).intValue());
}
}
return true;
}
};
}
示例6: getContentHandler
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
protected ContentHandler getContentHandler() {
return new BaseContentHandler() {
public boolean endArray() throws ParseException, IOException {
return !LABELS_KEY.equals(getParentKey());
}
public boolean startObject() throws ParseException, IOException {
if (LABELS_KEY.equals(getParentKey())) {
labels.add(new Label());
}
return true;
}
public boolean primitive(Object value) throws ParseException, IOException {
String key = (String) objects.peek();
if ("slug".equals(key)) {
if (LABELS_KEY.equals(getParentKey(2))) {
getLast().setSlug((String) value);
}
} else if ("name".equals(key)) {
if (LABELS_KEY.equals(getParentKey(2))) {
getLast().setName((String) value);
}
} else if ("nrOfTexts".equals(key)) {
if (LABELS_KEY.equals(getParentKey(2))) {
getLast().setNumberOfTexts(((Long) value).intValue());
}
}
return true;
}
};
}
示例7: getContentHandler
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
protected ContentHandler getContentHandler() {
return new BaseContentHandler() {
public boolean endArray() throws ParseException, IOException {
return !CATEGORIES_KEY.equals(getParentKey());
}
public boolean startObject() throws ParseException, IOException {
if (CATEGORIES_KEY.equals(getParentKey())) {
categories.add(new Category());
}
return true;
}
public boolean primitive(Object value) throws ParseException, IOException {
String key = (String) objects.peek();
if ("slug".equals(key)) {
if (CATEGORIES_KEY.equals(getParentKey(2))) {
getLast().setSlug((String) value);
}
} else if ("name".equals(key)) {
if (CATEGORIES_KEY.equals(getParentKey(2))) {
getLast().setName((String) value);
}
} else if ("nrOfBooks".equals(key)) {
if (CATEGORIES_KEY.equals(getParentKey(2))) {
getLast().setNumberOfBooks(((Long) value).intValue());
}
}
return true;
}
};
}
示例8: getContentHandler
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
protected ContentHandler getContentHandler() {
return new BaseContentHandler() {
public boolean endArray() throws ParseException, IOException {
return !PERSONS_KEY.equals(getParentKey());
}
public boolean startObject() throws ParseException, IOException {
if (PERSONS_KEY.equals(getParentKey())) {
persons.add(new Person());
}
return true;
}
public boolean primitive(Object value) throws ParseException, IOException {
String key = (String) objects.peek();
if ("slug".equals(key)) {
if (PERSONS_KEY.equals(getParentKey(2))) {
getLast().setSlug((String) value);
}
} else if ("name".equals(key)) {
if (PERSONS_KEY.equals(getParentKey(2))) {
getLast().setName((String) value);
}
} else if ("isAuthor".equals(key)) {
if (PERSONS_KEY.equals(getParentKey(2))) {
getLast().setAuthor(((Boolean) value).booleanValue());
}
}
return true;
}
};
}
示例9: handleSubs
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
public void handleSubs(boolean unread, int fromId, int limit, ContentHandler handler)
throws IOException, ParseException, ReaderException {
new JSONParser().parse(readSubs(unread, fromId, limit), handler);
}
示例10: handleAll
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
public void handleAll(long subId, int offset, int limit, ContentHandler handler)
throws IOException, ParseException, ReaderException {
new JSONParser().parse(readAll(subId, offset, limit), handler);
}
示例11: handleUnread
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
public void handleUnread(long subId, ContentHandler handler)
throws IOException, ParseException, ReaderException {
new JSONParser().parse(readUnread(subId), handler);
}
示例12: handlePinAll
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
public void handlePinAll(ContentHandler handler)
throws IOException, ParseException, ReaderException {
new JSONParser().parse(readPinAll(), handler);
}
示例13: getContentHandler
import org.json.simple.parser.ContentHandler; //导入依赖的package包/类
protected abstract ContentHandler getContentHandler();