/** * Replace any tab, CR, and LF by a whitespace character ' ', * as specified in <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">the whitespace facet 'replace'</a> */ public String unmarshal(String text) { if(text==null) return null; // be defensive int i=text.length()-1; // look for the first whitespace char. while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) ) i--; if( i<0 ) // no such whitespace. replace(text)==text. return text; // we now know that we need to modify the text. // allocate a char array to do it. char[] buf = text.toCharArray(); buf[i--] = ' '; for( ; i>=0; i-- ) if( isWhiteSpaceExceptSpace(buf[i])) buf[i] = ' '; return new String(buf); }
/** * @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; }
@Override public JSAssignmentExpression createValue(MappingCompiler<T, C> mappingCompiler, String item) { return mappingCompiler.getCodeModel().string(normalizedStringAdapter.unmarshal(item)); } }
/** * @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 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; }
@Override public JSAssignmentExpression createValue(MappingCompiler<T, C> mappingCompiler, String item) { return mappingCompiler.getCodeModel().string(normalizedStringAdapter.unmarshal(item)); } }
public String unmarshal(String v) { if (v == null) { return null; } int i; for (i = v.length() - 1; i >= 0 && !isWhiteSpaceExceptSpace(v.charAt(i)); i--); if (i < 0) { return v; } char buf[] = v.toCharArray(); buf[i--] = ' '; for(; i >= 0; i--) { if(isWhiteSpaceExceptSpace(buf[i])) { buf[i] = ' '; } } return new String(buf); }
/** * @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; }
@Override public JsonValue createValue(JsonSchemaMappingCompiler<T, C> mappingCompiler, String item) { final JsonArrayBuilder arrayBuilder = mappingCompiler.getJsonBuilderFactory().createArrayBuilder(); return arrayBuilder.add(normalizedStringAdapter.unmarshal(item)).build().get(0); } }
public String unmarshal(String v) { if (v == null) { return null; } int i; for (i = v.length() - 1; i >= 0 && !isWhiteSpaceExceptSpace(v.charAt(i)); i--); if (i < 0) { return v; } char buf[] = v.toCharArray(); buf[i--] = ' '; for(; i >= 0; i--) { if(isWhiteSpaceExceptSpace(buf[i])) { buf[i] = ' '; } } return new String(buf); }
/** * @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; }
@Override public JsonValue createValue(JsonSchemaMappingCompiler<T, C> mappingCompiler, String item) { final JsonArrayBuilder arrayBuilder = mappingCompiler.getJsonBuilderFactory().createArrayBuilder(); return arrayBuilder.add(normalizedStringAdapter.unmarshal(item)).build().get(0); } }
public String unmarshal(String v) { if (v == null) { return null; } int i; for (i = v.length() - 1; i >= 0 && !isWhiteSpaceExceptSpace(v.charAt(i)); i--); if (i < 0) { return v; } char buf[] = v.toCharArray(); buf[i--] = ' '; for(; i >= 0; i--) { if(isWhiteSpaceExceptSpace(buf[i])) { buf[i] = ' '; } } return new String(buf); }
/** * @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; }
public String unmarshal(String v) { if (v == null) { return null; } int i; for (i = v.length() - 1; i >= 0 && !isWhiteSpaceExceptSpace(v.charAt(i)); i--); if (i < 0) { return v; } char buf[] = v.toCharArray(); buf[i--] = ' '; for(; i >= 0; i--) { if(isWhiteSpaceExceptSpace(buf[i])) { buf[i] = ' '; } } return new String(buf); }
/** * Replace any tab, CR, and LF by a whitespace character ' ', * as specified in <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">the whitespace facet 'replace'</a> */ public String unmarshal(String text) { if(text==null) return null; // be defensive int i=text.length()-1; // look for the first whitespace char. while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) ) i--; if( i<0 ) // no such whitespace. replace(text)==text. return text; // we now know that we need to modify the text. // allocate a char array to do it. char[] buf = text.toCharArray(); buf[i--] = ' '; for( ; i>=0; i-- ) if( isWhiteSpaceExceptSpace(buf[i])) buf[i] = ' '; return new String(buf); }
/** * Replace any tab, CR, and LF by a whitespace character ' ', * as specified in <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">the whitespace facet 'replace'</a> */ public String unmarshal(String text) { if(text==null) return null; // be defensive int i=text.length()-1; // look for the first whitespace char. while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) ) i--; if( i<0 ) // no such whitespace. replace(text)==text. return text; // we now know that we need to modify the text. // allocate a char array to do it. char[] buf = text.toCharArray(); buf[i--] = ' '; for( ; i>=0; i-- ) if( isWhiteSpaceExceptSpace(buf[i])) buf[i] = ' '; return new String(buf); }
/** * Replace any tab, CR, and LF by a whitespace character ' ', * as specified in <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">the whitespace facet 'replace'</a> */ public String unmarshal(String text) { if(text==null) return null; // be defensive int i=text.length()-1; // look for the first whitespace char. while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) ) i--; if( i<0 ) // no such whitespace. replace(text)==text. return text; // we now know that we need to modify the text. // allocate a char array to do it. char[] buf = text.toCharArray(); buf[i--] = ' '; for( ; i>=0; i-- ) if( isWhiteSpaceExceptSpace(buf[i])) buf[i] = ' '; return new String(buf); }
/** * Replace any tab, CR, and LF by a whitespace character ' ', * as specified in <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">the whitespace facet 'replace'</a> */ public String unmarshal(String text) { if(text==null) return null; // be defensive int i=text.length()-1; // look for the first whitespace char. while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) ) i--; if( i<0 ) // no such whitespace. replace(text)==text. return text; // we now know that we need to modify the text. // allocate a char array to do it. char[] buf = text.toCharArray(); buf[i--] = ' '; for( ; i>=0; i-- ) if( isWhiteSpaceExceptSpace(buf[i])) buf[i] = ' '; return new String(buf); }
/** * Replace any tab, CR, and LF by a whitespace character ' ', * as specified in <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">the whitespace facet 'replace'</a> */ public String unmarshal(String text) { if(text==null) return null; // be defensive int i=text.length()-1; // look for the first whitespace char. while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) ) i--; if( i<0 ) // no such whitespace. replace(text)==text. return text; // we now know that we need to modify the text. // allocate a char array to do it. char[] buf = text.toCharArray(); buf[i--] = ' '; for( ; i>=0; i-- ) if( isWhiteSpaceExceptSpace(buf[i])) buf[i] = ' '; return new String(buf); }