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


Java ValidationEvent.getSeverity方法代码示例

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


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

示例1: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public boolean handleEvent( ValidationEvent event ) {
    events.add(event);

    boolean retVal = true;
    switch( event.getSeverity() ) {
        case ValidationEvent.WARNING:
            retVal = true; // continue validation
            break;
        case ValidationEvent.ERROR:
            retVal = true; // continue validation
            break;
        case ValidationEvent.FATAL_ERROR:
            retVal = false; // halt validation
            break;
        default:
            _assert( false,
                     Messages.format( Messages.UNRECOGNIZED_SEVERITY,
                             event.getSeverity() ) );
            break;
    }

    return retVal;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:ValidationEventCollector.java

示例2: checkForValidationErrors

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
private List<String> checkForValidationErrors(ValidationEvent... events)
{

	List<String> errors = new ArrayList<>();

	for (ValidationEvent event : events)
	{
		if (event.getSeverity() != ValidationEvent.WARNING)
		{
			String severity = (event.getSeverity() == ValidationEvent.ERROR) ? "[ERROR]: " : "[FATAL_ERROR]: ";
			String location = JaxbUtil.getErrorLocation(event);
			String message = String.format("%s %s Location: %s", severity, event.getMessage(), location);
			errors.add(message);

		}
	}

	return errors;
}
 
开发者ID:tinesoft,项目名称:droidlinguist,代码行数:20,代码来源:SourceStringsParser.java

示例3: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent event) {
	events.add(event);

	boolean retVal = true;
	switch (event.getSeverity()) {
	case ValidationEvent.WARNING:
		retVal = true; // continue validation
		break;
	case ValidationEvent.ERROR:
		retVal = true; // continue validation
		break;
	case ValidationEvent.FATAL_ERROR:
		retVal = true; // continue validation
		break;

	}

	return retVal;
}
 
开发者ID:tinesoft,项目名称:droidlinguist,代码行数:21,代码来源:EagerValidationEventCollector.java

示例4: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent event) {
    if (event.getSeverity() > ValidationEvent.WARNING) {
        String message = event.getMessage().replace("\n", " ").trim();
        throw new JaxbException(message);
    }
    return true;
}
 
开发者ID:yahoo,项目名称:parsec-libraries,代码行数:9,代码来源:ParsecValidationEventHandler.java

示例5: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent event) {
  System.err.print(String.format("%s line %d col %d %s", severityToString(event.getSeverity()),
      event.getLocator().getLineNumber(), event.getLocator().getColumnNumber(),
      event.getMessage()));
  return event.getSeverity() == ValidationEvent.WARNING;
}
 
开发者ID:FIXTradingCommunity,项目名称:fix-orchestra,代码行数:8,代码来源:DocGenerator.java

示例6: handleValidationEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的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

示例7: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
/**
 * Receive notification of a validation warning or error.
 *
 * <p>
 *
 * The ValidationEvent will have a
 * {@link javax.xml.bind.ValidationEventLocator} embedded in it that
 * indicates where the error or warning occurred.
 *
 * <p>
 *
 * If an unchecked runtime exception is thrown from this method, the JAXB
 * provider will treat it as if the method returned false and interrupt
 * the current unmarshal, validate, or marshal operation.
 *
 * @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>.
 *
 * @throws IllegalArgumentException
 * if the event object is null.
 */
@Override
public boolean handleEvent( ValidationEvent event )
{
  if (event==null)
    throw new IllegalArgumentException( "No validation event was provided!" );

  int line = -1;
  int col = -1;
  if (event.getLocator()!=null)
  {
    line = event.getLocator().getLineNumber();
    col = event.getLocator().getColumnNumber();
  }

  if (ValidationEvent.FATAL_ERROR==event.getSeverity())
  {
    LOGGER.warn( "fatal validation error" );
    if (line>-1 && col>-1) LOGGER.warn( "> at line " + line + " / column " + col );
    LOGGER.warn( "> " + event.getMessage() );
    return false;
  }

  if (ValidationEvent.WARNING==event.getSeverity())
  {
    LOGGER.warn( "validation warning" );
    if (line>-1 && col>-1) LOGGER.warn( "> at line " + line + " / column " + col );
    LOGGER.warn( "> " + event.getMessage() );
  }
  else
  {
    LOGGER.warn( "validation error" );
    if (line>-1 && col>-1) LOGGER.warn( "> at line " + line + " / column " + col );
    LOGGER.warn( "> " + event.getMessage() );
  }

  return true;
}
 
开发者ID:OpenEstate,项目名称:OpenEstate-IO,代码行数:67,代码来源:XmlValidationHandler.java

示例8: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public boolean handleEvent(ValidationEvent event) {
	if ((event.getSeverity() == ValidationEvent.FATAL_ERROR)
			|| (event.getSeverity() == ValidationEvent.ERROR)) {
		return false;
	} else if (event.getSeverity() == ValidationEvent.WARNING) {
		log.debug("Validation warning: " + event.getMessage() + ".");
		return true;
	} else {
		log.warn("Unknown validation event type.");
		return false;
	}
}
 
开发者ID:loomchild,项目名称:segment,代码行数:13,代码来源:LoggingValidationEventHandler.java

示例9: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(final ValidationEvent event) {
    final int severity = event.getSeverity();
    if (severity == ValidationEvent.WARNING) {
        logger.warn("encountered JAXB parsing warning: " + event.getMessage());
        return true;
    }

    logger.warn("encountered JAXB parsing error: " + event.getMessage());
    return false;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:12,代码来源:JaxbValidationEventHandler.java

示例10: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent event) {
	StringBuilder msg = new StringBuilder();
	LogLevel type = LogLevel.ERROR;

	switch (event.getSeverity()) {
	case ValidationEvent.FATAL_ERROR:
	case ValidationEvent.ERROR:
		msg.append("Invalid XML content");
		type = LogLevel.ERROR;
		isValid = false;
		break;
	case ValidationEvent.WARNING:
		msg.append("Warning");
		type = LogLevel.WARN;
		break;
	}

	if (event.getLocator() != null) {
		msg.append(" at [").append(event.getLocator().getLineNumber())
		.append(", ").append(event.getLocator().getColumnNumber()).append("]");
	}

	msg.append(": ").append(event.getMessage());		
	log.log(type, msg.toString());
	
	if (!isValid)
		cause = msg.toString();
	
	return isValid;
}
 
开发者ID:3dcitydb,项目名称:web-feature-service,代码行数:32,代码来源:ValidationEventHandlerImpl.java

示例11: hasSeverity

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public boolean hasSeverity(int severity) {
    if (!hasEvents()) {
        return false;
    }

    for (ValidationEvent validationEvent : getEvents()) {
        if (validationEvent.getSeverity() == severity) {
            return true;
        }
    }

    return false;
}
 
开发者ID:forcedotcom,项目名称:idecore,代码行数:14,代码来源:MetadataValidationEventCollector.java

示例12: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent event) {
	int severity = event.getSeverity();
	if (severity == ValidationEvent.WARNING) {
		logger.warn("encountered JAXB parsing warning: " + event.getMessage());
		return true;
	}

	logger.warn("encountered JAXB parsing error: " + event.getMessage());
	return false;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:12,代码来源:JaxbValidationEventHandler.java

示例13: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent ve)
{
	if (ve.getSeverity() == ValidationEvent.FATAL_ERROR
		|| ve.getSeverity() == ValidationEvent.ERROR)
	{
		ValidationEventLocator locator = ve.getLocator();
		log.error("{}: {} at line={}, column={}", locator.getURL(),
			ve.getMessage(), locator.getLineNumber(),
			locator.getColumnNumber());
		foundErrors = true;
	}
	return true;
}
 
开发者ID:outermedia,项目名称:solr-fusion,代码行数:15,代码来源:XmlValidationHandler.java

示例14: getValidationEventHandler

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
private ValidationEventHandler getValidationEventHandler() {
    return new ValidationEventHandler() {
        public boolean handleEvent(ValidationEvent event) {
            if (event.getSeverity() == ValidationEvent.WARNING) {
                Log.warn("Ignored {}", event, event.getLinkedException());
                return true; // handled - ignore as WARNING does not prevent unmarshalling
            } else {
                return false; // not handled - ERROR and FATAL_ERROR prevent successful unmarshalling
            }
        }
    };
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:13,代码来源:TraceHeaderProcessor.java

示例15: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent event){
	Level level = (event.getSeverity() == ValidationEvent.WARNING ? Level.WARNING : Level.SEVERE);

	ValidationExample.logger.log(level, String.valueOf(event));

	return true;
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:9,代码来源:ValidationExample.java


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