public void invalidAttributeValue(String element, String attribute, String value) { invalidAttributeValue(element, attribute, value, null); }
public void invalidAttributeValue(String element, String attribute, String value) { invalidAttributeValue(element, attribute, value, null); }
public Boolean checkBoolean(String element, String attribute, String value) { try { return Boolean.valueOf(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } catch (NullPointerException npe) { invalidAttributeValue(element, attribute, null); } return Boolean.FALSE; }
public Boolean checkBoolean(String element, String attribute, String value) { try { return Boolean.valueOf(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } catch (NullPointerException npe) { invalidAttributeValue(element, attribute, null); } return Boolean.FALSE; }
public Boolean checkBoolean(String element, String attribute, String value, boolean defaultValue) { Boolean result = (defaultValue ? Boolean.TRUE : Boolean.FALSE); if (value != null) { try { return Boolean.valueOf(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } } return result; }
public int checkInteger(String element, String attribute, String value) { try { return Integer.parseInt(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } return 0; }
public int checkInteger(String element, String attribute, String value) { try { return Integer.parseInt(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } return 0; }
public Boolean checkBoolean(String element, String attribute, String value, boolean defaultValue) { Boolean result = (defaultValue ? Boolean.TRUE : Boolean.FALSE); if (value != null) { try { return Boolean.valueOf(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } } return result; }
public VersionRange checkVersionRange(String element, String attribute, String value) { try { if (value != null) return new VersionRange(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } catch (NullPointerException npe) { invalidAttributeValue(element, attribute, null); } return VersionRange.emptyRange; }
public VersionRange checkVersionRange(String element, String attribute, String value) { try { if (value != null) return new VersionRange(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } catch (NullPointerException npe) { invalidAttributeValue(element, attribute, null); } return VersionRange.emptyRange; }
/** * Converts a version string to a Version object. Returns the version object, * or {@link Version#emptyVersion} if the value was not a valid version. */ public Version checkVersion(String element, String attribute, String value) { try { return Version.parseVersion(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } catch (NullPointerException npe) { invalidAttributeValue(element, attribute, null); } return Version.emptyVersion; }
/** * Converts a version string to a Version object. Returns the version object, * or {@link Version#emptyVersion} if the value was not a valid version. */ public Version checkVersion(String element, String attribute, String value) { try { return Version.parseVersion(value); } catch (IllegalArgumentException iae) { invalidAttributeValue(element, attribute, value); } catch (NullPointerException npe) { invalidAttributeValue(element, attribute, null); } return Version.emptyVersion; }
public URI checkURI(String element, String attribute, String value) { try { return URIUtil.fromString(value); } catch (URISyntaxException e) { invalidAttributeValue(element, attribute, value); } //TODO ok to return null? return null; }
public URI checkURI(String element, String attribute, String value) { try { return URIUtil.fromString(value); } catch (URISyntaxException e) { invalidAttributeValue(element, attribute, value); } //TODO ok to return null? return null; }
private URI constructURI(Attributes attributes, boolean required, String location) { try { if (location != null) return new URI(location); if (required) location = parseRequiredAttributes(attributes, new String[] {URL_ATTRIBUTE})[0]; else location = parseOptionalAttribute(attributes, URL_ATTRIBUTE); if (location == null) return null; return URIUtil.toURI(new URL(location)); } catch (MalformedURLException e) { invalidAttributeValue(elementHandled, URL_ATTRIBUTE, location, e); } catch (URISyntaxException e) { invalidAttributeValue(elementHandled, URL_ATTRIBUTE, location, e); } return null; }
/** * In p2 1.0 we stored URLs, in 1.1 and later we store URIs. This method will * first check for a URI, and then resort to looking for a URL attribute for * backwards compatibility. * @param attributes The attributes to parse * @param required If true, an exception is thrown if no URI or URL attribute is present */ protected URI parseURIAttribute(Attributes attributes, boolean required) { String location = parseOptionalAttribute(attributes, URI_ATTRIBUTE); try { if (location != null) return new URI(location); if (required) location = parseRequiredAttributes(attributes, new String[] {URL_ATTRIBUTE})[0]; else location = parseOptionalAttribute(attributes, URL_ATTRIBUTE); if (location == null) return null; return URIUtil.toURI(new URL(location)); } catch (MalformedURLException e) { invalidAttributeValue(elementHandled, URL_ATTRIBUTE, location, e); } catch (URISyntaxException e) { invalidAttributeValue(elementHandled, URL_ATTRIBUTE, location, e); } return null; }