private int parseInt(String value, Location location, IntrospectionContext context) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { context.addError(new InvalidValue("Invalid value", location, e)); return 0; } } }
private int parseRetries(XMLStreamReader reader, IntrospectionContext context) { String retries = reader.getAttributeValue(null, "retries"); if (retries != null) { try { return Integer.parseInt(retries); } catch (NumberFormatException e) { Location location = reader.getLocation(); InvalidValue error = new InvalidValue("The retries attribute must be a valid number", location); context.addError(error); } } return 0; }
private int parseInt(String value, Location location, IntrospectionContext context) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { context.addError(new InvalidValue("Invalid value", location, e)); return 0; } } }
private int parseRingSize(ChannelDefinition definition, XMLStreamReader reader, Location startLocation, IntrospectionContext context, RingBufferData data) { String sizeStr = reader.getAttributeValue(null, RING_SIZE); int ringSize = DEFAULT_RING_SIZE; if (sizeStr != null) { try { ringSize = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { context.addError(new InvalidValue("Invalid ring buffer size" + sizeStr, startLocation, definition)); } } return ringSize; }
private String readMandatoryAttribute(String name, XMLStreamReader reader, IntrospectionContext context) { String val = reader.getAttributeValue(null, name); if (val == null) { InvalidValue error = new InvalidValue("Datasource " + name + " must be specified", reader.getLocation()); context.addError(error); } return val; }
private void validateRemotable(XMLStreamReader reader, Location location, IntrospectionContext context) { String remotableAttr = reader.getAttributeValue(null, "remotable"); if (remotableAttr != null) { boolean remotable = Boolean.parseBoolean(remotableAttr); if (!remotable) { InvalidValue error = new InvalidValue("WSDL interfaces cannot set remotable to false", location); context.addError(error); } } }
private int parseRingSize(Channel definition, XMLStreamReader reader, Location startLocation, IntrospectionContext context) { String sizeStr = reader.getAttributeValue(null, RING_SIZE); int ringSize = DEFAULT_RING_SIZE; if (sizeStr != null) { try { ringSize = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { context.addError(new InvalidValue("Invalid ring buffer size" + sizeStr, startLocation, definition)); } } return ringSize; }
private URI parseTargetUri(XMLStreamReader reader, IntrospectionContext context) { String uri = reader.getAttributeValue(null, "uri"); URI targetUri = null; if (uri != null) { try { targetUri = new URI(uri); } catch (URISyntaxException ex) { Location location = reader.getLocation(); InvalidValue failure = new InvalidValue("The web services binding URI is not a valid: " + uri, location); context.addError(failure); } } return targetUri; }
private String readMandatoryAttribute(String name, XMLStreamReader reader, IntrospectionContext context) { String val = reader.getAttributeValue(null, name); if (val == null) { InvalidValue error = new InvalidValue("Datasource " + name + " must be specified", reader.getLocation()); context.addError(error); } return val; }
private long parseLong(String name, XMLStreamReader reader, IntrospectionContext context) { try { String val = reader.getAttributeValue(null, name); if (val == null) { return -1; } return Long.parseLong(val); } catch (NumberFormatException e) { Location location = reader.getLocation(); InvalidValue error = new InvalidValue("Invalid value specified for " + name, location, e); context.addError(error); return -1; } }
private int parseRetries(XMLStreamReader reader, IntrospectionContext context) { String retries = reader.getAttributeValue(null, "retries"); if (retries != null) { try { return Integer.parseInt(retries); } catch (NumberFormatException e) { Location location = reader.getLocation(); InvalidValue error = new InvalidValue("The retries attribute must be a valid number", location); context.addError(error); } } return 0; }
private URI parseTargetUri(XMLStreamReader reader, IntrospectionContext context) { String uri = reader.getAttributeValue(null, "uri"); URI targetUri = null; if (uri != null) { try { targetUri = new URI(uri); } catch (URISyntaxException ex) { Location location = reader.getLocation(); InvalidValue failure = new InvalidValue("The web services binding URI is not a valid: " + uri, location); context.addError(failure); } } return targetUri; }
private long parseDelay(XMLStreamReader reader, IntrospectionContext context) { long delay = -1; String delayStr = reader.getAttributeValue(null, "delay"); if (delayStr != null) { try { delay = Long.parseLong(delayStr); } catch (NumberFormatException e) { Location location = reader.getLocation(); InvalidValue error = new InvalidValue("Invalid delay value", location, e); context.addError(error); } } return delay; }
private CreateOption parseCreate(XMLStreamReader reader, IntrospectionContext context) { Location startLocation = reader.getLocation(); String create = reader.getAttributeValue(null, "create"); if (create != null) { if ("always".equals(create)) { return CreateOption.ALWAYS; } else if ("never".equalsIgnoreCase(create)) { return CreateOption.NEVER; } else if ("ifNotExist".equalsIgnoreCase(create)) { return CreateOption.IF_NOT_EXIST; } else { InvalidValue error = new InvalidValue("Invalid value specified for create attribute: " + create, startLocation); context.addError(error); } } return CreateOption.IF_NOT_EXIST; }
private long parseLong(String name, XMLStreamReader reader, IntrospectionContext context) { try { String val = reader.getAttributeValue(null, name); if (val == null) { return -1; } return Long.parseLong(val); } catch (NumberFormatException e) { Location location = reader.getLocation(); InvalidValue error = new InvalidValue("Invalid value specified for " + name, location, e); context.addError(error); return -1; } }
private URI parseUri(XMLStreamReader reader, Location location, IntrospectionContext context) { URI uri = null; String uriStr = reader.getAttributeValue(null, "uri"); if (uriStr != null) { if (uriStr.length() < 1) { InvalidValue failure = new InvalidValue("Web component URI must specify a value", location); context.addError(failure); } else { try { uri = new URI(uriStr); } catch (URISyntaxException e) { InvalidValue failure = new InvalidValue("Web component URI is not a valid: " + uri, location); context.addError(failure); } } } return uri; }
private URI parseUri(XMLStreamReader reader, Location location, IntrospectionContext context) { URI uri = null; String uriStr = reader.getAttributeValue(null, "uri"); if (uriStr != null) { if (uriStr.length() < 1) { InvalidValue failure = new InvalidValue("Web component URI must specify a value", location); context.addError(failure); } else { try { uri = new URI(uriStr); } catch (URISyntaxException e) { InvalidValue failure = new InvalidValue("Web component URI is not a valid: " + uri, location); context.addError(failure); } } } return uri; }
private long parseLong(ChannelDefinition definition, XMLStreamReader reader, Location startLocation, String attributeName, String errorText, long defaultValue, IntrospectionContext context) { String valueStr = reader.getAttributeValue(null, attributeName); long value = defaultValue; if (valueStr != null) { try { value = Long.parseLong(valueStr); } catch (NumberFormatException e) { context.addError(new InvalidValue(errorText + valueStr, startLocation, definition)); } } return value; } }
private long parseLong(Channel definition, XMLStreamReader reader, Location startLocation, String attributeName, String errorText, long defaultValue, IntrospectionContext context) { String valueStr = reader.getAttributeValue(null, attributeName); long value = defaultValue; if (valueStr != null) { try { value = Long.parseLong(valueStr); } catch (NumberFormatException e) { context.addError(new InvalidValue(errorText + valueStr, startLocation, definition)); } } return value; } }
private void loadInitLevel(ComponentDefinition<Implementation<?>> componentDefinition, XMLStreamReader reader, IntrospectionContext context) { String initLevel = reader.getAttributeValue(null, "initLevel"); if (initLevel != null && initLevel.length() != 0) { try { Integer level = Integer.valueOf(initLevel); componentDefinition.setInitLevel(level); } catch (NumberFormatException e) { InvalidValue failure = new InvalidValue("Component initialization level must be an integer: " + initLevel, reader); context.addError(failure); } } }