Example usage for javax.xml.registry.infomodel LocalizedString getValue

List of usage examples for javax.xml.registry.infomodel LocalizedString getValue

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel LocalizedString getValue.

Prototype

String getValue() throws JAXRException;

Source Link

Document

Get the String value for this object.

Usage

From source file:it.cnr.icar.eric.client.xml.registry.infomodel.InternationalStringImpl.java

/**
 * Gets the localized value of an InternationalString for a given Locale or
 * the closest match, according to a precedence list (see {@link
 * #getClosestKeys(java.util.Locale, java.lang.String) getClosestKeys(
 * java.util.Locale, java.lang.String)}.
 *
 * @param locale the desired Locale// ww w.  java 2 s  . c  om
 * @return String with LocalizedString's value for 'locale' or for the 1st
 *         alternate Locale found. Null if nothing found.
 */
public String getClosestValue(Locale locale) throws JAXRException {
    LocalizedString lString = getClosestLocalizedString(locale, null);

    if (lString != null) {
        return lString.getValue();
    }

    return null;
}

From source file:it.cnr.icar.eric.client.xml.registry.infomodel.InternationalStringImpl.java

public String getValue(Locale locale) throws JAXRException {
    String value = null;/*from   ww  w  .  j  av a2 s .  c  o m*/
    LocalizedString ls = localizedStringMap.get(getKey(locale, LocalizedStringImpl.DEFAULT_CHARSET_NAME));

    if (ls != null) {
        value = ls.getValue();
    }

    return value;
}

From source file:it.cnr.icar.eric.client.ui.common.UIUtility.java

public Object convertValue(Object value, Locale locale, String charSet) {
    Object finalValue = null;/*from   w  w  w  . j  a v a2  s  . c  om*/

    try {
        if (value instanceof InternationalString) {
            LocalizedString iString = ((InternationalStringImpl) value).getClosestLocalizedString(locale,
                    charSet);
            // LS might be null
            if (iString == null) {
                value = "";
            } else {
                value = iString.getValue();
            }
        }
        if (value instanceof ExternalLink) {
            finalValue = ((ExternalLink) value).getExternalURI();

            try {
                URL url = new URL(((ExternalLink) value).getExternalURI());
                finalValue = url;
            } catch (MalformedURLException e) {
                finalValue = null;
            }
        } else if (value instanceof Collection) {
            //Converts elements of Collection
            Collection<?> c1 = (Collection<?>) value;
            Collection<Object> c2 = new ArrayList<Object>();
            Iterator<?> iter = c1.iterator();

            while (iter.hasNext()) {
                c2.add(convertValue(iter.next()));
            }

            finalValue = c2;
        } else if (value instanceof Slot) {
            Collection<?> c = ((Slot) value).getValues();
            finalValue = c;
        } else if (value instanceof Concept) {
            finalValue = ((Concept) value).getValue();
        } else {
            finalValue = value;
        }
    } catch (JAXRException e) {
        log.error(e);
    }

    return finalValue;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

private String getLocalizedNameString(RegistryObject ro) throws JAXRException {
    String nameValue = null;//from   ww w . j  av a 2  s.c om
    LocalizedString lsName = ((InternationalStringImpl) ro.getName()).getClosestLocalizedString(getLocale(),
            getCharset());

    if (lsName != null) {
        nameValue = lsName.getValue();
    }
    if (nameValue == null) {
        nameValue = "";
    }
    return nameValue;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

private String getLocalizedDescriptionString(RegistryObject ro) throws JAXRException {
    String descValue = null;//from  ww w.  j a  va 2s  . c  o m
    LocalizedString lsDesc = ((InternationalStringImpl) ro.getDescription())
            .getClosestLocalizedString(getLocale(), getCharset());

    if (lsDesc != null) {
        descValue = lsDesc.getValue();
    }
    if (descValue == null) {
        descValue = "";
    }
    return descValue;
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerImpl.java

static Name[] mapNamePatterns(Collection namePatterns) throws JAXRException {
    if (namePatterns == null)
        return null;
    Name[] result = new Name[namePatterns.size()];
    int currLoc = 0;
    for (Iterator i = namePatterns.iterator(); i.hasNext();) {
        Object obj = i.next();/*from  w  ww . java  2  s .c om*/
        Name name = objectFactory.createName();
        if (obj instanceof String) {
            name.setValue((String) obj);
        } else if (obj instanceof LocalizedString) {
            LocalizedString ls = (LocalizedString) obj;
            name.setValue(ls.getValue());
            name.setLang(ls.getLocale().getLanguage());
        }
        result[currLoc] = name;
        currLoc++;
    }
    return result;
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

public static BindingTemplate getBindingTemplateFromJAXRSB(ServiceBinding serviceBinding) throws JAXRException {
    BindingTemplate bt = objectFactory.createBindingTemplate();
    if (serviceBinding.getKey() != null && serviceBinding.getKey().getId() != null) {
        bt.setBindingKey(serviceBinding.getKey().getId());
    } else {/*  w w  w  . j  av a 2  s .co  m*/
        bt.setBindingKey("");
    }

    try {
        // Set Access URI
        String accessuri = serviceBinding.getAccessURI();
        if (accessuri != null) {
            AccessPoint accessPoint = objectFactory.createAccessPoint();
            accessPoint.setURLType(getURLType(accessuri));
            accessPoint.setValue(accessuri);
            bt.setAccessPoint(accessPoint);
        }
        ServiceBinding sb = serviceBinding.getTargetBinding();
        if (sb != null) {
            HostingRedirector red = objectFactory.createHostingRedirector();
            Key key = sb.getKey();
            if (key != null && key.getId() != null) {
                red.setBindingKey(key.getId());
            } else {
                red.setBindingKey("");
            }
            bt.setHostingRedirector(red);
        } else {
            if (bt.getAccessPoint() == null) {
                bt.setAccessPoint(objectFactory.createAccessPoint());
            }
        }
        // TODO:Need to look further at the mapping b/w BindingTemplate and
        // Jaxr ServiceBinding

        // Get Service information
        Service svc = serviceBinding.getService();
        if (svc != null && svc.getKey() != null && svc.getKey().getId() != null) {
            bt.setServiceKey(svc.getKey().getId());
        }

        InternationalString idesc = serviceBinding.getDescription();

        addDescriptions(bt.getDescription(), idesc);

        // SpecificationLink
        Collection<SpecificationLink> slcol = serviceBinding.getSpecificationLinks();
        TModelInstanceDetails tid = objectFactory.createTModelInstanceDetails();
        if (slcol != null && !slcol.isEmpty()) {
            Iterator<SpecificationLink> iter = slcol.iterator();
            while (iter.hasNext()) {
                SpecificationLink slink = (SpecificationLink) iter.next();

                TModelInstanceInfo emptyTInfo = objectFactory.createTModelInstanceInfo();
                tid.getTModelInstanceInfo().add(emptyTInfo);

                RegistryObject specificationObject = slink.getSpecificationObject();
                if (specificationObject.getKey() != null && specificationObject.getKey().getId() != null) {
                    emptyTInfo.setTModelKey(specificationObject.getKey().getId());
                    if (specificationObject.getDescription() != null) {
                        for (Object o : specificationObject.getDescription().getLocalizedStrings()) {
                            LocalizedString locDesc = (LocalizedString) o;
                            Description description = objectFactory.createDescription();
                            emptyTInfo.getDescription().add(description);
                            description.setValue(locDesc.getValue());
                            description.setLang(locDesc.getLocale().getLanguage());
                        }
                    }
                    Collection<ExternalLink> externalLinks = slink.getExternalLinks();
                    if (externalLinks != null && externalLinks.size() > 0) {
                        for (ExternalLink link : externalLinks) {
                            InstanceDetails ids = objectFactory.createInstanceDetails();
                            emptyTInfo.setInstanceDetails(ids);
                            if (link.getDescription() != null) {
                                Description description = objectFactory.createDescription();
                                ids.getDescription().add(description);
                                description.setValue(link.getDescription().getValue());
                            }
                            if (link.getExternalURI() != null) {
                                OverviewDoc overviewDoc = objectFactory.createOverviewDoc();
                                ids.setOverviewDoc(overviewDoc);
                                overviewDoc.setOverviewURL(link.getExternalURI());
                            }
                        }
                    }
                }
            }
        }
        bt.setTModelInstanceDetails(tid);
        log.debug("BindingTemplate=" + bt.toString());
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return bt;
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

private static void addDescriptions(List<Description> descripions, InternationalString idesc)
        throws JAXRException {
    if (idesc != null) {
        for (Object o : idesc.getLocalizedStrings()) {
            LocalizedString locName = (LocalizedString) o;
            Description desc = objectFactory.createDescription();
            descripions.add(desc);//  w w w  .j a  va2s. c o m
            desc.setValue(locName.getValue());
            desc.setLang(locName.getLocale().getLanguage());
        }
    }
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

private static Name getFirstName(InternationalString iname) throws JAXRException {
    for (Object o : iname.getLocalizedStrings()) {
        LocalizedString locName = (LocalizedString) o;
        Name name = objectFactory.createName();
        name.setValue(locName.getValue());
        name.setLang(locName.getLocale().getLanguage());
        return name;
    }//from  w w  w.  j  a  v a2s .co m
    return null;
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

private static void addNames(List<Name> names, InternationalString iname) throws JAXRException {
    for (Object o : iname.getLocalizedStrings()) {
        LocalizedString locName = (LocalizedString) o;
        Name name = objectFactory.createName();
        name.setValue(locName.getValue());
        name.setLang(locName.getLocale().getLanguage());
        names.add(name);/*from  www .ja  v a2 s.  c om*/
    }
}