Java 8 Location - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Location class.

This code example shows how to use the following methods:getColumnNumber, getLineNumber, getSystemId
 
  @Override 
  public void report(String message, String errorType, Object relatedInformation, Location loc) {
    final StringBuilder sb = new StringBuilder("XML parser reported ").append(errorType);
    if (loc !=  null) {
      sb.append(" in \"").append(loc.getSystemId()).append("\", line ")
        .append(loc.getLineNumber()).append(", column ").append(loc.getColumnNumber());
    } 
    log.warn(sb.append(": ").append(message).toString());
  } 
 
} 
7
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber, getSystemId
  // XMLReporter 
 
  public void report(String message, String errorType, Object relatedInformation, Location loc) {
    final StringBuilder sb = new StringBuilder("XML parser reported ").append(errorType);
    if (loc !=  null) {
      sb.append(" in \"").append(loc.getSystemId()).append("\", line ")
        .append(loc.getLineNumber()).append(", column ").append(loc.getColumnNumber());
    } 
    log.warn(sb.append(": ").append(message).toString());
  } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber
            throw unexpectedAttribute(reader, index);
        } 
    } 
 
    public static String getWarningMessage(final String msg, final Location location) {
        return String.format("Parsing problem at [row,col]:[%d ,%d]%nMessage: %s%n", location.getLineNumber(), location.getColumnNumber(), msg);
    } 
 
    public static Namespace[] getNamespaceAnnotations(Class<? extends ConfigurationParser> cls) {
       Namespaces namespacesAnnotation = cls.getAnnotation(Namespaces.class);
 
       if (namespacesAnnotation != null) {
          return namespacesAnnotation.value();
       } 
 
       Namespace namespaceAnnotation = cls.getAnnotation(Namespace.class);
       if (namespaceAnnotation != null) {
          return new Namespace[] { namespaceAnnotation };
       } 
 
6
CodeRank
This code example shows how to use the following methods:getCharacterOffset, getColumnNumber, getLineNumber, getSystemId
    private List<Object> sources;
 
    protected XmlValidationFailure(String message, Location location, ModelObject... sources) {
        this.message = message;
        if (location != null) {
            line = location.getLineNumber();
            column = location.getColumnNumber();
            offset = location.getCharacterOffset();
            resourceURI = location.getSystemId();
        } 
        this.sources = new ArrayList<>();
        if (sources != null) {
            this.sources.addAll(Arrays.asList(sources));
        } 
    } 
 
    protected XmlValidationFailure(String message) {
        this(message, null);
    } 
 
6
CodeRank
This code example shows how to use the following methods:getPublicId, getSystemId
	} 
 
	private void handleDtd() throws SAXException {
		if (getLexicalHandler() != null) { 
			javax.xml.stream.Location location = reader.getLocation();
			getLexicalHandler().startDTD(null, location.getPublicId(), location.getSystemId());
		} 
		if (getLexicalHandler() != null) { 
			getLexicalHandler().endDTD();
		} 
	} 
 
	private void handleEntityReference() throws SAXException {
		if (getLexicalHandler() != null) { 
			getLexicalHandler().startEntity(reader.getLocalName());
		} 
		if (getLexicalHandler() != null) { 
			getLexicalHandler().endEntity(reader.getLocalName());
		} 
	} 
5
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber
	 * @param location The location. 
	 */ 
	public XMLParserException(String message, Location location){
		super( 
			message +
			" @ line: " + location.getLineNumber() +
			" column: " + location.getColumnNumber()
		); 
	} 
	 
	/** 
	 * Construct a new {@link XMLParserException} using a cause. 
	 *  
	 * @param cause The cause. 
	 */ 
	public XMLParserException(Throwable cause){
		super(cause);
	} 
	 
	/** 
5
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber
 
	@Override 
	public String unsupportedNamespace(XMLStreamReader reader)
	{ 
		Location location = reader.getLocation();
		return this.tr("Unsupported namespace <{2} xmlns=\"{3}\"/> found at [{0}:{1}]", location.getLineNumber(), location.getColumnNumber(), reader.getLocalName(), reader.getNamespaceURI());
	} 
 
	@Override 
	public String unexpectedElement(XMLStreamReader reader)
	{ 
		Location location = reader.getLocation();
		return this.tr("Unexpected <{2}/> element found at [{0}:{1}]", location.getLineNumber(), location.getColumnNumber(), reader.getLocalName());
	} 
	 
	@Override 
	public String unexpectedAttribute(XMLStreamReader reader, int index)
	{ 
		Location location = reader.getLocation();
		return this.tr("Unexpected <{2} {3}=\"...\"/> attribute found at [{0}:{1}]", location.getLineNumber(), location.getColumnNumber(), reader.getLocalName(), reader.getAttributeLocalName(index));
5
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber, getSystemId
 
    public LoaderException(String message, XMLStreamReader reader) {
        super(message);
        Location location = reader.getLocation();
        if (location != null) {
            line = location.getLineNumber();
            column = location.getColumnNumber();
            resourceURI = location.getSystemId();
        } else { 
            resourceURI = "system";
            line = -1;
            column = -1;
        } 
    } 
 
    public LoaderException(String message, Throwable cause) {
        super(message, cause);
        line = UNDEFINED;
        column = UNDEFINED;
        resourceURI = null;
5
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber
    private void raiseInvalidConfiguration(String message, Throwable e, XMLStreamReader reader) throws InvalidBrokerConfigurationException {
        Location location = reader.getLocation();
        if (location == null) {
            throw new InvalidBrokerConfigurationException(message, e);
        } 
        int line = location.getLineNumber();
        int col = location.getColumnNumber();
        throw new InvalidBrokerConfigurationException(message + " [" + line + "," + col + "]", e);
    } 
 
} 
 
 
4
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber
 
public class BpmnXMLUtil implements BpmnXMLConstants { 
 
  public static void addXMLLocation(BaseElement element, XMLStreamReader xtr) {
    Location location = xtr.getLocation();
    element.setXmlRowNumber(location.getLineNumber());
    element.setXmlColumnNumber(location.getColumnNumber());
  } 
   
  public static void addXMLLocation(GraphicInfo graphicInfo, XMLStreamReader xtr) {
    Location location = xtr.getLocation();
    graphicInfo.setXmlRowNumber(location.getLineNumber());
    graphicInfo.setXmlColumnNumber(location.getColumnNumber());
  } 
   
  public static void writeDefaultAttribute(String attributeName, String value, XMLStreamWriter xtw) throws Exception {
    if (StringUtils.isNotEmpty(value) && "null".equalsIgnoreCase(value) == false) {
      xtw.writeAttribute(attributeName, value);
    } 
  } 
4
CodeRank
See Code Examples for Java 8 Location Methods: