Tabnine Logo
Token.getStartOffset
Code IndexAdd Tabnine to your IDE (free)

How to use
getStartOffset
method
in
de.pdark.decentxml.Token

Best Java code snippets using de.pdark.decentxml.Token.getStartOffset (Showing top 19 results out of 315)

origin: de.pdark/decentxml

/** The start offset of the node in the XML source or -1 */
public int getStartOffset ()
{
  return token == null ? -1 : token.getStartOffset ();
}

origin: de.pdark/decentxml

public int getStartOffset ()
{
  return startToken == null ? -1 : startToken.getStartOffset ();
}
origin: de.pdark/decentxml

public Location (Token token)
{
  this (token.getSource (), token.getStartOffset ());
}
origin: de.pdark/decentxml

  public String getPrefixWhiteSpace ()
  {
    int pos = getStartOffset ();
    int N = getEndOffset ();
    while (pos < N)
    {
      char c = source.charAt (pos);
      if (!Character.isWhitespace (c))
        break;
      pos ++;
    }
    return pos == 0 ? "" : source.substring (getStartOffset (), pos);
  }
}
origin: de.pdark/decentxml

public XMLParseException setToken (Token token)
{
  this.token = token;
  if (token != null)
  {
    setSource (token.getSource (), token.getStartOffset ());
  }
  return this;
}
origin: de.pdark/decentxml

@Override
public String toString ()
{
  return "Token (" + getType () + ", " + getStartOffset () + ":" + getEndOffset () + ", " + getEscapedText () + ")";
}
origin: de.pdark/decentxml

protected void parseDocTypeText (Token token)
{
  token.setType (Type.TEXT);
  pos --;
  while (pos < source.length () && getCharValidator ().isNameChar (source.charAt (pos)))
    pos ++;
  
  String s = source.substring (token.getStartOffset (), pos);
  if (s.length () == 0)
    throw new XMLParseException ("Expected some text"+lookAheadForErrorMessage ("but found", token.getStartOffset (), 20), token);
  
  // TODO How about "<!DOCTYPE SYSTEM ..."?
  if ("SYSTEM".equals (s))
    token.setType (Type.DOCTYPE_SYSTEM);
  else if ("PUBLIC".equals (s))
    token.setType (Type.DOCTYPE_PUBLIC);
  else if ("NDATA".equals (s))
    token.setType (Type.DOCTYPE_NDATA);
}
origin: de.pdark/decentxml

/** Return the string of text which this token represents in the XMLSource
 *
 * @return the text or <code>null</code> if there is no source
 */
public String getText ()
{
  return getSource() == null ? null : getSource().substring (getStartOffset(), getEndOffset());
}

origin: de.pdark/decentxml

/**
 * Fetch the next token and make sure it's {@code expected}. If not, create an
 * {@link XMLParseException} using the {@code errorMessage}
 */
protected Token expect (XMLTokenizer tokenizer, Token startToken, Type expected, String errorMessage)
{
  Token token = tokenizer.next ();
  //System.out.println (token);
  if (token == null || token.getType () != expected)
  {
    if (token == null)
      token = startToken;
    throw new XMLParseException (errorMessage + tokenizer.lookAheadForErrorMessage ("but found", token.getStartOffset (), 20) + " (" + token + ")", token);
  }
  return token;
}
origin: de.pdark/decentxml

protected void parseEntity (Token token)
{
  token.setType (Type.ENTITY);
  
  char c;
  if (pos < source.length ())
  {
    c = source.charAt (pos);
    if (c == '#')
      pos ++;
  }
  
  while (pos < source.length ())
  {
    c = source.charAt (pos);
    if (c == ';')
      break;
    
    if (!charValidator.isNameChar (c))
      throw new XMLParseException ("Illegal character in entity: ["+c+"] ("+Integer.toHexString (c)+")", source, pos);
    
    pos ++;
  }
  
  expect (';');
  
  verifyEntity (token.getStartOffset (), pos);
}
origin: io.fabric8.forge/camel-tooling-util

if (pos == token.getStartOffset())
  throw new XMLParseException("Expected attribute name", source, pos);
  pos++;
  if (pos >= source.length()) {
    int i = Math.min(20, source.length() - token.getStartOffset());
    throw new XMLParseException("Missing end quote (" + endChar + ") of attribute: "
        + lookAheadForErrorMessage(null, token.getStartOffset(), i), token);
origin: jboss-fuse/fabric8

if (pos == token.getStartOffset())
  throw new XMLParseException("Expected attribute name", source, pos);
  pos++;
  if (pos >= source.length()) {
    int i = Math.min(20, source.length() - token.getStartOffset());
    throw new XMLParseException("Missing end quote (" + endChar + ") of attribute: "
      + lookAheadForErrorMessage(null, token.getStartOffset(), i), token);
origin: de.pdark/decentxml

if (pos == token.getStartOffset())
  throw new XMLParseException ("Expected attribute name", source, pos);
  if (pos >= source.length ())
    int i = Math.min (20, source.length () - token.getStartOffset ());
    throw new XMLParseException ("Missing end quote ("+endChar+") of attribute: "
        +lookAheadForErrorMessage (null, token.getStartOffset (), i), token);
origin: de.pdark/decentxml

protected Token parseAttListTypeGroup (XMLTokenizer tokenizer, Token token, DocTypeAttributeList attList)
{
  attList.addNode (toNode (token));
  Token startGroup = token;
  int subLevel = 0;
  
  while ((token = tokenizer.next ()) != null)
  {
    attList.addNode (toNode (token));
    
    if (token.getType () == Type.DOCTYPE_END_GROUP)
    {
      if (subLevel == 0)
        break;
      subLevel --;
    }
    else if (token.getType () == Type.DOCTYPE_BEGIN_GROUP)
    {
      subLevel ++;
    }
  }
  
  if (token == null)
    throw new XMLParseException ("Expected end of group"+tokenizer.lookAheadForErrorMessage ("but found", startGroup.getStartOffset (), 20), startGroup);
  return token;
}
origin: de.pdark/decentxml

  throw new XMLParseException ("Unexpected token "+token+" while parsing attributes of element "+parent.getName (), token); //@COBEX
if (!Character.isWhitespace (token.getSource ().charAt (token.getStartOffset ())))
  throw new XMLParseException ("Expected whitespace between attributes of element a but found "+token, token);
origin: de.pdark/decentxml

protected void parseDocTypeSubElement (XMLTokenizer tokenizer, Token startToken,
    DocType docType)
{
  Token token = startToken;
  token = expect (tokenizer, token, Type.DTD_WHITESPACE, "Expected whitespace after '<!ELEMENT'");
  token = expect (tokenizer, token, Type.TEXT, "Expected element name");
  String name = token.getText ();
  
  token = expect (tokenizer, token, Type.DTD_WHITESPACE, "Expected whitespace after element name");
  Token beforeContent = token;
  
  while ((token = tokenizer.next ()) != null)
  {
    //System.out.println ("parseDocTypeSubElement "+token);
    if (token.getType() == Type.DOCTYPE_END)
      break;
    
    // TODO Check EMPTY, ANY, #PCDATA, (|), ?, *, +
  }
  if (token == null)
    throw new XMLParseException ("Unexpected EOF while parsing element content", tokenizer.getSource (), tokenizer.getOffset ());
  
  String content = tokenizer.getSource ().substring (beforeContent.getEndOffset (), token.getStartOffset ());
  startToken.setEndOffset (token.getEndOffset ());
  DocTypeElement element = new DocTypeElement (startToken, name, content);
  docType.add (element);
}
origin: de.pdark/decentxml

XMLTokenizer dtdTokenizer = createDTDTokenizer (tokenizer.getSource (), token.getStartOffset ());
origin: de.pdark/decentxml

throw new XMLParseException ("Expected '>' after entity declaration"+tokenizer.lookAheadForErrorMessage ("but found", token.getStartOffset (), 20), tokenizer.getSource (), tokenizer.getOffset ());
origin: de.pdark/decentxml

  throw new XMLParseException ("Unexpected EOF while parsing notation declaration", tokenizer.getSource (), tokenizer.getOffset ());
if (token.getType () != Type.DOCTYPE_END)
  throw new XMLParseException ("Expected '>' after notation declaration"+tokenizer.lookAheadForErrorMessage ("but found", token.getStartOffset (), 20), tokenizer.getSource (), tokenizer.getOffset ());
de.pdark.decentxmlTokengetStartOffset

Javadoc

The position in the source at which the token begins

Popular methods of Token

  • getText
    Return the string of text which this token represents in the XMLSource
  • setType
  • <init>
  • getEndOffset
    The position after the last character of the token (matching the definition of String.substring(star
  • getEscapedText
    Return the text with all special characters (like line feed, new line, null bytes, characters in the
  • getPrefixWhiteSpace
  • getSource
  • getType
  • setEndOffset
  • setSource
  • setStartOffset
  • setStartOffset

Popular in Java

  • Making http post requests using okhttp
  • setRequestProperty (URLConnection)
  • getContentResolver (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Collectors (java.util.stream)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now