javax.xml.bind.annotation.adapters.NormalizedStringAdapter Java Examples

The following examples show how to use javax.xml.bind.annotation.adapters.NormalizedStringAdapter. 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: NameAndNamespacePairValidatingAdapter.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #2
Source File: NameAndNamespacePairValidatingAdapter.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #3
Source File: PermissionDetailListAdapter.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #4
Source File: QualificationListAdapter.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #5
Source File: NameAndNamespacePairValidatingAdapter.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #6
Source File: NameAndNamespacePairValidatingAdapter.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #7
Source File: PermissionDetailListAdapter.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #8
Source File: QualificationListAdapter.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #9
Source File: ObjectFactory.java    From OpenESPI-Common-java with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: NameAndNamespacePairToKimTypeIdAdapter.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #11
Source File: NameAndNamespacePairToPermTemplateIdAdapter.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #12
Source File: NameAndNamespacePairToKimTypeIdAdapter.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #13
Source File: NameAndNamespacePairToPermTemplateIdAdapter.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #14
Source File: TypeUseTest.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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());

	}
 
Example #15
Source File: CAdapter.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #16
Source File: CAdapter.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #17
Source File: CAdapter.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #18
Source File: CAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #19
Source File: CAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source File: CAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #21
Source File: CAdapter.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #22
Source File: CAdapter.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}