当前位置: 首页>>代码示例>>Java>>正文


Java ValidationEventLocator类代码示例

本文整理汇总了Java中javax.xml.bind.ValidationEventLocator的典型用法代码示例。如果您正苦于以下问题:Java ValidationEventLocator类的具体用法?Java ValidationEventLocator怎么用?Java ValidationEventLocator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ValidationEventLocator类属于javax.xml.bind包,在下文中一共展示了ValidationEventLocator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleStartDocument

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
protected final void handleStartDocument(NamespaceContext nsc) throws SAXException {
    visitor.startDocument(new LocatorEx() {
        public ValidationEventLocator getLocation() {
            return new ValidationEventLocatorImpl(this);
        }
        public int getColumnNumber() {
            return getCurrentLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return getCurrentLocation().getLineNumber();
        }
        public String getPublicId() {
            return getCurrentLocation().getPublicId();
        }
        public String getSystemId() {
            return getCurrentLocation().getSystemId();
        }
    },nsc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:StAXConnector.java

示例2: getErrorFieldName

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
@Nullable
@OverrideOnDemand
protected String getErrorFieldName (@Nullable final ValidationEventLocator aLocator)
{
  if (aLocator != null)
  {
    // Source object found?
    final Object aObj = aLocator.getObject ();
    if (aObj != null)
      return "obj: " + aObj.toString ();

    // Source node found?
    final Node aNode = aLocator.getNode ();
    if (aNode != null)
      return XMLWriter.getNodeAsString (aNode);
  }
  return null;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:19,代码来源:AbstractValidationEventHandler.java

示例3: createValidationEvent

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
private ValidationEvent createValidationEvent(final boolean isUnexpectedElementsMessage) {
    return new ValidationEvent() {
        @Override
        public int getSeverity() {
            throw new UnsupportedOperationException("getSeverity is not supported by ");
        }

        @Override
        public String getMessage() {
            return isUnexpectedElementsMessage ? "unexpected element ( tralala" : "other exception";
        }

        @Override
        public Throwable getLinkedException() {
            throw new UnsupportedOperationException("getLinkedException is not supported by ");
        }

        @Override
        public ValidationEventLocator getLocator() {
            throw new UnsupportedOperationException("getLocator is not supported by ");
        }
    };
}
 
开发者ID:killbill,项目名称:killbill-adyen-plugin,代码行数:24,代码来源:TestIgnoreUnexpectedElementsEventHandler.java

示例4: propagateEvent

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
private void propagateEvent( int severity, SAXParseException saxException ) 
    throws SAXException {
        
    // get location info:
    //     sax locators simply use the location info embedded in the 
    //     sax exception, dom locators keep a reference to their DOMScanner
    //     and call back to figure out where the error occurred.
    ValidationEventLocator vel = 
        locator.getLocation( saxException );

    ValidationEventImpl ve = 
        new ValidationEventImpl( severity, saxException.getMessage(), vel  );

    Exception e = saxException.getException();
    if( e != null ) {
        ve.setLinkedException( e );
    } else {
        ve.setLinkedException( saxException );
    }
    
    // call the client's event handler.
    host.handleEvent( ve, severity!=ValidationEvent.FATAL_ERROR );
}
 
开发者ID:nhrdl,项目名称:javacash,代码行数:24,代码来源:ErrorHandlerAdaptor.java

示例5: handleEvent

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
/**
 * Validates and event.
 *
 * <p>The validation only continues if the there are a warning, otherwise it is stopped.
 *
 * @param   event  the encapsulated validation event information. It is a provider error if this parameter is null.
 *
 * @return  true if the JAXB Provider should attempt to continue the current unmarshal, validate, or marshal
 *          operation after handling this warning/error, false if the provider should terminate the current
 *          operation with the appropriate <tt>UnmarshalException</tt>, <tt>ValidationException</tt>, or <tt>
 *          MarshalException</tt>.
 */
@Override
public boolean handleEvent(final ValidationEvent event) {

    final ValidationEventLocator eventLocation = event.getLocator();

    final String details = MessageFormat.format("Line: [{0}:{1}] Message: {2}", eventLocation.getLineNumber(),
            eventLocation.getColumnNumber(), event.getMessage());

    boolean result = true;
    if (event.getSeverity() == ValidationEvent.WARNING) {
        LOG.warn(details);
    } else {
        LOG.error(details);
        result = false;
    }

    return result;
}
 
开发者ID:ribeirux,项目名称:jalphanode,代码行数:31,代码来源:XMLEventHandler.java

示例6: throwsExceptionOnEveryEvent

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
/**
 * XsdEventHandler throws exception on every event.
 * @throws Exception If something goes wrong
 */
@Test
public void throwsExceptionOnEveryEvent() throws Exception {
    final ValidationEventLocator locator =
        Mockito.mock(ValidationEventLocator.class);
    Mockito.doReturn(1).when(locator).getLineNumber();
    Mockito.doReturn(1).when(locator).getColumnNumber();
    Mockito.doReturn(new URL("http://localhost")).when(locator).getURL();
    final ValidationEvent event = Mockito.mock(ValidationEvent.class);
    Mockito.doReturn("msg").when(event).getMessage();
    Mockito.doReturn(locator).when(event).getLocator();
    final ValidationEventHandler handler = new XsdEventHandler();
    MatcherAssert.assertThat(
        handler.handleEvent(event),
        Matchers.is(false)
    );
}
 
开发者ID:yegor256,项目名称:rexsl,代码行数:21,代码来源:XsdEventHandlerTest.java

示例7: FFprobeJAXB

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
public FFprobeJAXB() throws JAXBException, ParserConfigurationException {
	/**
	 * Load JAXB classes
	 */
	JAXBContext jc = JAXBContext.newInstance("org.ffmpeg.ffprobe");
	unmarshaller = jc.createUnmarshaller();
	
	/**
	 * Prepare an error catcher if trouble are catched during import.
	 */
	unmarshaller.setEventHandler((ValidationEventHandler) e -> {
		ValidationEventLocator localtor = e.getLocator();
		Loggers.Transcode.warn("FFprobe XML validation: " + e.getMessage() + " [s" + e.getSeverity() + "] at line " + localtor.getLineNumber() + ", column " + localtor.getColumnNumber() + " offset " + localtor.getOffset() + " node: " + localtor.getNode() + ", object " + localtor.getObject());
		return true;
	});
	
	/**
	 * Load XML engine
	 */
	DocumentBuilderFactory xmlDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
	xml_document_builder = xmlDocumentBuilderFactory.newDocumentBuilder();
	xml_document_builder.setErrorHandler(null);
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:24,代码来源:FFprobeJAXB.java

示例8: handleEvent

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent validationEvent) {
	ValidationEventLocator locator = validationEvent.getLocator();
	lineNumber = locator.getLineNumber();
	columnNumber = locator.getColumnNumber();
	message = validationEvent.getMessage();
	return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:JaxbHelper.java

示例9: Snapshot

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
public Snapshot(LocatorEx loc) {
    columnNumber = loc.getColumnNumber();
    lineNumber = loc.getLineNumber();
    systemId = loc.getSystemId();
    publicId = loc.getPublicId();

    ValidationEventLocator vel = loc.getLocation();
    offset = vel.getOffset();
    url = vel.getURL();
    object = vel.getObject();
    node = vel.getNode();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:LocatorEx.java

示例10: getLocation

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
/**
 * Calculate a location message for the event
 *
 */
private String getLocation(ValidationEvent event) {
    StringBuffer msg = new StringBuffer();

    ValidationEventLocator locator = event.getLocator();

    if( locator != null ) {

        URL url = locator.getURL();
        Object obj = locator.getObject();
        Node node = locator.getNode();
        int line = locator.getLineNumber();

        if( url!=null || line!=-1 ) {
            msg.append( "line " + line );
            if( url!=null )
                msg.append( " of " + url );
        } else if( obj != null ) {
            msg.append( " obj: " + obj.toString() );
        } else if( node != null ) {
            msg.append( " node: " + node.toString() );
        }
    } else {
        msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) );
    }

    return msg.toString();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:DefaultValidationEventHandler.java

示例11: handleValidationEvent

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
private static boolean handleValidationEvent(ImmutableList.Builder<String> errorList, ValidationEvent validationEvent) {
    if (validationEvent.getSeverity() != ValidationEvent.WARNING) {
        ValidationEventLocator locator = validationEvent.getLocator();
        errorList.add("Line:Col[" + locator.getLineNumber() +
                              ":" + locator.getColumnNumber() +
                              "]:" + validationEvent.getMessage());
    }
    return true;
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:10,代码来源:DashManifestParser.java

示例12: handleEvent

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
public boolean handleEvent(ValidationEvent event) {
	ValidationEventLocator loc = event.getLocator();
	String file = loc.getURL().getFile();
	try {
		file = URLDecoder.decode(file, "UTF-8");
	} catch (UnsupportedEncodingException e) {
		throw new RuntimeException(e);
	}
	int lastSlash = file.lastIndexOf('/');
	if (lastSlash > 0)
		file = file.substring(lastSlash + 1);

	String errorMsg = event.getMessage();
	if (errorMsg == null) {
		Throwable t = event.getLinkedException();
		while (t != null && errorMsg == null) {
			errorMsg = t.getMessage();
			t = t.getCause();
		}
	}

	JOptionPane
			.showMessageDialog(null, "<html><h3>Failed to load a custom map</h3><p><i>" + errorMsg
					+ "</i></p><br><p>file: \"<b>" + file + "</b>\"<br>line/column: <i>" + loc.getLineNumber()
					+ "/" + loc.getColumnNumber() + "</i></p>", "Error: custom map loading failed",
					JOptionPane.ERROR_MESSAGE);
	log.error(event.toString());
	return false;
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:30,代码来源:CustomMapSourceLoader.java

示例13: load

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
public AtlasInterface load() throws JAXBException {
	JAXBContext context = JAXBContext.newInstance(Atlas.class);
	Unmarshaller um = context.createUnmarshaller();
	um.setEventHandler(new ValidationEventHandler() {

		public boolean handleEvent(ValidationEvent event) {
			ValidationEventLocator loc = event.getLocator();
			String file = loc.getURL().getFile();
			int lastSlash = file.lastIndexOf('/');
			if (lastSlash > 0)
				file = file.substring(lastSlash + 1);
			int ret = JOptionPane.showConfirmDialog(
					null,
					String.format(I18nUtils.localizedStringForKey("msg_error_load_atlas_profile"),
							event.getMessage(), file, loc.getLineNumber(), loc.getColumnNumber()),
					I18nUtils.localizedStringForKey("msg_error_load_atlas_profile_title"),
					JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);
			log.error(event.toString());
			return (ret == JOptionPane.YES_OPTION);
		}
	});
	try {
		AtlasInterface newAtlas = (AtlasInterface) um.unmarshal(file);
		return newAtlas;
	} catch (Exception e) {
		throw new JAXBException(e.getMessage(), e);
	}
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:29,代码来源:Profile.java

示例14: getErrorLocation

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
/**
 * Calculates a location message for the event.
 * 
 * {@link DefaultValidationEventHandler#getLocation(ValidationEvent)}
 */
public static String getErrorLocation(ValidationEvent event)
{
	StringBuilder msg = new StringBuilder();

	ValidationEventLocator locator = event.getLocator();

	if (locator != null)
	{

		URL url = locator.getURL();
		Object obj = locator.getObject();
		Node node = locator.getNode();
		int line = locator.getLineNumber();

		if (url != null || line != -1)
		{
			msg.append("line " + line);
			if (url != null)
				msg.append(" of " + url);
		}
		else if (obj != null)
		{
			msg.append(" obj: " + obj.toString());
		}
		else if (node != null)
		{
			msg.append(" node: " + node.toString());
		}
	}
	else
	{
		msg.append("Cannot determinate the location of the error/warning");
	}

	return msg.toString();
}
 
开发者ID:tinesoft,项目名称:droidlinguist,代码行数:42,代码来源:JaxbUtil.java

示例15: getLocationResourceID

import javax.xml.bind.ValidationEventLocator; //导入依赖的package包/类
@Nullable
@OverrideOnDemand
protected String getLocationResourceID (@Nullable final ValidationEventLocator aLocator)
{
  if (aLocator != null)
  {
    // Source file found?
    final URL aURL = aLocator.getURL ();
    if (aURL != null)
      return aURL.toString ();
  }
  return null;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:14,代码来源:AbstractValidationEventHandler.java


注:本文中的javax.xml.bind.ValidationEventLocator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。