类javax.xml.bind.annotation.adapters.NormalizedStringAdapter源码实例Demo

下面列出了怎么用javax.xml.bind.annotation.adapters.NormalizedStringAdapter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: kfs   文件: QualificationListAdapter.java
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public Map<String, String> unmarshal(QualificationList v) throws Exception {
    if (v != null) {
        NormalizedStringAdapter normalizedStringAdapter = new NormalizedStringAdapter();
        Map<String, String> map = new HashMap<String, String>();
        for (MapStringStringAdapter.StringMapEntry stringMapEntry : v.getQualifications()) {
            String tempKey = normalizedStringAdapter.unmarshal(stringMapEntry.getKey());
            if (StringUtils.isBlank(tempKey)) {
                throw new UnmarshalException("Cannot create a qualification entry with a blank key");
            } else if (map.containsKey(tempKey)) {
                throw new UnmarshalException("Cannot create more than one qualification entry with a key of \"" + tempKey + "\"");
            }
            map.put(tempKey, normalizedStringAdapter.unmarshal(stringMapEntry.getValue()));
        }
    }
    return null;
}
 
源代码2 项目: kfs   文件: PermissionDetailListAdapter.java
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public Map<String, String> unmarshal(PermissionDetailList v) throws Exception {
    if (v != null) {
        NormalizedStringAdapter normalizedStringAdapter = new NormalizedStringAdapter();
        Map<String, String> map = new HashMap<String, String>();
        for (MapStringStringAdapter.StringMapEntry stringMapEntry : v.getPermissionDetails()) {
            String tempKey = normalizedStringAdapter.unmarshal(stringMapEntry.getKey());
            if (StringUtils.isBlank(tempKey)) {
                throw new UnmarshalException("Cannot create a permission detail entry with a blank key");
            } else if (map.containsKey(tempKey)) {
                throw new UnmarshalException("Cannot create more than one permission detail entry with a key of \"" + tempKey + "\"");
            }
            map.put(tempKey, normalizedStringAdapter.unmarshal(stringMapEntry.getValue()));
        }
    }
    return null;
}
 
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public NameAndNamespacePair unmarshal(NameAndNamespacePair v) throws Exception {
    if (v != null) {
        
        if (StringUtils.isBlank(v.getName())) {
            throw new UnmarshalException("Cannot import a name-and-namespace pair with a blank name");
        } else if (StringUtils.isBlank(v.getNamespaceCode())) {
            throw new UnmarshalException("Cannot import a name-and-namespace pair with a blank namespace code");
        } if (CoreServiceApiServiceLocator.getNamespaceService().getNamespace(v.getNamespaceCode()) == null) {
            throw new UnmarshalException("Cannot import a name-and-namespace pair with invalid or unknown namespace \"" +
                    v.getNamespaceCode() + "\"");
        }
        
        v.setName(new NormalizedStringAdapter().unmarshal(v.getName()));
        v.setNamespaceCode(v.getNamespaceCode());
    }
    return v;
}
 
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
 */
@Override
public NameAndNamespacePair marshal(NameAndNamespacePair v) throws Exception {
    if (v != null) {
        if (StringUtils.isBlank(v.getName())) {
            throw new MarshalException("Cannot export a name-and-namespace pair with a blank name");
        } else if (StringUtils.isBlank(v.getNamespaceCode())) {
            throw new MarshalException("Cannot export a name-and-namespace pair with a blank namespace code");
        } else if (CoreServiceApiServiceLocator.getNamespaceService().getNamespace(v.getNamespaceCode()) == null) {
            throw new MarshalException("Cannot export a name-and-namespace pair with invalid or unknown namespace \"" + v.getNamespaceCode() + "\"");
        }
        
        v.setName(new NormalizedStringAdapter().marshal(v.getName()));
        v.setNamespaceCode(v.getNamespaceCode());
    }
    return v;
}
 
源代码5 项目: rice   文件: QualificationListAdapter.java
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public Map<String, String> unmarshal(QualificationList v) throws Exception {
    if (v != null) {
        NormalizedStringAdapter normalizedStringAdapter = new NormalizedStringAdapter();
        Map<String, String> map = new HashMap<String, String>();
        for (MapStringStringAdapter.StringMapEntry stringMapEntry : v.getQualifications()) {
            String tempKey = normalizedStringAdapter.unmarshal(stringMapEntry.getKey());
            if (StringUtils.isBlank(tempKey)) {
                throw new UnmarshalException("Cannot create a qualification entry with a blank key");
            } else if (map.containsKey(tempKey)) {
                throw new UnmarshalException("Cannot create more than one qualification entry with a key of \"" + tempKey + "\"");
            }
            map.put(tempKey, normalizedStringAdapter.unmarshal(stringMapEntry.getValue()));
        }
    }
    return null;
}
 
源代码6 项目: rice   文件: PermissionDetailListAdapter.java
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public Map<String, String> unmarshal(PermissionDetailList v) throws Exception {
    if (v != null) {
        NormalizedStringAdapter normalizedStringAdapter = new NormalizedStringAdapter();
        Map<String, String> map = new HashMap<String, String>();
        for (MapStringStringAdapter.StringMapEntry stringMapEntry : v.getPermissionDetails()) {
            String tempKey = normalizedStringAdapter.unmarshal(stringMapEntry.getKey());
            if (StringUtils.isBlank(tempKey)) {
                throw new UnmarshalException("Cannot create a permission detail entry with a blank key");
            } else if (map.containsKey(tempKey)) {
                throw new UnmarshalException("Cannot create more than one permission detail entry with a key of \"" + tempKey + "\"");
            }
            map.put(tempKey, normalizedStringAdapter.unmarshal(stringMapEntry.getValue()));
        }
    }
    return null;
}
 
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public NameAndNamespacePair unmarshal(NameAndNamespacePair v) throws Exception {
    if (v != null) {
        
        if (StringUtils.isBlank(v.getName())) {
            throw new UnmarshalException("Cannot import a name-and-namespace pair with a blank name");
        } else if (StringUtils.isBlank(v.getNamespaceCode())) {
            throw new UnmarshalException("Cannot import a name-and-namespace pair with a blank namespace code");
        } if (CoreServiceApiServiceLocator.getNamespaceService().getNamespace(v.getNamespaceCode()) == null) {
            throw new UnmarshalException("Cannot import a name-and-namespace pair with invalid or unknown namespace \"" +
                    v.getNamespaceCode() + "\"");
        }
        
        v.setName(new NormalizedStringAdapter().unmarshal(v.getName()));
        v.setNamespaceCode(v.getNamespaceCode());
    }
    return v;
}
 
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
 */
@Override
public NameAndNamespacePair marshal(NameAndNamespacePair v) throws Exception {
    if (v != null) {
        if (StringUtils.isBlank(v.getName())) {
            throw new MarshalException("Cannot export a name-and-namespace pair with a blank name");
        } else if (StringUtils.isBlank(v.getNamespaceCode())) {
            throw new MarshalException("Cannot export a name-and-namespace pair with a blank namespace code");
        } else if (CoreServiceApiServiceLocator.getNamespaceService().getNamespace(v.getNamespaceCode()) == null) {
            throw new MarshalException("Cannot export a name-and-namespace pair with invalid or unknown namespace \"" + v.getNamespaceCode() + "\"");
        }
        
        v.setName(new NormalizedStringAdapter().marshal(v.getName()));
        v.setNamespaceCode(v.getNamespaceCode());
    }
    return v;
}
 
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public String unmarshal(NameAndNamespacePair v) throws Exception {
    if (v != null) {
        Template permissionTemplate = KimApiServiceLocator.getPermissionService().findPermTemplateByNamespaceCodeAndName(
                v.getNamespaceCode(), new NormalizedStringAdapter().unmarshal(v.getName()));
        if (permissionTemplate == null) {
            throw new UnmarshalException("Cannot find permission template with namespace \"" + v.getNamespaceCode() + "\" and name \"" + v.getName() + "\"");
        }
        return permissionTemplate.getId();
    }
    return null;
}
 
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public String unmarshal(NameAndNamespacePair v) throws Exception {
    if (v != null) {
        KimTypeContract kimType = KimApiServiceLocator.getKimTypeInfoService().findKimTypeByNameAndNamespace(
                v.getNamespaceCode(), new NormalizedStringAdapter().unmarshal(v.getName()));
        if (kimType == null) {
            throw new UnmarshalException("Cannot find KIM Type with namespace \"" + v.getNamespaceCode() + "\" and name \"" + v.getName() + "\"");
        }
        return kimType.getId();
    }
    return null;
}
 
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public String unmarshal(NameAndNamespacePair v) throws Exception {
    if (v != null) {
        Template permissionTemplate = KimApiServiceLocator.getPermissionService().findPermTemplateByNamespaceCodeAndName(
                v.getNamespaceCode(), new NormalizedStringAdapter().unmarshal(v.getName()));
        if (permissionTemplate == null) {
            throw new UnmarshalException("Cannot find permission template with namespace \"" + v.getNamespaceCode() + "\" and name \"" + v.getName() + "\"");
        }
        return permissionTemplate.getId();
    }
    return null;
}
 
/**
 * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
 */
@Override
public String unmarshal(NameAndNamespacePair v) throws Exception {
    if (v != null) {
        KimTypeContract kimType = KimApiServiceLocator.getKimTypeInfoService().findKimTypeByNameAndNamespace(
                v.getNamespaceCode(), new NormalizedStringAdapter().unmarshal(v.getName()));
        if (kimType == null) {
            throw new UnmarshalException("Cannot find KIM Type with namespace \"" + v.getNamespaceCode() + "\" and name \"" + v.getName() + "\"");
        }
        return kimType.getId();
    }
    return null;
}
 
源代码13 项目: OpenESPI-Common-java   文件: ObjectFactory.java
/**
 * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
 */
@XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "email", scope = PersonType.class)
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
public JAXBElement<String> createPersonTypeEmail(String value) {
	return new JAXBElement<String>(PersonTypeEmail_QNAME, String.class,
			PersonType.class, value);
}
 
源代码14 项目: hyperjaxb3   文件: TypeUseTest.java
public void testEquals() throws Exception {

		final CAdapter adapter = new CAdapter(NormalizedStringAdapter.class,
				false);

		final CAdapter adapter1 = new CAdapter(NormalizedStringAdapter.class,
				false);

		final TypeUse left = CBuiltinLeafInfo.NORMALIZED_STRING;

		final TypeUse right = TypeUseFactory.adapt(CBuiltinLeafInfo.STRING,
				adapter);

//		Assert.assertTrue(adapter.equals(adapter1));
//		Assert.assertTrue(left.equals(right));
//		Assert.assertTrue(left.hashCode() == right.hashCode());

	}
 
源代码15 项目: TencentKona-8   文件: CAdapter.java
/**
 * Returns true if the adapter is for whitespace normalization.
 * Such an adapter can be ignored when producing a list.
 */
public boolean isWhitespaceAdapter() {
    return adapterClass2==CollapsedStringAdapter.class || adapterClass2==NormalizedStringAdapter.class;
}
 
源代码16 项目: jdk8u60   文件: CAdapter.java
/**
 * Returns true if the adapter is for whitespace normalization.
 * Such an adapter can be ignored when producing a list.
 */
public boolean isWhitespaceAdapter() {
    return adapterClass2==CollapsedStringAdapter.class || adapterClass2==NormalizedStringAdapter.class;
}
 
源代码17 项目: openjdk-jdk8u   文件: CAdapter.java
/**
 * Returns true if the adapter is for whitespace normalization.
 * Such an adapter can be ignored when producing a list.
 */
public boolean isWhitespaceAdapter() {
    return adapterClass2==CollapsedStringAdapter.class || adapterClass2==NormalizedStringAdapter.class;
}
 
源代码18 项目: openjdk-jdk8u-backup   文件: CAdapter.java
/**
 * Returns true if the adapter is for whitespace normalization.
 * Such an adapter can be ignored when producing a list.
 */
public boolean isWhitespaceAdapter() {
    return adapterClass2==CollapsedStringAdapter.class || adapterClass2==NormalizedStringAdapter.class;
}
 
源代码19 项目: openjdk-jdk9   文件: CAdapter.java
/**
 * Returns true if the adapter is for whitespace normalization.
 * Such an adapter can be ignored when producing a list.
 */
public boolean isWhitespaceAdapter() {
    return adapterClass2==CollapsedStringAdapter.class || adapterClass2==NormalizedStringAdapter.class;
}
 
源代码20 项目: hottub   文件: CAdapter.java
/**
 * Returns true if the adapter is for whitespace normalization.
 * Such an adapter can be ignored when producing a list.
 */
public boolean isWhitespaceAdapter() {
    return adapterClass2==CollapsedStringAdapter.class || adapterClass2==NormalizedStringAdapter.class;
}
 
源代码21 项目: openjdk-8-source   文件: CAdapter.java
/**
 * Returns true if the adapter is for whitespace normalization.
 * Such an adapter can be ignored when producing a list.
 */
public boolean isWhitespaceAdapter() {
    return adapterClass2==CollapsedStringAdapter.class || adapterClass2==NormalizedStringAdapter.class;
}
 
源代码22 项目: openjdk-8   文件: CAdapter.java
/**
 * Returns true if the adapter is for whitespace normalization.
 * Such an adapter can be ignored when producing a list.
 */
public boolean isWhitespaceAdapter() {
    return adapterClass2==CollapsedStringAdapter.class || adapterClass2==NormalizedStringAdapter.class;
}
 
 类方法
 同包方法