本文整理汇总了Java中org.mozilla.javascript.json.JsonParser.ParseException类的典型用法代码示例。如果您正苦于以下问题:Java ParseException类的具体用法?Java ParseException怎么用?Java ParseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseException类属于org.mozilla.javascript.json.JsonParser包,在下文中一共展示了ParseException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: lint
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
public LinkedList<JSHintError> lint(Document d) {
Context cx = Context.enter();
LinkedList<JSHintError> result = new LinkedList<>();
FileObject fo = NbEditorUtilities.getFileObject(d);
try {
Scriptable config = getConfig(cx, fo);
String code = d.getText(0, d.getLength());
result = lint(cx, code, config);
} catch (IOException | ParseException | BadLocationException ex) {
Exceptions.printStackTrace(ex);
} finally {
Context.exit();
}
return result;
}
开发者ID:luka-zitnik,项目名称:jshint-for-netbeans,代码行数:18,代码来源:JSHint.java
示例2: getConfig
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@NbBundle.Messages({
"LBL_InvalidRC=Invalid .jshintrc",
"# {0} - Linted JavaScript file",
"# {1} - RC file",
"DESC_InvalidRC=File {0} was linted with default configuration because its related {1} is not valid json",
"ICON_InvalidRC="
})
private Scriptable getConfig(Context cx, FileObject fo) throws ParseException, IOException {
JsonParser parser = new JsonParser(cx, scope);
FileObject config = findConfig(fo);
if (config == null) {
return cx.newObject(scope);
}
String json = config.asText();
try {
return (Scriptable) parser.parseValue(json);
}
catch (ParseException ex) {
JTextArea text = new JTextArea(Bundle.DESC_InvalidRC(fo.getPath(), config.getPath()));
NotificationDisplayer.getDefault().notify(Bundle.LBL_InvalidRC(), new ImageIcon(Bundle.ICON_InvalidRC()), text, text, NotificationDisplayer.Priority.NORMAL);
return cx.newObject(scope);
}
}
开发者ID:luka-zitnik,项目名称:jshint-for-netbeans,代码行数:27,代码来源:JSHint.java
示例3: putJson
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Override
public void putJson(final String varName, final String json) {
runWithContext(new RhinoCallable<Object, RuntimeException>() {
@Override
protected Object doCall(Context cx, Scriptable scope) throws RuntimeException {
try {
Object obj = new JsonParser(cx, scope).parseValue(json);
scope.put(varName, scope, obj);
return null;
} catch (ParseException e) {
throw Throwables.propagate(e);
}
}
});
}
开发者ID:viltgroup,项目名称:minium,代码行数:16,代码来源:RhinoEngine.java
示例4: coerce
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Override
public Object coerce(Object obj, Type type) {
Context cx = Context.enter();
try {
if (obj instanceof String) {
return new JsonParser(cx, cx.initStandardObjects()).parseValue((String) obj);
}
return obj;
} catch (ParseException e) {
// just assume it's actually a string
return obj;
}
}
开发者ID:viltgroup,项目名称:minium,代码行数:14,代码来源:RhinoWebModules.java
示例5: shouldFailToParseIllegalWhitespaceChars
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseIllegalWhitespaceChars() throws Exception {
parser.parseValue(" \u000b 1");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例6: shouldFailToParseJavaNull
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseJavaNull() throws Exception {
parser.parseValue(null);
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例7: shouldFailToParseDoubleNegativeNumbers
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseDoubleNegativeNumbers() throws Exception {
parser.parseValue("--5");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例8: shouldFailToParseNumbersWithDecimalExponent
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseNumbersWithDecimalExponent() throws Exception {
parser.parseValue("5e5.5");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例9: shouldFailToParseNumbersBeginningWithZero
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseNumbersBeginningWithZero() throws Exception {
parser.parseValue("05");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例10: shouldFailToParseEmptyJavaString
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseEmptyJavaString() throws Exception {
parser.parseValue("");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例11: shouldFailToParseSingleDoubleQuote
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseSingleDoubleQuote() throws Exception {
parser.parseValue(str('"'));
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例12: shouldFailToParseStringContainingSingleBackslash
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseStringContainingSingleBackslash() throws Exception {
parser.parseValue(str('"', '\\', '"'));
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例13: shouldFailToParseStringIllegalStringChars
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseStringIllegalStringChars() throws Exception {
parser.parseValue(str('"', '\n', '"'));
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例14: shouldFailToParseArrayWithInvalidElements
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseArrayWithInvalidElements() throws Exception {
parser.parseValue("[wtf]");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例15: shouldFailToParseJsonObjectsWithInvalidFormat
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseJsonObjectsWithInvalidFormat() throws Exception {
parser.parseValue("{\"only\", \"keys\"}");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例16: shouldFailToParseMoreThanOneToplevelValue
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseMoreThanOneToplevelValue() throws Exception {
parser.parseValue("1 2");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例17: shouldFailToParseStringTruncatedUnicode
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseStringTruncatedUnicode() throws Exception {
parser.parseValue("\"\\u00f\"");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例18: shouldFailToParseStringControlChars1
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseStringControlChars1() throws Exception {
parser.parseValue("\"\u0000\"");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例19: shouldFailToParseStringControlChars2
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldFailToParseStringControlChars2() throws Exception {
parser.parseValue("\"\u001f\"");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
示例20: shouldThrowParseExceptionWhenIncompleteObject
import org.mozilla.javascript.json.JsonParser.ParseException; //导入依赖的package包/类
@Test(expected = ParseException.class)
public void shouldThrowParseExceptionWhenIncompleteObject() throws Exception {
parser.parseValue("{\"a\" ");
}
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:JsonParserTest.java
注:本文中的org.mozilla.javascript.json.JsonParser.ParseException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论