本文整理汇总了Java中com.sun.org.apache.xerces.internal.util.URI类的典型用法代码示例。如果您正苦于以下问题:Java URI类的具体用法?Java URI怎么用?Java URI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URI类属于com.sun.org.apache.xerces.internal.util包,在下文中一共展示了URI类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBaseURI
import com.sun.org.apache.xerces.internal.util.URI; //导入依赖的package包/类
/**
* Returns the absolute base URI of this node or null if the implementation
* wasn't able to obtain an absolute URI. Note: If the URI is malformed, a
* null is returned.
*
* @return The absolute base URI of this node or null.
* @since DOM Level 3
*/
public String getBaseURI() {
if (needsSyncData()) {
synchronizeData();
}
if (baseURI != null && baseURI.length() != 0 ) {// attribute value is always empty string
try {
return new URI(baseURI).toString();
}
catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e){
// REVISIT: what should happen in this case?
return null;
}
}
return baseURI;
}
示例2: getActualValue
import com.sun.org.apache.xerces.internal.util.URI; //导入依赖的package包/类
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
// check 3.2.17.c0 must: URI (rfc 2396/2723)
try {
if( content.length() != 0 ) {
// encode special characters using XLink 5.4 algorithm
final String encoded = encode(content);
// Support for relative URLs
// According to Java 1.1: URLs may also be specified with a
// String and the URL object that it is related to.
new URI(BASE_URI, encoded );
}
} catch (URI.MalformedURIException ex) {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "anyURI"});
}
// REVISIT: do we need to return the new URI object?
return content;
}
示例3: getBaseURI
import com.sun.org.apache.xerces.internal.util.URI; //导入依赖的package包/类
/**
* Returns the absolute base URI of this node or null if the implementation
* wasn't able to obtain an absolute URI. Note: If the URI is malformed, a
* null is returned.
*
* @return The absolute base URI of this node or null.
* @since DOM Level 3
*/
public String getBaseURI() {
if (fDocumentURI != null && fDocumentURI.length() != 0 ) {// attribute value is always empty string
try {
return new URI(fDocumentURI).toString();
}
catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e){
// REVISIT: what should happen in this case?
return null;
}
}
return fDocumentURI;
}
示例4: getBaseURI
import com.sun.org.apache.xerces.internal.util.URI; //导入依赖的package包/类
/**
* Returns the absolute base URI of this node or null if the implementation
* wasn't able to obtain an absolute URI. Note: If the URI is malformed, a
* null is returned.
*
* @return The absolute base URI of this node or null.
* @since DOM Level 3
*/
public String getBaseURI() {
if (needsSyncData()) {
synchronizeData();
}
if (baseURI == null) {
DocumentType doctype;
NamedNodeMap entities;
EntityImpl entDef;
if (null != (doctype = getOwnerDocument().getDoctype()) &&
null != (entities = doctype.getEntities())) {
entDef = (EntityImpl)entities.getNamedItem(getNodeName());
if (entDef !=null) {
return entDef.getBaseURI();
}
}
} else if (baseURI != null && baseURI.length() != 0 ) {// attribute value is always empty string
try {
return new URI(baseURI).toString();
}
catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e){
// REVISIT: what should happen in this case?
return null;
}
}
return baseURI;
}
示例5: resolveSystemId
import com.sun.org.apache.xerces.internal.util.URI; //导入依赖的package包/类
/** Resolves a system identifier against a base URI. */
private String resolveSystemId(String systemId, String baseURI) {
try {
return XMLEntityManager.expandSystemId(systemId, baseURI, false);
}
// In the event that resolution failed against the
// base URI, just return the system id as is. There's not
// much else we can do.
catch (URI.MalformedURIException ex) {
return systemId;
}
}
示例6: openWebpage
import com.sun.org.apache.xerces.internal.util.URI; //导入依赖的package包/类
public static void openWebpage(java.net.URI uri) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(uri);
} catch (Exception e) {
Logger.getLogger(GendreAPIPreviewCreator.class.getName()).log(
Level.WARNING,
"Couldn't open in browser. Please get your API Key at "+NamSorAPI.NAMSOR_CHANNEL_REGISTRATION_URL);
}
}
}
示例7: openWebpage
import com.sun.org.apache.xerces.internal.util.URI; //导入依赖的package包/类
public static void openWebpage(java.net.URI uri) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(uri);
} catch (Exception e) {
Logger.getLogger(OriginAPIPreviewCreator.class.getName()).log(
Level.WARNING,
"Couldn't open in browser. Please get your API Key at "+NamSorAPI.NAMSOR_CHANNEL_REGISTRATION_URL);
}
}
}
示例8: updateActivemqConfigFile
import com.sun.org.apache.xerces.internal.util.URI; //导入依赖的package包/类
private void updateActivemqConfigFile(File configFile) throws Exception {
Document doc = openXmlForUpdating("ActiveMQ", configFile, false);
Element broker = (Element)doc.getDocumentElement().getElementsByTagName("broker").item(0);
Element transportConnectors = (Element)broker.getElementsByTagName("transportConnectors").item(0);
Element transportConnector = (Element)transportConnectors.getElementsByTagName("transportConnector").item(0); // edit first in the list (could use attribute name to decide right one..)
URI uri = new URI(transportConnector.getAttribute("uri"));
uri.setScheme(configs[BROKER_PROTOCOL_INDEX][VAL_INDEX]);
uri.setHost(configs[BROKER_PRIVATE_HOST_INDEX][VAL_INDEX]);
uri.setPort(Integer.parseInt(configs[BROKER_PORT_INDEX][VAL_INDEX]));
updateElementAttribute(transportConnector, "uri", uri.toString());
writeLater(configFile, doc);
}
示例9: getRelativeBaseURI
import com.sun.org.apache.xerces.internal.util.URI; //导入依赖的package包/类
/**
* Returns a URI, relative to the include parent's base URI, of the current
* [base URI]. For instance, if the current [base URI] was "dir1/dir2/file.xml"
* and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
* @return the relative URI
*/
protected String getRelativeBaseURI() throws MalformedURIException {
int includeParentDepth = getIncludeParentDepth();
String relativeURI = this.getRelativeURI(includeParentDepth);
if (isRootDocument()) {
return relativeURI;
}
else {
if (relativeURI.equals("")) {
relativeURI = fCurrentBaseURI.getLiteralSystemId();
}
if (includeParentDepth == 0) {
if (fParentRelativeURI == null) {
fParentRelativeURI =
fParentXIncludeHandler.getRelativeBaseURI();
}
if (fParentRelativeURI.equals("")) {
return relativeURI;
}
URI base = new URI(fParentRelativeURI, true);
URI uri = new URI(base, relativeURI);
/** Check whether the scheme components are equal. */
final String baseScheme = base.getScheme();
final String literalScheme = uri.getScheme();
if (!Objects.equals(baseScheme, literalScheme)) {
return relativeURI;
}
/** Check whether the authority components are equal. */
final String baseAuthority = base.getAuthority();
final String literalAuthority = uri.getAuthority();
if (!Objects.equals(baseAuthority, literalAuthority)) {
return uri.getSchemeSpecificPart();
}
/**
* The scheme and authority components are equal,
* return the path and the possible query and/or
* fragment which follow.
*/
final String literalPath = uri.getPath();
final String literalQuery = uri.getQueryString();
final String literalFragment = uri.getFragment();
if (literalQuery != null || literalFragment != null) {
final StringBuilder buffer = new StringBuilder();
if (literalPath != null) {
buffer.append(literalPath);
}
if (literalQuery != null) {
buffer.append('?');
buffer.append(literalQuery);
}
if (literalFragment != null) {
buffer.append('#');
buffer.append(literalFragment);
}
return buffer.toString();
}
return literalPath;
}
else {
return relativeURI;
}
}
}