gpt4 book ai didi

com.sun.xml.bind.v2.runtime.XMLSerializer.reportError()方法的使用及代码示例

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

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

XMLSerializer.reportError介绍

[英]Report an error found as an exception.
[中]将发现的错误报告为异常。

代码示例

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public String getId(BeanT bean, XMLSerializer target) throws SAXException {
  if(idProperty!=null) {
    try {
      return idProperty.getIdValue(bean);
    } catch (AccessorException e) {
      target.reportError(null,e);
    }
  }
  return null;
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public void serializeBody(Object array, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
  int len = Array.getLength(array);
  for( int i=0; i<len; i++ )  {
    Object item = Array.get(array,i);
    try {
      xducer.writeText(target,item,"arrayItem");
    } catch (AccessorException e) {
      target.reportError("arrayItem",e);
    }
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public final void serializeBody(BeanT bean, XMLSerializer w) throws SAXException, IOException, XMLStreamException {
  // most of the times leaves are printed as leaf element/attribute property,
  // so this code is only used for example when you have multiple XmlElement on a property
  // and some of them are leaves. Hence this doesn't need to be super-fast.
  try {
    xducer.writeText(w,bean,null);
  } catch (AccessorException e) {
    w.reportError(null,e);
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public void serializeBody(JAXBElement element, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
  try {
    property.serializeBody(element,target,null);
  } catch (AccessorException x) {
    target.reportError(null,x);
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public final void serializeRoot(Object array, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
  target.reportError(
      new ValidationEventImpl(
          ValidationEvent.ERROR,
          Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(array.getClass().getName()),
          null,
          null));
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public void serializeRoot(CompositeStructure o, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
  target.reportError(
      new ValidationEventImpl(
          ValidationEvent.ERROR,
          Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(o.getClass().getName()),
          null,
          null));
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public final void serializeRoot(Object array, XMLSerializer target) throws SAXException {
  target.reportError(
      new ValidationEventImpl(
          ValidationEvent.ERROR,
          Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(array.getClass().getName()),
          null,
          null));
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public void serializeRoot(Object element, XMLSerializer target) throws SAXException {
  target.reportError(
      new ValidationEventImpl(
          ValidationEvent.ERROR,
          Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(element.getClass().getName()),
          null,
          null));
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public final void serializeURIs(Object array, XMLSerializer target) throws SAXException {
  if(xducer.useNamespace()) {
    int len = Array.getLength(array);
    for( int i=0; i<len; i++ )  {
      Object item = Array.get(array,i);
      try {
        xducer.declareNamespace(item,target);
      } catch (AccessorException e) {
        target.reportError("arrayItem",e);
      }
    }
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

/**
 * Report an error found as an exception.
 *
 * @param fieldName
 *      the name of the property being processed when an error is found.
 */
public final void reportError(String fieldName, Throwable t) throws SAXException {
  ValidationEvent ve = new ValidationEventImpl(ValidationEvent.ERROR,
    t.getMessage(), getCurrentLocation(fieldName), t);
  reportError(ve);
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public final void serializeURIs(BeanT bean, XMLSerializer target) throws SAXException {
  // TODO: maybe we should create another LeafBeanInfoImpl class for
  // context-dependent xducers?
  if(xducer.useNamespace()) {
    try {
      xducer.declareNamespace(bean,target);
    } catch (AccessorException e) {
      target.reportError(null,e);
    }
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public <E> void writeDom(E element, DomHandler<E, ?> domHandler, Object parentBean, String fieldName) throws SAXException {
  Source source = domHandler.marshal(element,this);
  if(contentHandlerAdapter==null)
    contentHandlerAdapter = new ContentHandlerAdaptor(this);
  try {
    getIdentityTransformer().transform(source,new SAXResult(contentHandlerAdapter));
  } catch (TransformerException e) {
    reportError(fieldName,e);
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

private void reportMissingObjectError(String fieldName) throws SAXException {
  reportError(new ValidationEventImpl(
    ValidationEvent.ERROR,
    Messages.MISSING_OBJECT.format(fieldName),
      getCurrentLocation(fieldName),
    new NullPointerException() ));
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public String onIDREF( Object obj ) throws SAXException {
  String id;
  try {
    id = getIdFromObject(obj);
  } catch (JAXBException e) {
    reportError(null,e);
    return null; // recover by returning null
  }
  idReferencedObjects.add(obj);
  if(id==null) {
    reportError( new NotIdentifiableEventImpl(
      ValidationEvent.ERROR,
      Messages.NOT_IDENTIFIABLE.format(),
      new ValidationEventLocatorImpl(obj) ) );
  }
  return id;
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

void reconcileID() throws SAXException {
  // find objects that were not a part of the object graph
  idReferencedObjects.removeAll(objectsWithId);
  for( Object idObj : idReferencedObjects ) {
    try {
      String id = getIdFromObject(idObj);
      reportError( new NotIdentifiableEventImpl(
        ValidationEvent.ERROR,
        Messages.DANGLING_IDREF.format(id),
        new ValidationEventLocatorImpl(idObj) ) );
    } catch (JAXBException e) {
      // this error should have been reported already. just ignore here.
    }
  }
  // clear the garbage
  idReferencedObjects.clear();
  objectsWithId.clear();
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public final void serializeRoot(BeanT bean, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
  if(tagName==null) {
    target.reportError(
      new ValidationEventImpl(
        ValidationEvent.ERROR,
        Messages.UNABLE_TO_MARSHAL_NON_ELEMENT.format(bean.getClass().getName()),
        null,
        null));
  }
  else {
    target.startElement(tagName,bean);
    target.childAsSoleContent(bean,null);
    target.endElement();
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

/**
 * Called when a referenced object doesn't have an ID.
 */
public void errorMissingId(Object obj) throws SAXException {
  reportError( new ValidationEventImpl(
    ValidationEvent.ERROR,
    Messages.MISSING_ID.format(obj),
    new ValidationEventLocatorImpl(obj)) );
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
  ValueT v = acc.get(o);
  if(v!=null) {
    try {
      JaxBeanInfo bi = w.grammar.getBeanInfo(v,true);
      if(bi.jaxbType==Object.class && domHandler!=null)
        // even if 'v' is a DOM node, it always derive from Object,
        // so the getBeanInfo returns BeanInfo for Object
        w.writeDom(v,domHandler,o,fieldName);
      else
        bi.serializeRoot(v,w);
    } catch (JAXBException e) {
      w.reportError(fieldName,e);
      // recover by ignoring this property
    }
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public String print(BeanT bean) throws AccessorException, SAXException {
  TargetT target = acc.get(bean);
  if(target==null)    return null;
  
  XMLSerializer w = XMLSerializer.getInstance();
  try {
    String id = w.grammar.getBeanInfo(target,true).getId(target,w);
    if(id==null)
      w.errorMissingId(target);
    return id;
  } catch (JAXBException e) {
    w.reportError(null,e);
    return null;
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public void declareNamespace(BeanT bean, XMLSerializer w) throws AccessorException, SAXException {
  ListT list = acc.get(bean);
  if(list!=null) {
    ListIterator<ItemT> itr = lister.iterator(list, w);
    while(itr.hasNext()) {
      try {
        ItemT item = itr.next();
        if (item != null) {
          xducer.declareNamespace(item,w);
        }
      } catch (JAXBException e) {
        w.reportError(null,e);
      }
    }
  }
}

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