Java APG, Version 1.0
Author Lowell D. Thomas
Copyright © Coast to Coast Research, Inc. 2011

com.coasttocoastresearch.apg
Class Parser.UdtCallback

java.lang.Object
  extended by com.coasttocoastresearch.apg.Parser.UdtCallback
Direct Known Subclasses:
UdtLib.Alphanum, UdtLib.Any, UdtLib.CComment, UdtLib.Comment, UdtLib.DecNum, UdtLib.HexNum, UdtLib.LineEnd, UdtLib.QuotedString, UdtLib.WhiteSpace
Enclosing class:
Parser

public abstract static class Parser.UdtCallback
extends java.lang.Object

Base class for all User-Defined Terminals (UDTs).


Field Summary
 Parser.CallbackData callbackData
          Parser-provisioned data available to all UDT callback functions
 
Constructor Summary
Parser.UdtCallback(Parser parser)
          Base class constructor for the UDT callback functions.
 
Method Summary
abstract  int callback(int offset)
          The UDT function.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

callbackData

public final Parser.CallbackData callbackData
Parser-provisioned data available to all UDT callback functions

Constructor Detail

Parser.UdtCallback

public Parser.UdtCallback(Parser parser)
Base class constructor for the UDT callback functions.

Parameters:
parser - the instance of the Parser to attach this callback function to.
Method Detail

callback

public abstract int callback(int offset)
                      throws java.lang.Exception
The UDT function.

Parameters:
offset - offset into the input string to the first character of the parsed phrase.
Returns:
the matched phrase length, L, or -1 if no phrase was matched. The phrase length must be in the range 0 <= L <=(n-1), where n is the remaining number of characters in the input string.
Throws:
java.lang.Exception - thrown if the callback function returns an illegal value. An illegal value would be a phrase length L >= n, or Illegal values are phrase lengths longer than the length of the remaining input string or a zero (empty) length by a UDT designated as non-empty. (UDTs having names beginning with "u_" are designated as non-empty. UDTs having names beginning with "e_" are designated as empty.)

Java APG, Version 1.0
Author Lowell D. Thomas
Copyright © Coast to Coast Research, Inc. 2011

Licence Notification

All the software in this distribution is free software:
you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program in the COPYING file. If not, see GPL, Version 2
or GPL, Version 3 or write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.