Example usage for javax.xml.bind JAXBElement getName

List of usage examples for javax.xml.bind JAXBElement getName

Introduction

In this page you can find the example usage for javax.xml.bind JAXBElement getName.

Prototype

public QName getName() 

Source Link

Document

Returns the xml element tag name.

Usage

From source file:be.fedict.eid.dss.spi.utils.XAdESUtils.java

@SuppressWarnings("unchecked")
public static <T> T findUnsignedSignatureProperty(QualifyingPropertiesType qualifyingProperties,
        Class<T> declaredType, String name) {

    UnsignedPropertiesType unsignedProperties = qualifyingProperties.getUnsignedProperties();
    UnsignedSignaturePropertiesType unsignedSignatureProperties = unsignedProperties
            .getUnsignedSignatureProperties();
    List<Object> unsignedSignaturePropertiesContentList = unsignedSignatureProperties
            .getCounterSignatureOrSignatureTimeStampOrCompleteCertificateRefs();
    for (Object unsignedSignatureProperty : unsignedSignaturePropertiesContentList) {
        if (!(unsignedSignatureProperty instanceof JAXBElement)) {
            continue;
        }/* ww  w . jav a  2  s  .  co m*/
        JAXBElement<?> unsignedSignaturePropertyElement = (JAXBElement<?>) unsignedSignatureProperty;
        Object unsignedSignaturePropertyValue = unsignedSignaturePropertyElement.getValue();
        if (unsignedSignaturePropertyValue.getClass().isAssignableFrom(declaredType)) {

            if (null == name) {
                return (T) unsignedSignaturePropertyValue;
            } else if (unsignedSignaturePropertyElement.getName().getLocalPart().equals(name)) {
                return (T) unsignedSignaturePropertyValue;
            }
        }
    }

    return null;
}

From source file:com.hp.autonomy.idol.parametricvalues.IdolParametricValuesService.java

@Override
public Set<QueryTagInfo> getAllParametricValues(final IdolParametricRequest idolParametricRequest)
        throws AciErrorException {
    final Collection<String> fieldNames = new HashSet<>();
    fieldNames.addAll(idolParametricRequest.getFieldNames());
    if (fieldNames.isEmpty()) {
        fieldNames.addAll(getTagNames());
    }/*from   w w  w  .j a v a 2  s  . c  om*/

    final Set<QueryTagInfo> results;
    if (fieldNames.isEmpty()) {
        results = Collections.emptySet();
    } else {
        final AciParameters aciParameters = new AciParameters(TagActions.GetQueryTagValues.name());
        aciParameters.add(QueryParams.Combine.name(), CombineParam.Simple);
        aciParameters.add(QueryParams.Text.name(), idolParametricRequest.getQueryText());
        aciParameters.add(QueryParams.FieldText.name(), idolParametricRequest.getFieldText());
        aciParameters.add(QueryParams.DatabaseMatch.name(),
                new Databases(idolParametricRequest.getDatabases()));
        aciParameters.add(QueryParams.MinDate.name(), formatDate(idolParametricRequest.getMinDate()));
        aciParameters.add(QueryParams.MaxDate.name(), formatDate(idolParametricRequest.getMaxDate()));
        aciParameters.add(QueryParams.AnyLanguage.name(), true);
        aciParameters.add(GetQueryTagValuesParams.DocumentCount.name(), true);
        aciParameters.add(GetQueryTagValuesParams.MaxValues.name(), MAX_VALUES);
        aciParameters.add(GetQueryTagValuesParams.FieldName.name(),
                StringUtils.join(fieldNames.toArray(), ','));
        aciParameters.add(GetQueryTagValuesParams.Sort.name(), SortParam.DocumentCount.name());

        final GetQueryTagValuesResponseData responseData = contentAciService.executeAction(aciParameters,
                queryTagValuesResponseProcessor);
        final List<FlatField> fields = responseData.getField();
        results = new LinkedHashSet<>(fields.size());
        for (final FlatField field : fields) {
            final List<JAXBElement<? extends Serializable>> valueElements = field.getValueOrSubvalueOrValues();
            final LinkedHashSet<QueryTagCountInfo> values = new LinkedHashSet<>(valueElements.size());
            for (final JAXBElement<?> element : valueElements) {
                if (VALUE_NODE_NAME.equals(element.getName().getLocalPart())) {
                    final TagValue tagValue = (TagValue) element.getValue();
                    values.add(new QueryTagCountInfo(tagValue.getValue(), tagValue.getCount()));
                }
            }
            final String fieldName = getFieldNameFromPath(field.getName().get(0));
            if (!values.isEmpty()) {
                results.add(new QueryTagInfo(fieldName, values));
            }
        }
    }

    return results;
}

From source file:com.hp.autonomy.searchcomponents.idol.parametricvalues.IdolParametricValuesService.java

@Override
public Set<QueryTagInfo> getAllParametricValues(final IdolParametricRequest parametricRequest)
        throws AciErrorException {
    final Collection<String> fieldNames = new HashSet<>();
    fieldNames.addAll(parametricRequest.getFieldNames());
    if (fieldNames.isEmpty()) {
        fieldNames.addAll(fieldsService.getParametricFields(new IdolFieldsRequest.Builder().build()));
    }/*w  ww  .j a  v  a2s  .  com*/

    final Set<QueryTagInfo> results;
    if (fieldNames.isEmpty()) {
        results = Collections.emptySet();
    } else {
        final AciParameters aciParameters = new AciParameters(TagActions.GetQueryTagValues.name());
        parameterHandler.addSearchRestrictions(aciParameters, parametricRequest.getQueryRestrictions());

        if (parametricRequest.isModified()) {
            parameterHandler.addQmsParameters(aciParameters, parametricRequest.getQueryRestrictions());
        }

        aciParameters.add(GetQueryTagValuesParams.DocumentCount.name(), true);
        aciParameters.add(GetQueryTagValuesParams.MaxValues.name(), parametricRequest.getMaxValues());
        aciParameters.add(GetQueryTagValuesParams.FieldName.name(),
                StringUtils.join(fieldNames.toArray(), ','));
        aciParameters.add(GetQueryTagValuesParams.Sort.name(), SortParam.DocumentCount.name());

        final GetQueryTagValuesResponseData responseData = contentAciService.executeAction(aciParameters,
                queryTagValuesResponseProcessor);
        final List<FlatField> fields = responseData.getField();
        results = new LinkedHashSet<>(fields.size());
        for (final FlatField field : fields) {
            final List<JAXBElement<? extends Serializable>> valueElements = field.getValueOrSubvalueOrValues();
            final LinkedHashSet<QueryTagCountInfo> values = new LinkedHashSet<>(valueElements.size());
            for (final JAXBElement<?> element : valueElements) {
                if (VALUE_NODE_NAME.equals(element.getName().getLocalPart())) {
                    final TagValue tagValue = (TagValue) element.getValue();
                    values.add(new QueryTagCountInfo(tagValue.getValue(), tagValue.getCount()));
                }
            }
            final String fieldName = getFieldNameFromPath(field.getName().get(0));
            if (!values.isEmpty()) {
                results.add(new QueryTagInfo(fieldName, values));
            }
        }
    }

    return results;
}

From source file:org.apache.taverna.scufl2.translator.t2flow.defaultactivities.AbstractActivityParser.java

/**
 * Deals with the not-so-helpful//w w  w.ja v  a  2  s  .co  m
 * getHandledReferenceSchemesOrTranslatedElementTypeOrName method
 * 
 * @param portBean
 * @param elementName
 * @return
 */
private <T> T getPortElement(ActivityPortDefinitionBean portBean, String elementName, Class<T> type) {
    for (JAXBElement<?> elem : portBean.getHandledReferenceSchemesOrTranslatedElementTypeOrName())
        if (elem.getName().getLocalPart().equals(elementName))
            return type.cast(elem.getValue());
    return null;
}

From source file:com.evolveum.midpoint.model.impl.dataModel.dot.DotMappingRelation.java

@Override
public String getNodeStyleAttributes() {
    ExpressionType expression = getMapping().getExpression();
    if (expression == null || expression.getExpressionEvaluator().isEmpty()) {
        return "";
    }//  w  w  w  . java 2s  . c  o  m
    JAXBElement<?> evalElement = expression.getExpressionEvaluator().get(0);
    Object eval = evalElement.getValue();
    if (QNameUtil.match(evalElement.getName(), SchemaConstants.C_VALUE)) {
        return "style=filled, fillcolor=ivory";
    } else if (eval instanceof AsIsExpressionEvaluatorType) {
        return "";
    } else if (eval instanceof ScriptExpressionEvaluatorType) {
        return "style=filled, fillcolor=wheat";
    } else {
        return "";
    }
}

From source file:com.evolveum.midpoint.model.impl.dataModel.dot.DotMappingRelation.java

private String getTooltipString() {
    ExpressionType expression = getMapping().getExpression();
    if (expression == null || expression.getExpressionEvaluator().isEmpty()) {
        return "asIs";
    }/*  w w w  .j av  a 2  s  .  c o m*/
    JAXBElement<?> evalElement = expression.getExpressionEvaluator().get(0);
    Object eval = evalElement.getValue();
    if (QNameUtil.match(evalElement.getName(), SchemaConstants.C_VALUE)) {
        return getStringConstant(eval);
    } else if (eval instanceof AsIsExpressionEvaluatorType) {
        return "asIs";
    } else if (eval instanceof ScriptExpressionEvaluatorType) {
        return ((ScriptExpressionEvaluatorType) eval).getCode();
    } else if (eval instanceof ItemPathType) {
        return String.valueOf(((ItemPathType) eval).getItemPath());
    } else {
        return "";
    }
}

From source file:be.fedict.eid.pkira.xkmsws.util.XMLMarshallingUtil.java

/**
 * Extracts the first element from the list matching the type.
 * /*from w ww  .j a  v  a  2s  .c  om*/
 * @param name
 *            name of the element to get.
 * @param list
 *            list with either this type of a JAXBElement with this type.
 * @return the first matching element.
 */
public Object getFromJAXBElementList(List<Object> list, String name) {
    for (Object object : list) {
        if (object instanceof JAXBElement<?>) {
            JAXBElement<?> element = (JAXBElement<?>) object;
            if (name.equals(element.getName().getLocalPart())) {
                return element.getValue();
            }
        } else if (object instanceof Element) {
            Element element = (Element) object;
            if (name.equals(element.getLocalName())) {
                return element.getTextContent().trim();
            }
        }
    }

    return null;
}

From source file:edu.cornell.mannlib.vivo.orcid.controller.OrcidConfirmationState.java

private String getElementFromOrcidIdentifier(String elementName) {
    OrcidProfile orcidProfile = getOrcidProfile();
    if (orcidProfile == null) {
        return "";
    }/*from  ww w. j  a  va2s . c  o m*/

    OrcidId id = orcidProfile.getOrcidIdentifier();
    if (id == null) {
        log.warn("There is no ORCID Identifier in the profile.");
        return "";
    }

    List<JAXBElement<String>> idElements = id.getContent();
    if (idElements != null) {
        for (JAXBElement<String> idElement : idElements) {
            QName name = idElement.getName();
            if (name != null && elementName.equals(name.getLocalPart())) {
                String value = idElement.getValue();
                if (value != null) {
                    return value;
                }
            }
        }
    }
    log.warn("Didn't find the element '' in the ORCID Identifier: " + idElements);
    return "";
}

From source file:com.evolveum.midpoint.model.impl.dataModel.dot.DotMappingRelation.java

@Nullable
private String getLabel(String defaultLabel, boolean showConstant) {
    ExpressionType expression = getMapping().getExpression();
    if (expression == null || expression.getExpressionEvaluator().isEmpty()) {
        return defaultLabel;
    }//ww w. ja  v  a  2s . co  m
    if (expression.getExpressionEvaluator().size() > 1) {
        return "> 1 evaluator"; // TODO multivalues
    }
    JAXBElement<?> evalElement = expression.getExpressionEvaluator().get(0);
    Object eval = evalElement.getValue();
    if (QNameUtil.match(evalElement.getName(), SchemaConstants.C_VALUE)) {
        if (showConstant) {
            String str = getStringConstant(eval);
            return "\'" + StringUtils.abbreviate(str, MAX_CONSTANT_WIDTH) + "\'";
        } else {
            return "constant";
        }
    } else if (eval instanceof AsIsExpressionEvaluatorType) {
        return defaultLabel;
    } else if (eval instanceof ScriptExpressionEvaluatorType) {
        ScriptExpressionEvaluatorType script = (ScriptExpressionEvaluatorType) eval;
        if (script.getLanguage() == null) {
            return "groovy";
        } else {
            return StringUtils.substringAfter(script.getLanguage(), "#");
        }
    } else {
        return evalElement.getName().getLocalPart();
    }
}

From source file:com.provenance.cloudprovenance.sconverter.PolicyResponseConverter.java

public String marhsallObject(PolicyResponse pResponse) {

    JAXBContext jaxbContext;//www.  j ava2 s  . c o  m
    StringWriter sw = new StringWriter();

    try {
        jaxbContext = JAXBContext.newInstance(instanceDir);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", cProvPrefixMapper);

        JAXBElement<PolicyResponse> el = pFactory.createPolicyResponse(pResponse);

        marshaller.marshal(el, sw);

        logger.info("Sucessfully marshalled the policy objects: " + el.getName());

    } catch (JAXBException e) {
        e.printStackTrace();
    }

    return sw.toString();
}