/** * A Constructor that helps conformance to RFC 5424. * * @param name The name portion of the id. * @param enterpriseNumber The enterprise number. * @param required The list of keys that are required for this id. * @param optional The list of keys that are optional for this id. * @param maxLength The maximum length of the StructuredData Id key. * @since 2.9 */ public StructuredDataId(final String name, final int enterpriseNumber, final String[] required, final String[] optional, final int maxLength) { if (name == null) { throw new IllegalArgumentException("No structured id name was supplied"); } if (name.contains(AT_SIGN)) { throw new IllegalArgumentException("Structured id name cannot contain an " + Strings.quote(AT_SIGN)); } if (enterpriseNumber <= 0) { throw new IllegalArgumentException("No enterprise number was supplied"); } this.name = name; this.enterpriseNumber = enterpriseNumber; final String id = name + AT_SIGN + enterpriseNumber; if (maxLength > 0 && id.length() > maxLength) { throw new IllegalArgumentException("Length of id exceeds maximum of " + maxLength + " characters: " + id); } this.required = required; this.optional = optional; }
@Test public void testQuote() { Assert.assertEquals("'Q'", Strings.quote("Q")); }
ctx.log(getClass().getName() + " unable to resolve key " + Strings.quote(key)); return null;
/** * A Constructor that helps conformance to RFC 5424. * * @param name The name portion of the id. * @param enterpriseNumber The enterprise number. * @param required The list of keys that are required for this id. * @param optional The list of keys that are optional for this id. * @param maxLength The maximum length of the StructuredData Id key. * @since 2.9 */ public StructuredDataId(final String name, final int enterpriseNumber, final String[] required, final String[] optional, final int maxLength) { if (name == null) { throw new IllegalArgumentException("No structured id name was supplied"); } if (name.contains(AT_SIGN)) { throw new IllegalArgumentException("Structured id name cannot contain an " + Strings.quote(AT_SIGN)); } if (enterpriseNumber <= 0) { throw new IllegalArgumentException("No enterprise number was supplied"); } this.name = name; this.enterpriseNumber = enterpriseNumber; final String id = name + AT_SIGN + enterpriseNumber; if (maxLength > 0 && id.length() > maxLength) { throw new IllegalArgumentException("Length of id exceeds maximum of " + maxLength + " characters: " + id); } this.required = required; this.optional = optional; }