FileDocCategorySizeDatePackage
Parser.javaAPI DocJMF 2.1.1e2557Mon May 12 12:20:52 BST 2003com.sun.media.sdp

Parser

public class Parser extends Object

Fields Summary
private static Vector
buffer
Constructors Summary
Methods Summary
public java.lang.StringgetLine(java.io.ByteArrayInputStream bin)

        ByteArrayOutputStream bout = new ByteArrayOutputStream();

        if (bin.available() > 0) {
            int ch = readChar(bin);

            while (ch != '\n" && ch != '\r" && ch != -1) {
                bout.write(ch);

                ch = readChar(bin);
            }
        }

        String line = new String(bout.toByteArray());

        return line;
    
public booleangetToken(java.io.ByteArrayInputStream bin, java.lang.String tokenString)

        boolean found = false;

        ByteArrayOutputStream bout = new ByteArrayOutputStream();

        skipWhitespace(bin);

        if (bin.available() > 0) {
            int ch = readChar(bin);

            while (ch != '=" && ch != '\n" && ch != '\r" && ch != -1) {
                bout.write(ch);

                ch = readChar(bin);
            }

            bout.write(ch);
        }

        String token = new String(bout.toByteArray());

        if (tokenString.equals(token)) {
            found = true;
        } else {
            ungetToken(token);
        }

        return found;
    
public booleangetToken(java.io.ByteArrayInputStream bin, java.lang.String tokenString, boolean mandatory)

        boolean found = getToken(bin, tokenString);

        if (!found) {
            if (mandatory) {
                Log.warning("[SDP Parser] Token missing: " + tokenString);
            }
        }

        return found;
    
public voidinit()

        buffer = new Vector();
    
public intreadChar(java.io.ByteArrayInputStream bin)

        int ch;

        if (buffer.size() > 0) {
            ch = ((Integer) buffer.elementAt(0)).intValue();

            buffer.removeElementAt(0);
        } else {
            ch = bin.read();
        }

        return ch;
    
private voidskipWhitespace(java.io.ByteArrayInputStream bin)

        int ch = readChar(bin);

        while (ch == ' " || ch == '\n" || ch == '\r") {
            ch = readChar(bin);
        }

        buffer.insertElementAt(new Integer(ch), 0);
    
public voidungetToken(java.lang.String tokenStr)

        byte token[] = tokenStr.getBytes();

        for (int i = 0; i < token.length; i++) {
            buffer.insertElementAt(new Integer(token[token.length - i - 1]), 0);
        }