org.xmlresolver.catalog.entry.EntryRewriteUri Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xmlresolver Show documentation
Show all versions of xmlresolver Show documentation
An XML entity/uri resolver
package org.xmlresolver.catalog.entry;
import org.xmlresolver.ResolverConfiguration;
import org.xmlresolver.utils.URIUtils;
import java.net.URI;
/**
* A rewrite URI catalog entry.
*/
public class EntryRewriteUri extends Entry {
/** The URI start string to match. */
public final String uriStart;
/** The prefix to use when rewriting the URI. */
public final URI rewritePrefix;
/**
* EntryRewriteUri constructor.
* @param config The configuration.
* @param baseURI The base URI.
* @param id The (XML) ID of this element in the XML catalog.
* @param startString The URI start string to match.
* @param rewrite The prefix to use when rewriting the URI.
*/
public EntryRewriteUri(ResolverConfiguration config, URI baseURI, String id, String startString, String rewrite) {
super(config, baseURI, id);
if (startString.startsWith("classpath:/")) {
// classpath:/path/to/thing is the same as classpath:path/to/thing
// normalize without the leading slash.
uriStart = "classpath:" + startString.substring(11);
} else {
uriStart = startString;
}
rewritePrefix = URIUtils.resolve(baseURI, rewrite);
}
@Override
public Type getType() {
return Type.REWRITE_URI;
}
@Override
public String toString() {
return "rewriteURI " + uriStart + Entry.rarr + rewritePrefix;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy