gpt4 book ai didi

org.deegree.commons.xml.stax.XMLStreamReaderWrapper类的使用及代码示例

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

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

XMLStreamReaderWrapper介绍

[英]TODO add documentation here
[中]TODO在此处添加文档

代码示例

代码示例来源:origin: deegree/deegree3

@Override
  public XMLStreamReaderWrapper work( InputStream in )
              throws IOException {
    try {
      return new XMLStreamReaderWrapper( XmlHttpUtils.xmlInputFactory.createXMLStreamReader( in ),
                        "Post response" );
    } catch ( XMLStreamException e ) {
      throw new IOException( "Error creating XMLStreamReader for POST response: " + e.getMessage() );
    }
  }
};

代码示例来源:origin: deegree/deegree3

private Geometry parseGeometryProperty( XMLStreamReaderWrapper xmlStream, ICRS crs )
            throws XMLStreamException {
  Geometry geometry = null;
  String href = xmlStream.getAttributeValue( CommonNamespaces.XLNNS, "href" );
  if ( href != null && href.length() > 0 ) {
    LOG.debug( "Found geometry reference (xlink): '" + href + "'" );
    geometry = new GeometryReference<Geometry>( idContext, href, xmlStream.getSystemId() );
    idContext.addReference( (GeometryReference<?>) geometry );
    if ( xmlStream.nextTag() == XMLStreamConstants.START_ELEMENT ) {
      String msg = "Unexpected element '" + xmlStream.getName()
             + "'. Geometry value has already been specified using xlink.";
      throw new XMLParsingException( xmlStream, msg );
    }
  } else if ( xmlStream.nextTag() == XMLStreamConstants.START_ELEMENT ) {
    geometry = parse( xmlStream, crs );
    xmlStream.nextTag();
  } else {
    String msg = "Error in geometry property element. Expected a 'gml:_Geometry' element or an 'xlink:href' attribute.";
    throw new XMLParsingException( xmlStream, msg );
  }
  return geometry;
}

代码示例来源:origin: deegree/deegree3

@Override
public void require( int type, String namespaceURI, String localName )
            throws XMLStreamException {
  if ( getEventType() != type ) {
    String msg = "Expected event type " + type + ", but found " + getCurrentEventInfo();
    throw new XMLParsingException( this, msg );
  }
  if ( type == START_ELEMENT || type == END_ELEMENT ) {
    if ( !getName().equals( new QName( namespaceURI, localName ) ) ) {
      String msg = "Expected {" + namespaceURI + "}" + localName + ", but found: " + getCurrentEventInfo();
      throw new XMLParsingException( this, msg );
    }
  }
}

代码示例来源:origin: deegree/deegree3

public int getElementTextAsPositiveInteger( String namespaceURI, String localName )
            throws XMLParsingException, XMLStreamException {
  require( START_ELEMENT, namespaceURI, localName );
  return getElementTextAsPositiveInteger();
}

代码示例来源:origin: deegree/deegree3

public double getElementTextAsDouble( String namespaceURI, String localName )
            throws XMLParsingException, XMLStreamException {
  require( START_ELEMENT, namespaceURI, localName );
  return getElementTextAsDouble();
}

代码示例来源:origin: deegree/deegree3

/**
 * Creates printable (debug) information about the event that the cursor of the given <code>XMLStreamReader</code>
 * currently points at.
 * 
 * @return printable information
 */
public final String getCurrentEventInfo() {
  String s = getEventTypeString( getEventType() );
  if ( getEventType() == START_ELEMENT || getEventType() == END_ELEMENT ) {
    s += ": " + getName();
  }
  Location location = getLocation();
  s += " at line " + location.getLineNumber() + ", column " + location.getColumnNumber() + " (character offset "
     + getLocation().getCharacterOffset() + ")";
  return s;
}

代码示例来源:origin: deegree/deegree3

String gid = parseGeometryId( xmlStream );
ICRS crs = determineActiveCRS( xmlStream, defaultCRS );
xmlStream.nextTag();
if ( xmlStream.getEventType() == START_ELEMENT ) {
  if ( xmlStream.getLocalName().equals( "outerBoundaryIs" ) ) {
    if ( xmlStream.nextTag() != START_ELEMENT ) {
      String msg = "Error in 'gml:Polygon' element. Expected a 'gml:LinearRing' element.";
      throw new XMLParsingException( xmlStream, msg );
    xmlStream.nextTag();
    xmlStream.require( END_ELEMENT, GML21NS, "outerBoundaryIs" );
    xmlStream.nextTag();
while ( xmlStream.getEventType() == START_ELEMENT ) {
  if ( xmlStream.getLocalName().equals( "innerBoundaryIs" ) ) {
    if ( xmlStream.nextTag() != START_ELEMENT ) {
      String msg = "Error in 'gml:Polygon' element. Expected a 'gml:LinearRing' element.";
      throw new XMLParsingException( xmlStream, msg );
    xmlStream.nextTag();
    xmlStream.require( END_ELEMENT, GML21NS, "innerBoundaryIs" );
  } else {
    String msg = "Error in 'gml:Polygon' element. Expected a 'gml:innerBoundaryIs' element, but found: '"
           + xmlStream.getName() + "'.";
    throw new XMLParsingException( xmlStream, msg );
  xmlStream.nextTag();

代码示例来源:origin: deegree/deegree3

xmlStream.nextTag();
Points points = parseControlPoints( xmlStream, defaultCRS );
int degree = xmlStream.getElementTextAsPositiveInteger( gmlNs, "degree" );
while ( xmlStream.nextTag() == XMLStreamConstants.START_ELEMENT ) {
  if ( !"knot".equals( xmlStream.getLocalName() ) ) {
    break;
  xmlStream.nextTag();
  xmlStream.require( XMLStreamConstants.START_ELEMENT, gmlNs, "Knot" );
  xmlStream.nextTag();
  double value = xmlStream.getElementTextAsDouble( gmlNs, "value" );
  xmlStream.nextTag();
  int multiplicity = xmlStream.getElementTextAsPositiveInteger( gmlNs, "multiplicity" );
  xmlStream.nextTag();
  double weight = xmlStream.getElementTextAsDouble( gmlNs, "weight" );
  xmlStream.nextTag();
  xmlStream.require( XMLStreamConstants.END_ELEMENT, gmlNs, "Knot" );
  xmlStream.nextTag();
  xmlStream.require( XMLStreamConstants.END_ELEMENT, gmlNs, "knot" );
  knots.add( new Knot( value, multiplicity, weight ) );
  throw new XMLParsingException( xmlStream, msg );
xmlStream.require( XMLStreamConstants.END_ELEMENT, gmlNs, "Bezier" );
return geomFac.createBezier( points, degree, knots.get( 0 ), knots.get( 1 ) );

代码示例来源:origin: deegree/deegree3

StringReader sr = new StringReader( filters[i] );
XMLAdapter adapter = new XMLAdapter( sr );
XMLStreamReaderWrapper streamWrapper = new XMLStreamReaderWrapper(
                                  adapter.getRootElement().getXMLStreamReaderWithoutCaching(),
                                  adapter.getSystemId() );
try {
  streamWrapper.nextTag();
  filter = Filter110XMLDecoder.parse( streamWrapper );
} catch ( XMLParsingException e ) {

代码示例来源:origin: deegree/deegree3

protected Length parseLengthType( XMLStreamReaderWrapper xmlStream )
            throws XMLStreamException {
  String uom = xmlStream.getAttributeValue( null, "uom" );
  if ( uom == null ) {
    String msg = "Required attribute 'uom' missing in element '" + xmlStream.getName() + "'.";
    throw new XMLParsingException( xmlStream, msg );
  }
  String s = xmlStream.getElementText();
  BigDecimal value = new BigDecimal( 0.0 );
  try {
    value = new BigDecimal( s );
  } catch ( NumberFormatException e ) {
    String msg = "Error in element '" + xmlStream.getName() + "': expected a double value, but found '" + s
           + "'.";
    throw new XMLParsingException( xmlStream, msg );
  }
  return new Length( value, uom );
}

代码示例来源:origin: deegree/deegree3

String interpolationAttrValue = xmlStream.getAttributeValueWDefault( "interpolation", "polynomialSpline" );
if ( "rationalSpline".equals( interpolationAttrValue ) ) {
  isPolynomial = true;
} else {
  String msg = "Invalid value ('" + interpolationAttrValue + "') for interpolation attribute in element '"
         + xmlStream.getName() + "'. Must be 'rationalSpline' or 'polynomialSpline'.";
  throw new XMLParsingException( xmlStream, msg );
xmlStream.nextTag();
Points points = parseControlPoints( xmlStream, defaultCRS );
int degree = xmlStream.getElementTextAsPositiveInteger( gmlNs, "degree" );
while ( xmlStream.nextTag() == XMLStreamConstants.START_ELEMENT ) {
  if ( !"knot".equals( xmlStream.getLocalName() ) ) {
    break;
  xmlStream.nextTag();
  xmlStream.require( XMLStreamConstants.START_ELEMENT, gmlNs, "Knot" );
  xmlStream.nextTag();
  double value = xmlStream.getElementTextAsDouble( gmlNs, "value" );
  xmlStream.nextTag();
  int multiplicity = xmlStream.getElementTextAsPositiveInteger( gmlNs, "multiplicity" );
  xmlStream.nextTag();
  double weight = xmlStream.getElementTextAsDouble( gmlNs, "weight" );
  xmlStream.nextTag();
  xmlStream.require( XMLStreamConstants.END_ELEMENT, gmlNs, "Knot" );
  xmlStream.nextTag();

代码示例来源:origin: deegree/deegree3

throws XMLParsingException, XMLStreamException, UnknownCRSException {
xmlStream.nextTag();
xmlStream.require( START_ELEMENT, gmlNs, "refLocation" );
xmlStream.nextTag();
xmlStream.require( START_ELEMENT, gmlNs, "AffinePlacement" );
AffinePlacement referenceLocation = parseAffinePlacement( xmlStream, defaultCRS );
xmlStream.nextTag();
xmlStream.require( END_ELEMENT, gmlNs, "refLocation" );
xmlStream.nextTag();
double scaleFactor = xmlStream.getElementTextAsDouble( gmlNs, "scaleFactor" );
xmlStream.nextTag();
double startParameter = xmlStream.getElementTextAsDouble( gmlNs, "startParameter" );
xmlStream.nextTag();
double endParameter = xmlStream.getElementTextAsDouble( gmlNs, "endParameter" );
xmlStream.nextTag();
xmlStream.require( END_ELEMENT, gmlNs, "Clothoid" );
return geomFac.createClothoid( referenceLocation, scaleFactor, startParameter, endParameter );

代码示例来源:origin: deegree/deegree3

private Points parseControlPoints( XMLStreamReaderWrapper xmlStream, ICRS crs )
            throws XMLStreamException {
  List<Point> controlPoints = null;
  if ( xmlStream.getEventType() == XMLStreamConstants.START_ELEMENT ) {
    String name = xmlStream.getLocalName();
    if ( "coordinates".equals( name ) ) {
      controlPoints = parseCoordinates( xmlStream, crs );
      xmlStream.nextTag();
    } else {
      controlPoints = new LinkedList<Point>();
      do {
        name = xmlStream.getLocalName();
        if ( "coord".equals( name ) ) {
          double[] coords = parseCoordType( xmlStream );
          // anonymous point (no registering necessary)
          controlPoints.add( geomFac.createPoint( null, coords, crs ) );
        } else {
          break;
        }
      } while ( xmlStream.nextTag() == XMLStreamConstants.START_ELEMENT );
    }
  }
  return geomFac.createPoints( controlPoints );
}

代码示例来源:origin: deegree/deegree3

int event = xmlStream.nextTag();
if ( event != XMLStreamConstants.START_ELEMENT || !GML_X.equals( xmlStream.getName() ) ) {
  String msg = "Invalid 'gml:coords' element. Must contain an 'gml:X' element.";
  throw new XMLParsingException( xmlStream, msg );
double x = xmlStream.getElementTextAsDouble();
event = xmlStream.nextTag();
if ( event == XMLStreamConstants.END_ELEMENT ) {
  return new double[] { x };
if ( event != XMLStreamConstants.START_ELEMENT || !GML_Y.equals( xmlStream.getName() ) ) {
  String msg = "Invalid 'gml:coords' element. Second child element must be a 'gml:Y' element.";
  throw new XMLParsingException( xmlStream, msg );
double y = xmlStream.getElementTextAsDouble();
event = xmlStream.nextTag();
if ( event == XMLStreamConstants.END_ELEMENT ) {
  return new double[] { x, y };
if ( event != XMLStreamConstants.START_ELEMENT || !GML_Z.equals( xmlStream.getName() ) ) {
  String msg = "Invalid 'gml:coords' element. Third child element must be a 'gml:Z' element.";
  throw new XMLParsingException( xmlStream, msg );
double z = xmlStream.getElementTextAsDouble();
event = xmlStream.nextTag();
if ( event != XMLStreamConstants.END_ELEMENT ) {
  xmlStream.skipElement();

代码示例来源:origin: deegree/deegree3

/**
 * Not piped to wrapped reader, because AXIOM provided reader (withoutCaching) behaves strange here.
 */
@Override
public String getElementText()
            throws XMLStreamException {
  if ( getEventType() != XMLStreamConstants.START_ELEMENT ) {
    throw new XMLStreamException( "parser must be on START_ELEMENT to read next text", getLocation() );
  }
  int eventType = next();
  StringBuilder content = new StringBuilder();
  while ( eventType != XMLStreamConstants.END_ELEMENT ) {
    if ( eventType == XMLStreamConstants.CHARACTERS || eventType == XMLStreamConstants.CDATA
       || eventType == XMLStreamConstants.SPACE || eventType == XMLStreamConstants.ENTITY_REFERENCE ) {
      content.append( getText() );
    } else if ( eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
          || eventType == XMLStreamConstants.COMMENT ) {
      // skipping
    } else if ( eventType == XMLStreamConstants.END_DOCUMENT ) {
      throw new XMLStreamException( "unexpected end of document when reading element text content",
                     getLocation() );
    } else if ( eventType == XMLStreamConstants.START_ELEMENT ) {
      throw new XMLStreamException( "element text content may not contain START_ELEMENT", getLocation() );
    } else {
      throw new XMLStreamException( "Unexpected event type " + eventType, getLocation() );
    }
    eventType = next();
  }
  return content.toString();
}

代码示例来源:origin: deegree/deegree3

LOG.debug( "- parsing feature, gml:id=" + fid + " (begin): " + xmlStream.getCurrentEventInfo() );
QName featureName = xmlStream.getName();
FeatureType ft = lookupFeatureType( xmlStream, featureName, false );
if ( ft == null ) {
while ( xmlStream.getEventType() == START_ELEMENT ) {
  QName propName = xmlStream.getName();
  LOG.debug( "- property '" + propName + "'" );
  xmlStream.nextTag();
  if ( lastPropDecl != propDecl ) {
    lastPropDecl = propDecl;

代码示例来源:origin: deegree/deegree3

List<Property> propertyList = new ArrayList<Property>();
xmlStream.nextTag();
while ( xmlStream.getEventType() == START_ELEMENT ) {
  QName propName = xmlStream.getName();
  if ( LOG.isDebugEnabled() ) {
    LOG.debug( "- property '" + propName + "'" );
    xmlStream.nextTag();
    continue;
  xmlStream.nextTag();

代码示例来源:origin: deegree/deegree3

private Feature readProperty()
            throws XMLParsingException, XMLStreamException, UnknownCRSException {
  Feature feature = null;
  int event = xmlStream.getEventType();
  if ( event == START_ELEMENT ) {
    QName propName = xmlStream.getName();
    if ( LOG.isDebugEnabled() ) {
      LOG.debug( "- property '" + propName + "'" );
  xmlStream.next();
  return feature;

代码示例来源:origin: deegree/deegree3

/**
 * Starts the validation.
 * 
 * @throws XMLStreamException
 * @throws UnknownCRSException
 */
public void validateGeometries()
            throws XMLStreamException, UnknownCRSException {
  while ( xmlStream.getEventType() != END_DOCUMENT ) {
    if ( xmlStream.isStartElement() ) {
      if ( gmlStream.isGeometryElement() ) {
        validateGeometryElement();
      }
    }
    xmlStream.next();
  }
}

代码示例来源:origin: deegree/deegree3

private void validateInterpolationAttribute( XMLStreamReaderWrapper xmlStream, String expected )
              throws XMLParsingException {
    String actual = xmlStream.getAttributeValue( null, "interpolation" );
    if ( actual != null && !expected.equals( actual ) ) {
      String msg = "Invalid value (='" + actual + "') for interpolation attribute in element '"
             + xmlStream.getName() + "'. Must be '" + expected + "'.";
      throw new XMLParsingException( xmlStream, msg );
    }
  }
}

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