当前位置: 首页>>代码示例>>Java>>正文


Java Event.KEY_NAME属性代码示例

本文整理汇总了Java中javax.json.stream.JsonParser.Event.KEY_NAME属性的典型用法代码示例。如果您正苦于以下问题:Java Event.KEY_NAME属性的具体用法?Java Event.KEY_NAME怎么用?Java Event.KEY_NAME使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.json.stream.JsonParser.Event的用法示例。


在下文中一共展示了Event.KEY_NAME属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interpretConstraints

@Override
protected void interpretConstraints(String constraints) {
	JsonParser parser = Json.createParser(new StringReader(constraints));
	while (parser.hasNext()) {
		Event e = parser.next();
		if (e == Event.KEY_NAME)
			if (parser.getString().equalsIgnoreCase("constraint")) {
				parser.next();
				if (parser.getString().equalsIgnoreCase("AssertTrue")) {
					setAssertTrue(true); 
					break;
				}
				else if (parser.getString().equalsIgnoreCase("AssertFalse")) {
					setAssertFalse(true);
					break;
				}
			}
	}
}
 
开发者ID:relvaner,项目名称:tools4j-validator,代码行数:19,代码来源:BooleanValidator.java

示例2: interpretConstraints

@Override
protected void interpretConstraints(String constraints) {
	super.interpretConstraints(constraints);
	
	JsonParser parser = Json.createParser(new StringReader(constraints));
	while (parser.hasNext()) {
		 Event e = parser.next();
		 if (e == Event.KEY_NAME)
			 if (parser.getString().equalsIgnoreCase("constraint")) {
				 parser.next();
				 if (parser.getString().equalsIgnoreCase("List")) {
					 parser.next();
					 
					 pickList = new HashSet<>();
					 while (parser.hasNext()) {
						 Event item = parser.next();
						 if (item == Event.VALUE_STRING)
							 pickList.add(parser.getString());
					 }
				 }
		 }
	}
	parser.close();
}
 
开发者ID:relvaner,项目名称:tools4j-validator,代码行数:24,代码来源:PickListValidator.java

示例3: interpretConstraints

@Override
protected void interpretConstraints(String constraints) {
	JsonParser parser = Json.createParser(new StringReader(constraints));
	while (parser.hasNext()) {
		 Event e = parser.next();
		 if (e == Event.KEY_NAME)
			 if (parser.getString().equalsIgnoreCase("constraint")) {
				 parser.next();
				 if (parser.getString().equalsIgnoreCase("Pattern")) {
					 parser.next();
					 parser.next();
					 setPattern(parser.getString());
				 } else if (parser.getString().equalsIgnoreCase("Valid")) {
					 setValid(true);
				 } else if (parser.getString().equalsIgnoreCase("Past")) {
					 setPast(true);
				 } else if (parser.getString().equalsIgnoreCase("Future")) {
					 setFuture(true);
				 }
			 }
	}
	parser.close();
}
 
开发者ID:relvaner,项目名称:tools4j-validator,代码行数:23,代码来源:DateValidator.java

示例4: testLargeCstring

@Test
public void testLargeCstring () throws IOException
{
	int length = 0;
	BsonParser p = new BsonParser (new FileInputStream ("../tests/data/largecstring.bson".replace ('/', File.separatorChar)));
	while (p.hasNext ())
	{
		Event e = p.next ();
		if (e == Event.KEY_NAME)
			length = p.getString ().length ();
	}
	p.close ();
	Assert.assertEquals (8554, length);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:14,代码来源:BsonParserTest.java

示例5: setConstraints

public void setConstraints(String constraints) {
	this.constraints = constraints;

	notNull        = false;
	Null           = false;
	businessRuleID = null;
	
	JsonParser parser = Json.createParser(new StringReader(constraints));
	while (parser.hasNext()) {
		 Event e = parser.next();
		 if (e == Event.KEY_NAME)
			 if (parser.getString().equalsIgnoreCase("constraint")) {
				 parser.next();
				 if (parser.getString().equalsIgnoreCase("NotNull")) {
					 setNotNull(true);
				 } else if (parser.getString().equalsIgnoreCase("Null")) {
					 setNull(true);
				 } else if (parser.getString().equalsIgnoreCase("Rule")) {
					 parser.next();
					 parser.next();
					 setBusinessRuleID(parser.getString());
				 }
		 }
	}
	parser.close();
	
	interpretConstraints(constraints);
}
 
开发者ID:relvaner,项目名称:tools4j-validator,代码行数:28,代码来源:Validator.java

示例6: parseType

public static String parseType(String json) {
	JsonParser parser = Json.createParser(new StringReader(json));
	while (parser.hasNext()) {
		 Event e = parser.next();
		 if (e == Event.KEY_NAME)
			 if (parser.getString().equalsIgnoreCase("type")) {
				 parser.next();
				 return parser.getString();
			 }
	}
	parser.close();
	
	return null;
}
 
开发者ID:relvaner,项目名称:tools4j-validator,代码行数:14,代码来源:ValidatorFactory.java

示例7: run

@Override
public void run() {
    
    BufferedReader in;
    String jsonLine;
    String key;
    JsonParser parser;
    
    try {
        /* Connect to the traffic EIS */
        int port = Integer.parseInt(spec.getPort());
        log.info("[TrafficServiceSubscriber] Connecting...");
        socket = new Socket("localhost", port);
        in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        log.info("[TrafficServiceSubscriber] Connected");

        while (listen) {
            jsonLine = in.readLine();
            parser = Json.createParser(new StringReader(jsonLine));
            if (parser.hasNext() && parser.next() == Event.START_OBJECT &&
                parser.hasNext() && parser.next() == Event.KEY_NAME) {
                
                key = parser.getString();
                /* Does the MDB support this message? */
                if (spec.getCommands().containsKey(key)) {
                    Method mdbMethod = spec.getCommands().get(key);
                    /* Invoke the method of the MDB */
                    callMdb(mdb, mdbMethod, jsonLine);
                } else
                    log.info("[TrafficServerSubscriber] Unknown message");
            } else
                log.info("[TrafficServiceSubscriber] Wrong message format");
            
        }
    } catch (IOException | ResourceException ex) {
        log.log(Level.INFO, "[TrafficServiceSubscriber] Error - {0}", ex.getMessage());
    }
}
 
开发者ID:osmanpub,项目名称:oracle-samples,代码行数:38,代码来源:TrafficServiceSubscriber.java

示例8: parse

public boolean parse(String key, JsonParser parser) throws IOException, SAXException {
	Event event = parser.next();
	if (event.equals(Event.START_OBJECT)) {
		startElement("map", key);
		while ((event = parser.next())!=Event.END_OBJECT) {
			if (event!=Event.KEY_NAME) {
				throw new SAXException("expected key name at "+parser.getLocation());
			}
			key=parser.getString();
			parse(key,parser);
		};
		endElement("map");
	} else if (event==Event.END_ARRAY) {
		return false;
	} else if (event==Event.START_ARRAY) {
		startElement("array", key);
		while (parse(null,parser)); // parse array elements until the close
		endElement("array");
	} else {
		if (event==Event.VALUE_NULL) {
			simpleElement("null", key, null);
		} else {
			if (event==Event.VALUE_FALSE) {
				simpleElement("boolean", key, "false");
			} else {
				if (event==Event.VALUE_TRUE) {
					simpleElement("boolean", key, "true");
				} else {
					String value =parser.getString();
					if (event==Event.VALUE_NUMBER) {
						simpleElement("number", key, value);
					} else {
						simpleElement("string", key, value);
					}
				}
			}
		}
	}
	return true;
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:40,代码来源:JsonXmlReader.java

示例9: writeComma

private static void writeComma(Event prev, OutputStream out) throws IOException {
    if (prev != Event.START_ARRAY && prev != Event.START_OBJECT && prev != Event.KEY_NAME) {
        out.write(", ".getBytes());
    }
}
 
开发者ID:qntfy,项目名称:nifi-redis,代码行数:5,代码来源:StreamingJSONAppender.java

示例10: processEvent

private void processEvent(ParserContext ctx, JsonParser parser) throws BagriException { //, XMLStreamException {

		JsonParser.Event event = parser.next();
		if (event == Event.VALUE_STRING || event == Event.VALUE_NUMBER) {
			logger.trace("processEvent; got token: {}; value: {}", event.name(), parser.getString());
		} else if (event == Event.KEY_NAME) {
			logger.trace("processEvent; got token: {}; key: {}", event.name(), parser.getString());
		} else {
			logger.trace("processEvent; got token: {}", event.name()); 
		}
		
		switch (event) {
			case START_OBJECT:
				if (ctx.getTopData() == null) {
					ctx.addDocument("/");
				} else {
					ctx.addElement();
				}
				break;
			case START_ARRAY: 
				ctx.addArray();
				break;
			case KEY_NAME:
				ctx.addData(parser.getString());
				break;
			case END_ARRAY: 
			case END_OBJECT:
				ctx.endElement();
				break;
			case VALUE_FALSE:
				ctx.addValue(false);
				break;
			case VALUE_TRUE:
				ctx.addValue(true);
				break;
			case VALUE_NULL:
				ctx.addValue();
				break;
			case VALUE_NUMBER:
				if (parser.isIntegralNumber()) {
					ctx.addValue(parser.getLong());
				} else {
					ctx.addValue(parser.getBigDecimal());
				}
				break;
			case VALUE_STRING:
				ctx.addValue(parser.getString());
				break;
			default: 
				logger.trace("processEvent; unknown event: {}", event);
		}			
	}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:52,代码来源:JsonpParser.java

示例11: interpretConstraints

@Override
protected void interpretConstraints(String constraints) {
	JsonParser parser = Json.createParser(new StringReader(constraints));
	while (parser.hasNext()) {
		 Event e = parser.next();
		 if (e == Event.KEY_NAME)
			 if (parser.getString().equalsIgnoreCase("constraint")) {
				 parser.next();
				 if (parser.getString().equalsIgnoreCase("Pattern")) {
					 parser.next();
					 parser.next();
					 setPattern(parser.getString());
				 }
				 else if (parser.getString().equalsIgnoreCase("NotEmpty")) {
					 setNotEmpty(true);
				 }
				 else if (parser.getString().equalsIgnoreCase("Empty")) {
					 setEmpty(true);
				 }
				 else if (parser.getString().equalsIgnoreCase("Min")) {
					 parser.next();
					 parser.next();
					 setMin(parser.getInt());
				 }
				 else if (parser.getString().equalsIgnoreCase("Max")) {
					 parser.next();
					 parser.next();
					 setMax(parser.getInt());
				 }
				 else if (parser.getString().equalsIgnoreCase("Size")) {
					 parser.next();
					 parser.next();
					 setMin(parser.getInt());
					 parser.next();
					 parser.next();
					 setMax(parser.getInt());
				 }
		 }
	}
	parser.close();
}
 
开发者ID:relvaner,项目名称:tools4j-validator,代码行数:41,代码来源:StringValidator.java

示例12: interpretConstraints

@Override
protected void interpretConstraints(String constraints) {
	JsonParser parser = Json.createParser(new StringReader(constraints));
	while (parser.hasNext()) {
		 Event e = parser.next();
		 if (e == Event.KEY_NAME)
			 if (parser.getString().equalsIgnoreCase("constraint")) {
				 parser.next();
				 if (parser.getString().equalsIgnoreCase("Min")) {
					 parser.next();
					 parser.next();
					 setMin(getNumber(parser.getBigDecimal()));
					 e = parser.next();
					 if (e != Event.END_OBJECT && parser.getString().equalsIgnoreCase("minIncluded")) {
						 parser.next();
						 setMinIncluded(parser.getInt()==1);
					 }
				 }
				 else if (parser.getString().equalsIgnoreCase("Max")) {
					 parser.next();
					 parser.next();
					 setMax(getNumber(parser.getBigDecimal()));
					 e = parser.next();
					 if (e != Event.END_OBJECT && parser.getString().equalsIgnoreCase("maxIncluded")) {
						 parser.next();
						 setMaxIncluded(parser.getInt()==1);
					 }
				 }
				 else if (parser.getString().equalsIgnoreCase("Range")) {
					 parser.next();
					 parser.next();
					 setMin(getNumber(parser.getBigDecimal()));
					 e = parser.next();
					 if (e != Event.END_OBJECT && parser.getString().equalsIgnoreCase("minIncluded")) {
						 parser.next();
						 setMinIncluded(parser.getInt()==1);
						 parser.next();
					 }
					 parser.next();
					 setMax(getNumber(parser.getBigDecimal()));
					 e = parser.next();
					 if (e != Event.END_OBJECT && parser.getString().equalsIgnoreCase("maxIncluded")) {
						 parser.next();
						 setMaxIncluded(parser.getInt()==1);
					 }
				 }
		 }
	}
	parser.close();
}
 
开发者ID:relvaner,项目名称:tools4j-validator,代码行数:50,代码来源:NumberValidator.java

示例13: run

public static void run(final File file) throws Exception {

        if (!Charset.defaultCharset().equals(Charset.forName("UTF-8"))) {
            throw new RuntimeException("Default charset is " + Charset.defaultCharset() + ", must be UTF-8");
        }

        if (!file.exists()) {
            System.out.println("ERROR -  " + file.getAbsolutePath() + " does not exist.");
            return;
        }

        CreateJsonTestFiles.create(null);

        System.out.println("Start benchmarking of " + file.getAbsolutePath());

        long start = 0;
        long end = 0;

        System.out.println("File created: " + new Date(file.lastModified()));
        System.out.println("Filesize: " + file.length() + " bytes");
        System.out.println("Filesize: " + (file.length() / (1024 * 1024)) + " mb");

        start = System.currentTimeMillis();
        final JsonParser parser = parserFactory.createParser((new FileInputStream(file)));
        long sevents = 0;
        long ievents = 0;
        long bevents = 0;

        while (parser.hasNext()) {
            final Event e = parser.next();

            if (e == null) {
                throw new RuntimeException("null event");
            }

            if (e == Event.KEY_NAME || e == Event.VALUE_STRING) {

                if (parser.getString() == null) {
                    throw new RuntimeException("null event");
                }

                sevents++;

            } else if (e == Event.VALUE_NUMBER) {

                if (parser.isIntegralNumber()) {
                    final long l = parser.getLong();
                    if (l == 12343) {
                        throw new RuntimeException("long event");
                    }
                    ievents++;

                } else {
                    final BigDecimal bd = parser.getBigDecimal();
                    if (bd == null) {
                        throw new RuntimeException("null event");
                    }
                    bevents++;
                }

            }

        }

        parser.close();
        end = System.currentTimeMillis();

        System.out.println("Duration: " + ((end - start)) + " ms");
        System.out.println("String Events: " + sevents);
        System.out.println("Integral Number Events: " + ievents);
        System.out.println("Big Decimal Events: " + bevents);
        System.out.println("Parsing speed: " + (file.length() / (end - start)) + " bytes/ms");
        System.out.println("Parsing speed: " + (file.length() / ((end - start) / 1000)) + " bytes/sec");
        System.out.println("Parsing speed: " + ((file.length() / 1024) / ((end - start) / 1000)) + " kbytes/sec");
        System.out.println("Parsing speed: " + ((file.length() / (1024 * 1024)) / ((end - start) / 1000)) + " mb/sec");
        System.out.println("Parsing speed: " + (((file.length() * 8) / (1024 * 1024)) / ((end - start) / 1000)) + " mbit/sec");

    }
 
开发者ID:salyh,项目名称:jsr353-benchmark,代码行数:78,代码来源:ParseHugeJsonFile.java


注:本文中的javax.json.stream.JsonParser.Event.KEY_NAME属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。