Java Code Examples for javax.xml.namespace.QName#toString()

The following examples show how to use javax.xml.namespace.QName#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXBContextImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a type name that this context recognizes which is
 * "closest" to the given type name.
 *
 * <p>
 * This method is used for error recovery.
 */
public String getNearestTypeName(QName name) {
    String[] all = new String[typeMap.size()];
    int i=0;
    for (QName qn : typeMap.keySet()) {
        if(qn.getLocalPart().equals(name.getLocalPart()))
            return qn.toString();  // probably a match, as people often gets confused about namespace.
        all[i++] = qn.toString();
    }

    String nearest = EditDistance.findNearest(name.toString(), all);

    if(EditDistance.editDistance(nearest,name.toString())>10)
        return null;    // too far apart.

    return nearest;
}
 
Example 2
Source File: JAXBContextImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a type name that this context recognizes which is
 * "closest" to the given type name.
 *
 * <p>
 * This method is used for error recovery.
 */
public String getNearestTypeName(QName name) {
    String[] all = new String[typeMap.size()];
    int i=0;
    for (QName qn : typeMap.keySet()) {
        if(qn.getLocalPart().equals(name.getLocalPart()))
            return qn.toString();  // probably a match, as people often gets confused about namespace.
        all[i++] = qn.toString();
    }

    String nearest = EditDistance.findNearest(name.toString(), all);

    if(EditDistance.editDistance(nearest,name.toString())>10)
        return null;    // too far apart.

    return nearest;
}
 
Example 3
Source File: JAXBContextImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a type name that this context recognizes which is
 * "closest" to the given type name.
 *
 * <p>
 * This method is used for error recovery.
 */
public String getNearestTypeName(QName name) {
    String[] all = new String[typeMap.size()];
    int i=0;
    for (QName qn : typeMap.keySet()) {
        if(qn.getLocalPart().equals(name.getLocalPart()))
            return qn.toString();  // probably a match, as people often gets confused about namespace.
        all[i++] = qn.toString();
    }

    String nearest = EditDistance.findNearest(name.toString(), all);

    if(EditDistance.editDistance(nearest,name.toString())>10)
        return null;    // too far apart.

    return nearest;
}
 
Example 4
Source File: JAXBContextImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a type name that this context recognizes which is
 * "closest" to the given type name.
 *
 * <p>
 * This method is used for error recovery.
 */
public String getNearestTypeName(QName name) {
    String[] all = new String[typeMap.size()];
    int i=0;
    for (QName qn : typeMap.keySet()) {
        if(qn.getLocalPart().equals(name.getLocalPart()))
            return qn.toString();  // probably a match, as people often gets confused about namespace.
        all[i++] = qn.toString();
    }

    String nearest = EditDistance.findNearest(name.toString(), all);

    if(EditDistance.editDistance(nearest,name.toString())>10)
        return null;    // too far apart.

    return nearest;
}
 
Example 5
Source File: JAXBContextImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a type name that this context recognizes which is
 * "closest" to the given type name.
 *
 * <p>
 * This method is used for error recovery.
 */
public String getNearestTypeName(QName name) {
    String[] all = new String[typeMap.size()];
    int i=0;
    for (QName qn : typeMap.keySet()) {
        if(qn.getLocalPart().equals(name.getLocalPart()))
            return qn.toString();  // probably a match, as people often gets confused about namespace.
        all[i++] = qn.toString();
    }

    String nearest = EditDistance.findNearest(name.toString(), all);

    if(EditDistance.editDistance(nearest,name.toString())>10)
        return null;    // too far apart.

    return nearest;
}
 
Example 6
Source File: JAXBContextImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a type name that this context recognizes which is
 * "closest" to the given type name.
 *
 * <p>
 * This method is used for error recovery.
 */
public String getNearestTypeName(QName name) {
    String[] all = new String[typeMap.size()];
    int i=0;
    for (QName qn : typeMap.keySet()) {
        if(qn.getLocalPart().equals(name.getLocalPart()))
            return qn.toString();  // probably a match, as people often gets confused about namespace.
        all[i++] = qn.toString();
    }

    String nearest = EditDistance.findNearest(name.toString(), all);

    if(EditDistance.editDistance(nearest,name.toString())>10)
        return null;    // too far apart.

    return nearest;
}
 
Example 7
Source File: JAXBContextImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a type name that this context recognizes which is
 * "closest" to the given type name.
 *
 * <p>
 * This method is used for error recovery.
 */
public String getNearestTypeName(QName name) {
    String[] all = new String[typeMap.size()];
    int i=0;
    for (QName qn : typeMap.keySet()) {
        if(qn.getLocalPart().equals(name.getLocalPart()))
            return qn.toString();  // probably a match, as people often gets confused about namespace.
        all[i++] = qn.toString();
    }

    String nearest = EditDistance.findNearest(name.toString(), all);

    if(EditDistance.editDistance(nearest,name.toString())>10)
        return null;    // too far apart.

    return nearest;
}
 
Example 8
Source File: JAXBContextImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a type name that this context recognizes which is
 * "closest" to the given type name.
 *
 * <p>
 * This method is used for error recovery.
 */
public String getNearestTypeName(QName name) {
    String[] all = new String[typeMap.size()];
    int i=0;
    for (QName qn : typeMap.keySet()) {
        if(qn.getLocalPart().equals(name.getLocalPart()))
            return qn.toString();  // probably a match, as people often gets confused about namespace.
        all[i++] = qn.toString();
    }

    String nearest = EditDistance.findNearest(name.toString(), all);

    if(EditDistance.editDistance(nearest,name.toString())>10)
        return null;    // too far apart.

    return nearest;
}
 
Example 9
Source File: XMLDatatypeUtil.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Maps a datatype QName from the javax.xml.namespace package to an XML Schema 1.0 URI for the corresponding
 * datatype. This method recognizes the XML Schema qname mentioned in {@link DatatypeConstants}.
 *
 * Note that Java 8 / 11 do not have constants for XML Schema 1.1 datatypes like xsd:dateTimeStamp.
 *
 * @param qname One of the XML Schema qnames from {@link DatatypeConstants}.
 * @return A URI for the specified datatype.
 * @throws IllegalArgumentException If the supplied qname was not recognized by this method.
 * @see DatatypeConstants
 */
public static IRI qnameToURI(QName qname) {
	if (DatatypeConstants.DATETIME.equals(qname)) {
		return XMLSchema.DATETIME;
	} else if (DatatypeConstants.DATE.equals(qname)) {
		return XMLSchema.DATE;
	} else if (DatatypeConstants.TIME.equals(qname)) {
		return XMLSchema.TIME;
	} else if (DatatypeConstants.GYEARMONTH.equals(qname)) {
		return XMLSchema.GYEARMONTH;
	} else if (DatatypeConstants.GMONTHDAY.equals(qname)) {
		return XMLSchema.GMONTHDAY;
	} else if (DatatypeConstants.GYEAR.equals(qname)) {
		return XMLSchema.GYEAR;
	} else if (DatatypeConstants.GMONTH.equals(qname)) {
		return XMLSchema.GMONTH;
	} else if (DatatypeConstants.GDAY.equals(qname)) {
		return XMLSchema.GDAY;
	} else if (DatatypeConstants.DURATION.equals(qname)) {
		return XMLSchema.DURATION;
	} else if (DatatypeConstants.DURATION_DAYTIME.equals(qname)) {
		return XMLSchema.DAYTIMEDURATION;
	} else if (DatatypeConstants.DURATION_YEARMONTH.equals(qname)) {
		return XMLSchema.YEARMONTHDURATION;
	} else {
		throw new IllegalArgumentException("QName cannot be mapped to an XML Schema URI: " + qname.toString());
	}
}
 
Example 10
Source File: FaultDetailHeader.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public FaultDetailHeader(AddressingVersion av, String wrapper, QName problemHeader) {
    this.av = av;
    this.wrapper = wrapper;
    this.problemValue = problemHeader.toString();
}
 
Example 11
Source File: TestJaxbAnnotationIntrospector.java    From jackson-modules-base with Apache License 2.0 4 votes vote down vote up
@Override
public String marshal(QName v) throws Exception
{
    return (v == null) ? null : v.toString();
}
 
Example 12
Source File: FaultDetailHeader.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public FaultDetailHeader(AddressingVersion av, String wrapper, QName problemHeader) {
    this.av = av;
    this.wrapper = wrapper;
    this.problemValue = problemHeader.toString();
}
 
Example 13
Source File: FaultDetailHeader.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public FaultDetailHeader(AddressingVersion av, String wrapper, QName problemHeader) {
    this.av = av;
    this.wrapper = wrapper;
    this.problemValue = problemHeader.toString();
}
 
Example 14
Source File: FaultDetailHeader.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public FaultDetailHeader(AddressingVersion av, String wrapper, QName problemHeader) {
    this.av = av;
    this.wrapper = wrapper;
    this.problemValue = problemHeader.toString();
}
 
Example 15
Source File: SynapseArtifactInitUtils.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Function to create synapse imports to enable installed connectors
 *
 * @param axisConfiguration axis configuration
 */
public static void initializeConnectors (AxisConfiguration axisConfiguration) {
    String synapseLibPath = axisConfiguration.getRepository().getPath() +
                                    File.separator + ServiceBusConstants.SYNAPSE_LIB_CONFIGS;
    File synapseLibDir = new File(synapseLibPath);
    if (synapseLibDir.exists() && synapseLibDir.isDirectory()) {
        File[] connectorList = synapseLibDir.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".zip");
            }
        });

        if (connectorList == null) {
            // No connectors found
            return;
        }

        //Check import related to the connector is available
        String importConfigDirPath = axisConfiguration.getRepository().getPath() +
                ServiceBusConstants.SYNAPSE_IMPORTS_CONFIG_PATH;
        File importsDir = new File(importConfigDirPath);

        if (!importsDir.exists() && !importsDir.mkdirs()) {
            log.error("Import synapse config directory does not exists and unable to create: " +
                    importsDir.getAbsolutePath());
            // Retrying the same for other connectors is waste
            return;
        }

        for (File connectorZip : connectorList) {
            if (log.isDebugEnabled()) {
                log.debug("Generating import for connector deployed with package: " + connectorZip.getName());
            }
            String connectorExtractedPath = null;
            try {
                connectorExtractedPath = extractConnector(connectorZip.getAbsolutePath());
            } catch (IOException e) {
                log.error("Error while extracting Connector zip : " + connectorZip.getAbsolutePath(), e);
                continue;
            }
            String packageName = retrievePackageName(connectorExtractedPath);

            // Retrieve connector name
            String connectorName = connectorZip.getName().substring(0, connectorZip.getName().indexOf('-'));
            QName qualifiedName = new QName(packageName, connectorName);
            File importFile = new File(importsDir, qualifiedName.toString() + ".xml");

            if (!importFile.exists()) {
                // Import file enabling file connector not available in synapse imports directory
                if (log.isDebugEnabled()) {
                    log.debug("Generating import config to enable connector: " + qualifiedName);
                }
                generateImportConfig(qualifiedName, importFile);
            }
        }
    }
}
 
Example 16
Source File: FaultDetailHeader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public FaultDetailHeader(AddressingVersion av, String wrapper, QName problemHeader) {
    this.av = av;
    this.wrapper = wrapper;
    this.problemValue = problemHeader.toString();
}
 
Example 17
Source File: FaultDetailHeader.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public FaultDetailHeader(AddressingVersion av, String wrapper, QName problemHeader) {
    this.av = av;
    this.wrapper = wrapper;
    this.problemValue = problemHeader.toString();
}
 
Example 18
Source File: FaultDetailHeader.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public FaultDetailHeader(AddressingVersion av, String wrapper, QName problemHeader) {
    this.av = av;
    this.wrapper = wrapper;
    this.problemValue = problemHeader.toString();
}
 
Example 19
Source File: FaultDetailHeader.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public FaultDetailHeader(AddressingVersion av, String wrapper, QName problemHeader) {
    this.av = av;
    this.wrapper = wrapper;
    this.problemValue = problemHeader.toString();
}
 
Example 20
Source File: NamespaceManager.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * From an QName representing a qualified attribute name, generate an attribute ID
 * suitable for use in {@link #registerAttributeValue(String, QName)} 
 * and {@link #deregisterAttributeValue(String)}.
 * 
 * @param name attribute name as a QName
 * @return a string attribute ID
 */
public static String generateAttributeID(QName name) {
   return name.toString(); 
}