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


Java ValidationEventLocator.getLineNumber方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: toResponse

import javax.xml.bind.ValidationEventLocator; //导入方法依赖的package包/类
@Override
public Response toResponse(LensJAXBValidationException e) {
  ValidationEvent event = e.getEvent();
  ValidationEventLocator vel = event.getLocator();
  String msg = "XML Validation Exception:  " + event.getMessage() + " at row: " + vel.getLineNumber() + " column: "
    + vel.getColumnNumber();
  LensAPIResult lensAPIResult =
    LensAPIResult.composedOf(null, new MappedDiagnosticLogSegregationContext().getLogSegragationId(),
      LensErrorTO.composedOf(LensCommonErrorCode.INVALID_XML_ERROR.getValue(), msg,
        Arrays.toString(e.getStackTrace())), Response.Status.BAD_REQUEST);
  return Response.status(Response.Status.BAD_REQUEST).entity(lensAPIResult).build();
}
 
开发者ID:apache,项目名称:lens,代码行数:13,代码来源:LensJAXBValidationExceptionMapper.java

示例5: appendLocator

import javax.xml.bind.ValidationEventLocator; //导入方法依赖的package包/类
private static void appendLocator(StringBuilder sb, ValidationEventLocator loc) {
    if (loc.getURL() == null 
            && loc.getLineNumber() < 0 
            && loc.getColumnNumber() < 0
            && loc.getOffset() < 0
            && loc.getNode() == null
            && loc.getObject() == null) {
        return;
    }
    sb.append("(");
    boolean first = true;
    if (loc.getURL() != null) {
        sb.append(loc.getURL().toExternalForm());
        first = false;
    }
    if (loc.getLineNumber() >= 0) {
        if (!first) {
            sb.append(", ");
        }
        sb.append("line ").append(loc.getLineNumber());
        first = false;
    }
    if (loc.getColumnNumber() >= 0) {
        if (!first) {
            sb.append(", ");
        }
        sb.append("column ").append(loc.getColumnNumber());
        first = false;
    }
    if (loc.getOffset() >= 0) {
        if (!first) {
            sb.append(", ");
        }
        sb.append("byte ").append(loc.getOffset());
        first = false;
    }
    if (loc.getObject() != null) {
        if (!first) {
            sb.append(", ");
        }
        sb.append("object ").append(loc.getObject().getClass().getName());
        first = false;
    }
    if (loc.getNode() != null) {
        if (!first) {
            sb.append(", ");
        }
        sb.append("node ").append(loc.getNode().getLocalName());
        first = false;
    }
    sb.append(") ");
}
 
开发者ID:TAXIIProject,项目名称:java-taxii,代码行数:53,代码来源:ValidationErrorHandler.java


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