/** * Creates a message bean without cause and no namespace information. * * @param code the error or exception code of the exception. * @param systemId the resource that cannot be read. * @return a message bean without namespace information. */ public static ConfigMessageBean systemId(final ConfigCode code, final String systemId) { return systemId(code, null, systemId); }
private void checkDuplication(final String systemId, final ConfigurationKey<?> anyKey, final ConfigurationKey<?> key) { if (anyKey != null) { throw new DuplicateDefaultKeyException(duplicate(systemId, anyKey.toString(), key.toString())); } }
/** * Creates a message bean signaling a namespace problem. * * @param systemId the resource that cannot be read. * @param expectedNamespace the expected namespace. * @param actualNamespace the namespace that has actually been encountered. * @return a message bean signaling a namespace problem. */ public static ConfigMessageBean namespace(final String systemId, final String expectedNamespace, final String actualNamespace) { return new ConfigMessageBean(ConfigCode.WRONG_NAMESPACE, null, systemId, new DuplicateKeys(), new InvalidNamespace(expectedNamespace, actualNamespace)); }
private static void checkNamespace(final String systemId, final Document document) { final Namespace actualNamespace = document.getRootElement().getNamespace(); if (!NS.equals(actualNamespace)) { throw new ConfigException(namespace(systemId, NS.getURI(), actualNamespace.getURI())); } }
/** * Creates a message bean signaling a duplicate key problem. * * @param systemId the resource that cannot be read. * @param currentDefaultKey the key that has already been recognized as * default. * @param duplicateDefaultKey the second key that has been recognized as * default. * @return a message bean signaling a duplicate key problem. */ public static ConfigMessageBean duplicate(final String systemId, final String currentDefaultKey, final String duplicateDefaultKey) { return new ConfigMessageBean(ConfigCode.DUPLICATE_DEFAULT_KEY, null, systemId, new DuplicateKeys(currentDefaultKey, duplicateDefaultKey), new InvalidNamespace()); }
private static void checkNamespace(final String systemId, final Document document) { final Namespace actualNamespace = document.getRootElement().getNamespace(); if (!NS.equals(actualNamespace)) { throw new ConfigException(namespace(systemId, NS.getURI(), actualNamespace.getURI())); } }
/** * Creates a message bean without namespace information. * * @param code the error or exception code of the exception. * @param cause the cause (which is saved for later retrieval by the * {@link #getCause()} method). (A <tt>null</tt> value is permitted, * and indicates that the cause is nonexistent or unknown.) * @param systemId the resource that cannot be read. * @return a message bean without namespace information. */ public static ConfigMessageBean systemId(final ConfigCode code, final Throwable cause, final String systemId) { return new ConfigMessageBean(code, cause, systemId, new DuplicateKeys(), new InvalidNamespace()); }
throw new ConfigException(systemId(ConfigCode.CONFIG_FILE_NOT_FOUND, PropertiesContext.DEFINITION_FILE));