use of org.eclipse.jetty.http2.parser.Parser in project sonar-iac by SonarSource.
the class CloudformationParser method parse.
@Override
public FileTree parse(String source, @Nullable InputFileContext inputFileContext) {
LoadSettings settings = LoadSettings.builder().setParseComments(shouldParseComments(inputFileContext)).build();
StreamReader reader = new StreamReader(settings, source);
ScannerImpl scanner = new ScannerImpl(settings, reader);
Parser parser = new ParserImpl(settings, scanner);
Composer composer = new Composer(settings, parser);
List<Node> nodes = composerNodes(composer);
return CloudformationConverter.convertFile(nodes);
}
use of org.eclipse.jetty.http2.parser.Parser in project carbon-mediation by wso2.
the class HL7MessageBuilder method serializeHL7toXML.
private String serializeHL7toXML(Message message) throws AxisFault {
Parser xmlParser = new DefaultXMLParser();
xmlParser.setValidationContext(new NoValidation());
try {
return xmlParser.encode(message);
} catch (HL7Exception e) {
throw new AxisFault("Error on converting to HL7 XML: " + e.getMessage(), e);
}
}
use of org.eclipse.jetty.http2.parser.Parser in project carbon-mediation by wso2.
the class HL7EndpointManager method validateParameters.
private void validateParameters(InboundProcessorParams params, Map<String, Object> parameters) {
if (!params.getProperties().getProperty(MLLPConstants.PARAM_HL7_AUTO_ACK).equalsIgnoreCase("true") && !params.getProperties().getProperty(MLLPConstants.PARAM_HL7_AUTO_ACK).equalsIgnoreCase("false")) {
log.warn("Parameter inbound.hl7.AutoAck in HL7 inbound " + params.getName() + " is not valid. Default " + "value of true will be used.");
params.getProperties().setProperty(MLLPConstants.PARAM_HL7_AUTO_ACK, "true");
}
try {
Integer.valueOf(params.getProperties().getProperty(MLLPConstants.PARAM_HL7_TIMEOUT));
} catch (NumberFormatException e) {
log.warn("Parameter inbound.hl7.TimeOut in HL7 inbound " + params.getName() + " is not valid. Default timeout " + "of " + MLLPConstants.DEFAULT_HL7_TIMEOUT + " milliseconds will be used.");
params.getProperties().setProperty(MLLPConstants.PARAM_HL7_TIMEOUT, String.valueOf(MLLPConstants.DEFAULT_HL7_TIMEOUT));
}
try {
if (params.getProperties().getProperty(MLLPConstants.PARAM_HL7_PRE_PROC) != null) {
final HL7MessagePreprocessor preProcessor = (HL7MessagePreprocessor) Class.forName(params.getProperties().getProperty(MLLPConstants.PARAM_HL7_PRE_PROC)).newInstance();
Parser preProcParser = new PipeParser() {
public Message parse(String message) throws HL7Exception {
message = preProcessor.process(message, Axis2HL7Constants.MessageType.V2X, Axis2HL7Constants.MessageEncoding.ER7);
return super.parse(message);
}
};
parameters.put(MLLPConstants.HL7_PRE_PROC_PARSER_CLASS, preProcParser);
}
} catch (Exception e) {
log.error("Error creating message preprocessor for HL7 inbound " + params.getName() + ": ", e);
}
try {
if (params.getProperties().getProperty(MLLPConstants.PARAM_HL7_CHARSET) == null) {
params.getProperties().setProperty(MLLPConstants.PARAM_HL7_CHARSET, MLLPConstants.UTF8_CHARSET.displayName());
parameters.put(MLLPConstants.HL7_CHARSET_DECODER, MLLPConstants.UTF8_CHARSET.newDecoder());
} else {
parameters.put(MLLPConstants.HL7_CHARSET_DECODER, Charset.forName(params.getProperties().getProperty(MLLPConstants.PARAM_HL7_CHARSET)).newDecoder());
}
} catch (UnsupportedCharsetException e) {
parameters.put(MLLPConstants.HL7_CHARSET_DECODER, MLLPConstants.UTF8_CHARSET.newDecoder());
log.error("Unsupported charset '" + params.getProperties().getProperty(MLLPConstants.PARAM_HL7_CHARSET) + "' specified in HL7 inbound " + params.getName() + ". Default UTF-8 will be used instead.");
}
if (params.getProperties().getProperty(MLLPConstants.PARAM_HL7_VALIDATE) == null) {
params.getProperties().setProperty(MLLPConstants.PARAM_HL7_VALIDATE, "true");
}
if (params.getProperties().getProperty(MLLPConstants.PARAM_HL7_BUILD_RAW_MESSAGE) == null) {
params.getProperties().setProperty(MLLPConstants.PARAM_HL7_BUILD_RAW_MESSAGE, "false");
} else {
if (!params.getProperties().getProperty(MLLPConstants.PARAM_HL7_BUILD_RAW_MESSAGE).equalsIgnoreCase("true") && !params.getProperties().getProperty(MLLPConstants.PARAM_HL7_BUILD_RAW_MESSAGE).equalsIgnoreCase("false")) {
params.getProperties().setProperty(MLLPConstants.PARAM_HL7_BUILD_RAW_MESSAGE, "false");
}
}
if (params.getProperties().getProperty(MLLPConstants.PARAM_HL7_PASS_THROUGH_INVALID_MESSAGES) == null) {
params.getProperties().setProperty(MLLPConstants.PARAM_HL7_PASS_THROUGH_INVALID_MESSAGES, "false");
} else {
if (!params.getProperties().getProperty(MLLPConstants.PARAM_HL7_PASS_THROUGH_INVALID_MESSAGES).equalsIgnoreCase("true") && !params.getProperties().getProperty(MLLPConstants.PARAM_HL7_PASS_THROUGH_INVALID_MESSAGES).equalsIgnoreCase("false")) {
params.getProperties().setProperty(MLLPConstants.PARAM_HL7_PASS_THROUGH_INVALID_MESSAGES, "false");
}
}
}
use of org.eclipse.jetty.http2.parser.Parser in project commons-jexl by apache.
the class Engine method parse.
/**
* Parses an expression.
*
* @param info information structure
* @param parsingf the set of parsing features
* @param src the expression to parse
* @param scope the script frame
* @return the parsed tree
* @throws JexlException if any error occurred during parsing
*/
protected ASTJexlScript parse(final JexlInfo info, final JexlFeatures parsingf, final String src, final Scope scope) {
final boolean cached = src.length() < cacheThreshold && cache != null;
JexlFeatures features = parsingf != null ? parsingf : DEFAULT_FEATURES;
// if (features.getNameSpaces().isEmpty() && !functions.isEmpty()) {
// features = new JexlFeatures(features).nameSpaces(functions.keySet());
// }
final Source source = cached ? new Source(features, src) : null;
ASTJexlScript script;
if (source != null) {
script = cache.get(source);
if (script != null) {
final Scope f = script.getScope();
if ((f == null && scope == null) || (f != null && f.equals(scope))) {
return script;
}
}
}
final JexlInfo ninfo = info == null && debug ? createInfo() : info;
// if parser not in use...
if (parsing.compareAndSet(false, true)) {
try {
// lets parse
script = parser.parse(ninfo, features, src, scope);
} finally {
// no longer in use
parsing.set(false);
}
} else {
// ...otherwise parser was in use, create a new temporary one
final Parser lparser = new Parser(new StringProvider(";"));
script = lparser.parse(ninfo, features, src, scope);
}
if (source != null) {
cache.put(source, script);
}
return script;
}
use of org.eclipse.jetty.http2.parser.Parser in project commons-jexl by apache.
the class JexlTest method testAssignment.
/**
* Test assignment.
* @throws Exception
*/
@Test
public void testAssignment() throws Exception {
final JexlContext jc = new MapContext();
jc.set("aString", "Hello");
final Foo foo = new Foo();
jc.set("foo", foo);
final Parser parser = new Parser(";");
parser.parse(null, new JexlFeatures().register(false), "aString = 'World';", null);
assertExpression(jc, "hello = 'world'", "world");
Assert.assertEquals("hello variable not changed", "world", jc.get("hello"));
assertExpression(jc, "result = 1 + 1", new Integer(2));
Assert.assertEquals("result variable not changed", new Integer(2), jc.get("result"));
// todo: make sure properties can be assigned to, fall back to flat var if no property
// assertExpression(jc, "foo.property1 = '99'", "99");
// Assert.assertEquals("property not set", "99", foo.getProperty1());
}
Aggregations