本文整理汇总了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;
}
示例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();
}
示例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();
}
示例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();
}
示例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(") ");
}