Package org.apache.sis.xml

Examples of org.apache.sis.xml.ValueConverter


         * Try to guess if the UOM is a URN or URL. We looks for character that are usually
         * part of URI but not part of unit symbols, for example ':'. We can not search for
         * '/' and '.' since they are part of UCUM representation.
         */
        final Context context = Context.current();
        final ValueConverter converter = Context.converter(context);
        if (uom.indexOf(':') >= 0) {
            final URI uri = converter.toURI(context, uom);
            String part = uri.getFragment();
            if (part != null) {
                uom = part;
                int i = uom.lastIndexOf("@gml:id=");
                if (i >= 0) {
                    i += 8; // 8 is the length of "@gml:id="
                    for (final int length=uom.length(); i<length;) {
                        final int c = uom.codePointAt(i);
                        if (!Character.isWhitespace(c)) {
                            if (c == '\'') i++;
                            break;
                        }
                        i += Character.charCount(c);
                    }
                    final int stop = uom.lastIndexOf('\'');
                    uom = CharSequences.trimWhitespaces((stop > i) ? uom.substring(i, stop) : uom.substring(i));
                }
            } else if ((part = uri.getPath()) != null) {
                uom = new File(part).getName();
            }
        }
        unit = converter.toUnit(context, uom);
    }
View Full Code Here


     * @param  context The current context, or {@code null} if none.
     * @return The current value converter (never null).
     */
    public static ValueConverter converter(final Context context) {
        if (context != null) {
            final ValueConverter converter = context.converter;
            if (converter != null) {
                return converter;
            }
        }
        return ValueConverter.DEFAULT;
View Full Code Here

     *
     * @throws IllegalArgumentException If the UUID is already assigned to an other object.
     */
    private void setUUID(String id) {
        final Context context = Context.current();
        final ValueConverter converter = Context.converter(context);
        final UUID uuid;
        try {
            uuid = converter.toUUID(context, id);
        } catch (IllegalArgumentException e) {
            // IF we can not store the value as a UUID, store it as a String.
            Context.warningOccured(context, this, ISOMetadata.class, "setUUID", e, false);
            id = CharSequences.trimWhitespaces(id);
            if (id != null && !id.isEmpty()) {
View Full Code Here

            }
            case NonMarshalledAuthority.HREF: {
                URI uri = null;
                if (code != null) {
                    context = Context.current();
                    final ValueConverter converter = Context.converter(context);
                    try {
                        uri = converter.toURI(context, code);
                    } catch (URISyntaxException e) {
                        exception = e;
                        removed = setHRef(null);
                        type = URI.class;
                        break;
View Full Code Here

                case NonMarshalledAuthority.ID: {
                    return new SpecializedIdentifier<String>(IdentifierSpace.ID, code);
                }
                case NonMarshalledAuthority.UUID: {
                    final Context context = Context.current();
                    final ValueConverter converter = Context.converter(context);
                    try {
                        return new SpecializedIdentifier<UUID>(IdentifierSpace.UUID, converter.toUUID(context, code));
                    } catch (IllegalArgumentException e) {
                        parseFailure(context, code, UUID.class, e);
                        break;
                    }
                }
                case NonMarshalledAuthority.HREF:
                case NonMarshalledAuthority.XLINK: {
                    final Context context = Context.current();
                    final ValueConverter converter = Context.converter(context);
                    final URI href;
                    try {
                        href = converter.toURI(context, code);
                    } catch (URISyntaxException e) {
                        parseFailure(context, code, URI.class, e);
                        break;
                    }
                    if (ordinal == NonMarshalledAuthority.HREF) {
View Full Code Here

     * @param  context The current context, or {@code null} if none.
     * @return The current value converter (never null).
     */
    public static ValueConverter converter(final Context context) {
        if (context != null) {
            final ValueConverter converter = context.converter;
            if (converter != null) {
                return converter;
            }
        }
        return ValueConverter.DEFAULT;
View Full Code Here

TOP

Related Classes of org.apache.sis.xml.ValueConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.