gpt4 book ai didi

org.n52.svalbard.util.XmlHelper.validateDocument()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 12:03:05 27 4
gpt4 key购买 nike

本文整理了Java中org.n52.svalbard.util.XmlHelper.validateDocument()方法的一些代码示例,展示了XmlHelper.validateDocument()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlHelper.validateDocument()方法的具体详情如下:
包路径:org.n52.svalbard.util.XmlHelper
类名称:XmlHelper
方法名:validateDocument

XmlHelper.validateDocument介绍

暂无

代码示例

代码示例来源:origin: org.n52.arctic-sea/svalbard

/**
 * @param doc the XML document to validate.
 * @return <code>true</code> if the given xml document is valid, else an exception is thrown.
 * @throws DecodingException thrown if the given xml document is invalid.
 */
public static boolean validateDocument(XmlObject doc) throws DecodingException {
  validateDocument(doc, DecodingException::new);
  return true;
}

代码示例来源:origin: org.n52.svalbard/svalbard

public static boolean validateDocument(XmlObject doc) throws DecodingException {
  validateDocument(doc, DecodingException::new);
  return true;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

private List<SweField> parseAnyScalarPropertyTypeArray(final AnyScalarPropertyType[] fieldArray)
    throws DecodingException {
  final List<SweField> sosFields = new ArrayList<>(fieldArray.length);
  for (final AnyScalarPropertyType xbField : fieldArray) {
    // validate document
    XmlHelper.validateDocument(xbField);
    /*
     * if (xbField.isSetBoolean()) { sosFields.add(new
     * SosSweField(xbField.getName(),
     * parseAbstractDataComponent(xbField.getBoolean()))); } else if
     * (xbField.isSetCategory()) { sosFields.add(new
     * SosSweField(xbField.getName(),
     * parseAbstractDataComponent(xbField.getCategory()))); } else if
     * (xbField.isSetCount()) { sosFields.add(new
     * SosSweField(xbField.getName(),
     * parseAbstractDataComponent(xbField.getCount()))); } else if
     * (xbField.isSetQuantity()) { sosFields.add(new
     * SosSweField(xbField.getName(),
     * parseAbstractDataComponent(xbField.getQuantity()))); } else if
     * (xbField.isSetText()) { sosFields.add(new
     * SosSweField(xbField.getName(),
     * parseAbstractDataComponent(xbField.getText()))); } else if
     * (xbField.isSetTime()) { sosFields.add(new
     * SosSweField(xbField.getName(),
     * parseAbstractDataComponent(xbField.getTime()))); }
     */
  }
  return sosFields;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(OwsServiceRequest request, EncodingContext additionalValues) throws EncodingException {
  XmlObject encodedObject = encodeRequests(request);
  XmlHelper.validateDocument(encodedObject, EncodingException::new);
  return encodedObject;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public AbstractSensorML decode(XmlObject element) throws DecodingException {
  // validate document
  XmlHelper.validateDocument(element);
  return parse(element);
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(Object sosSweType, EncodingContext additionalValues)
    throws EncodingException {
  return XmlHelper.validateDocument(encode1(sosSweType, additionalValues), EncodingException::new);
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public DeleteResultTemplateRequest decode(XmlObject xmlObject) throws DecodingException {
  LOGGER.debug(String.format("REQUESTTYPE: %s", xmlObject != null ? xmlObject.getClass() : "null recevied"));
  XmlHelper.validateDocument(xmlObject);
  if (xmlObject instanceof DeleteResultTemplateDocument) {
    DeleteResultTemplateDocument drtd = (DeleteResultTemplateDocument) xmlObject;
    DeleteResultTemplateRequest decodedRequest = parseDeleteResultTemplate(drtd);
    LOGGER.debug(String.format("Decoded request: %s", decodedRequest));
    return decodedRequest;
  } else {
    throw new UnsupportedDecoderInputException(this, xmlObject);
  }
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(AbstractFeature abstractFeature, EncodingContext context) throws EncodingException {
  XmlObject encodedObject = createFeature(abstractFeature);
  if (LOGGER.isDebugEnabled()) {
    try {
      LOGGER.debug("Encoded object {} is valid: {}", encodedObject.schemaType().toString(),
          XmlHelper.validateDocument(encodedObject));
    } catch (DecodingException e) {
      throw new EncodingException(e);
    }
  }
  return encodedObject;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(Object element, EncodingContext additionalValues)
    throws EncodingException, UnsupportedEncoderInputException {
  XmlObject encodedObject = null;
  if (element instanceof Role) {
    encodedObject = encodeRole((Role) element);
  } else {
    throw new UnsupportedEncoderInputException(this, element);
  }
  XmlHelper.validateDocument(encodedObject, EncodingException::new);
  return encodedObject;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(T response, EncodingContext additionalValues) throws EncodingException {
  if (response == null) {
    throw new UnsupportedEncoderInputException(this, (String) null);
  }
  XmlObject xml = create(response);
  setSchemaLocations(xml);
  if (validate) {
    XmlHelper.validateDocument(xml, EncodingException::new);
  }
  return xml;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public OwsServiceRequest decode(XmlObject xmlObject) throws DecodingException {
  LOGGER.debug("REQUESTTYPE:" + xmlObject.getClass());
  XmlHelper.validateDocument(xmlObject);
  if (xmlObject instanceof DescribeSensorDocument) {
    return parseDescribeSensor((DescribeSensorDocument) xmlObject);
  } else if (xmlObject instanceof InsertSensorDocument) {
    return parseInsertSensor((InsertSensorDocument) xmlObject);
  } else if (xmlObject instanceof UpdateSensorDescriptionDocument) {
    return parseUpdateSensorDescription((UpdateSensorDescriptionDocument) xmlObject);
  } else if (xmlObject instanceof DeleteSensorDocument) {
    return parseDeleteSensor((DeleteSensorDocument) xmlObject);
  } else {
    throw new UnsupportedDecoderXmlInputException(this, xmlObject);
  }
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public AbstractFeature decode(final XmlObject element) throws DecodingException {
  // validate XmlObject
  XmlHelper.validateDocument(element);
  if (element instanceof SFSpecimenDocument) {
    return parseSpatialSamplingFeature(((SFSpecimenDocument) element).getSFSpecimen());
  } else if (element instanceof SFSpecimenType) {
    return parseSpatialSamplingFeature((SFSpecimenType) element);
  }
  return super.decode(element);
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public AbstractFeature decode(XmlObject element) throws DecodingException {
  // validate XmlObject
  XmlHelper.validateDocument(element);
  if (element instanceof SFSpatialSamplingFeatureDocument) {
    return parseSpatialSamplingFeature(
        ((SFSpatialSamplingFeatureDocument) element).getSFSpatialSamplingFeature());
  } else if (element instanceof SFSpatialSamplingFeatureType) {
    return parseSpatialSamplingFeature((SFSpatialSamplingFeatureType) element);
  }
  throw new UnsupportedDecoderXmlInputException(this, element);
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@SuppressWarnings({ "rawtypes", "unchecked" })
private List<SweCoordinate<?>> parseCoordinates(Coordinate[] coordinateArray) throws DecodingException {
  List<SweCoordinate<?>> sosCoordinates = new ArrayList<>(coordinateArray.length);
  for (final Coordinate xbCoordinate : coordinateArray) {
    // validate document
    XmlHelper.validateDocument(xbCoordinate);
    if (xbCoordinate.isSetQuantity()) {
      sosCoordinates.add(new SweCoordinate(xbCoordinate.getName(),
          (SweAbstractSimpleType) parseAbstractDataComponent(xbCoordinate.getQuantity())));
    } else {
      throw new DecodingException(SweConstants.EN_POSITION,
          "Error when parsing the Coordinates of Position: It must be of type Quantity!");
    }
  }
  return sosCoordinates;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(final Object response, final EncodingContext additionalValues) throws EncodingException {
  XmlObject encodedObject = null;
  if (response instanceof AbstractSensorML) {
    encodedObject = createSensorDescription((AbstractSensorML) response);
    // }
    // FIXME workaround? if of type UnknowProcedureType try to parse the
    // description string, UNIT is missing "NOT_DEFINED"?!
    // else if (response instanceof SosProcedureDescriptionUnknownType)
    // {
    // final String procDescXMLString = ((SosProcedureDescription)
    // response).getXml();
    // final AbstractSensorML sensorDesc = new AbstractSensorML();
    // sensorDesc.setXml(procDescXMLString);
    // encodedObject = createSensorDescriptionFromString(sensorDesc);
  } else {
    throw new UnsupportedEncoderInputException(this, response);
  }
  // check if all gml:id are unique
  XmlHelper.makeGmlIdsUnique(encodedObject.getDomNode());
  XmlHelper.validateDocument(encodedObject, EncodingException::new);
  return encodedObject;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public AbstractSensorML decode(XmlObject element) throws DecodingException {
  // validate document
  XmlHelper.validateDocument(element);
  if (element instanceof SensorMLDocument) {
    return parseSensorML((SensorMLDocument) element);
  } else if (element instanceof SystemDocument) {
    return parseSystem(((SystemDocument) element).getSystem());
  } else if (element instanceof SystemType) {
    return parseSystem((SystemType) element);
  } else if (element instanceof ProcessModelType) {
    return parseProcessModel((ProcessModelType) element);
  } else {
    throw new UnsupportedDecoderXmlInputException(this, element);
  }
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
  protected XmlObject create(GetDataAvailabilityResponse response)
      throws EncodingException {
    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      EncodingContext ctx = EncodingContext.empty()
          .with(EncoderFlags.ENCODER_REPOSITORY, getEncoderRepository())
          .with(XmlEncoderFlags.XML_OPTIONS, (Supplier<XmlOptions>) this::getXmlOptions);
      if (GetDataAvailabilityConstants.NS_GDA.equals(response.getResponseFormat())) {
        new GetDataAvailabilityStreamWriter(ctx, baos, response.getDataAvailabilities()).write();
      } else if (GetDataAvailabilityConstants.NS_GDA_20.equals(response.getResponseFormat())) {
        new GetDataAvailabilityV20StreamWriter(ctx, baos, response.getDataAvailabilities()).write();
      }
      XmlObject encodedObject = XmlObject.Factory.parse(baos.toString("UTF8"));
      XmlHelper.validateDocument(encodedObject, EncodingException::new);
      return encodedObject;
    } catch (XMLStreamException | XmlException | UnsupportedEncodingException ex) {
      throw new EncodingException("Error encoding response", ex);
    }
  }
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

LOGGER.debug("REQUESTTYPE:" + xml.getClass());
XmlHelper.validateDocument(xml);
if (xml instanceof GetCapabilitiesDocument) {
  return parseGetCapabilities((GetCapabilitiesDocument) xml);

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(Object element, EncodingContext additionalValues)
    throws EncodingException {
  XmlObject encodedObject = null;
  if (element instanceof OmObservation) {
    encodedObject = createObservation((OmObservation) element, additionalValues);
  } else if (element instanceof GetObservationResponse) {
    GetObservationResponse response = (GetObservationResponse) element;
    encodedObject =
        createObservationCollection(response.getObservationCollection(), response.getResultModel());
  } else if (element instanceof GetObservationByIdResponse) {
    GetObservationByIdResponse response = (GetObservationByIdResponse) element;
    encodedObject =
        createObservationCollection(response.getObservationCollection(), response.getResultModel());
  } else {
    throw new UnsupportedEncoderInputException(this, element);
  }
  XmlHelper.validateDocument(encodedObject, EncodingException::new);
  return encodedObject;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(Object objectToEncode, EncodingContext additionalValues) throws EncodingException {
  XmlObject encodedObject = null;
  try {
    if (objectToEncode instanceof AbstractSensorML) {
      AbstractSensorML description = (AbstractSensorML) objectToEncode;
      if (description.isSetXml()) {
        encodedObject = XmlObject.Factory.parse(((AbstractSensorML) objectToEncode).getXml());
        addValuesToXmlObject(encodedObject, (AbstractSensorML) objectToEncode);
        encodedObject = checkForAdditionalValues(encodedObject, additionalValues);
      } else {
        encodedObject = encodeDescription(description, additionalValues);
      }
    } else {
      throw new UnsupportedEncoderInputException(this, objectToEncode);
    }
  } catch (XmlException xmle) {
    throw new EncodingException(xmle);
  }
  // check if all gml:id are unique
  XmlHelper.makeGmlIdsUnique(encodedObject.getDomNode());
  XmlHelper.validateDocument(encodedObject, EncodingException::new);
  return encodedObject;
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com