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

How to use
Token
in
de.pdark.decentxml

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

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

public String getValue ()
{
  if (value == null)
    return token.getText ();
    
  return value;
}

origin: de.pdark/decentxml

/** All tokens are created here.
 * 
 * <p>Use this method to create custom tokens with
 * additional information.
 * 
 * @return a new, pre-initialized token
 */
protected Token createToken ()
{
  Token token = new Token ();
  token.setSource (source);
  token.setStartOffset (pos);
  return token;
}
origin: de.pdark/decentxml

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

public Location (Token token)
{
  this (token.getSource (), token.getStartOffset ());
}
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

/** Parse a doctype declaration
*
*  <p>The resulting token will contain "<!DOCTYPE"
*/
protected void parseDocType (Token token)
{
  token.setType (Type.DOCTYPE);
  nextChars ("<!DOCTYPE", pos - 3, "Expected '<!DOCTYPE'");
}
origin: de.pdark/decentxml

token = expect (tokenizer, token, Type.TEXT, "Expected notation name");
notation.addNode (toNode (token));
String name = token.getText ();
if (token.getType () == Type.DOCTYPE_SYSTEM)
  notation.setText (token.getText ());
  token = skipWhiteSpaceAndComments (tokenizer, tokenizer.next (), notation);
else if (token.getType () == Type.DOCTYPE_PUBLIC)
    && token.getType () != Type.DOCTYPE_END
    if (token.getType () != Type.DTD_WHITESPACE)
      throw new XMLParseException ("Expected whitespace after public ID literal", token);
if (token.getType () != Type.DOCTYPE_END)
  throw new XMLParseException ("Expected '>' after notation declaration"+tokenizer.lookAheadForErrorMessage ("but found", token.getStartOffset (), 20), tokenizer.getSource (), tokenizer.getOffset ());
origin: de.pdark/decentxml

  if (token == null || token.getType() == Type.BEGIN_ELEMENT_END)
    break;
  if (token.getType() != Type.ATTRIBUTE)
    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);
  throw new XMLParseException ("Unexpected end-of-file while parsing attributes of element "+parent.getName (), tokenizer.getSource (), tokenizer.getOffset ());
if (token.getType() == Type.BEGIN_ELEMENT_END)
  String postSpace = token.getPrefixWhiteSpace();
  parent.setPostSpace (postSpace);
  if ("/>".equals (token.getText ().trim ()))
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

/** 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

token.setType (Type.DOCTYPE_BEGIN_SUBSET);
docTypeLevel ++;
break;
token.setType (Type.DOCTYPE_END_SUBSET);
docTypeLevel --;
break;
token.setType (Type.DOCTYPE_BEGIN_GROUP);
docTypeLevel ++;
break;
token.setType (Type.DOCTYPE_END_GROUP);
docTypeLevel --;
break;
token.setType (Type.DOCTYPE_ZERO_OR_ONE);
break;
token.setType (Type.DOCTYPE_ZERO_OR_MORE);
break;
token.setType (Type.DOCTYPE_ONE_OR_MORE);
break;
token.setType (Type.DOCTYPE_ALTERNATIVE);
break;
token.setType (Type.DOCTYPE_SEQUENCE);
origin: de.pdark/decentxml

if (startToken == null)
  throw new XMLParseException ("Expected '<!DOCTYPE'", tokenizer.getSource (), tokenizer.getOffset ());
if (startToken.getType () != Type.DOCTYPE)
  throw new XMLParseException ("Expected '<!DOCTYPE' but found '"+startToken.getText ()+"'", startToken);
docType.setName (token.getText ());
if (token.getType () == Type.DOCTYPE_SYSTEM)
else if (token.getType () == Type.DOCTYPE_PUBLIC)
else if (token.getType () == Type.DOCTYPE_NDATA)
if (token.getType () == Type.DOCTYPE_BEGIN_SUBSET)
if (token.getType () != Type.DOCTYPE_END)
  throw new XMLParseException ("Expected '>', got "+token, token);
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

/** 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

    token.setType (Type.BEGIN_ELEMENT_END);
    inStartElement = false;
    token.setType (Type.BEGIN_ELEMENT_END);
    inStartElement = false;
token.setEndOffset (pos);
origin: de.pdark/decentxml

public BasicNode (Token token)
{
  if (token == null)
    throw new NullPointerException ("token is null");
  
  this.token = token;
  this.type = token.getType();
}

origin: de.pdark/decentxml

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

  ex.setNode (this, pi);
else
  ex.setSource (pi.getToken ().getSource (), pi.getStartOffset () + e.getOffset ());
throw ex;
origin: de.pdark/decentxml

  return null;
if (token.getType() == Type.END_ELEMENT)
  String endName = token.getText ();
  endName = endName.substring (2, endName.length () - 1);
  String name = endName.trim ();
    parent.setEndName (endName);
  parent.getStartToken ().setEndOffset (token.getEndOffset ());
else if (expandEntities && token.getType () == Type.ENTITY)
parent.addNode (n);
if (token.getType() == Type.BEGIN_ELEMENT)
de.pdark.decentxmlToken

Javadoc

A piece of XML.

Most used methods

  • getStartOffset
    The position in the source at which the token begins
  • 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
  • setSource,
  • setStartOffset

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • findViewById (Activity)
  • getSystemService (Context)
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JList (javax.swing)
  • Join (org.hibernate.mapping)
  • Top plugins for WebStorm
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