⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 obrcommandimpl.java

📁 OSGI这是一个中间件,与UPNP齐名,是用于移植到嵌入式平台之上
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        tokenizer.wordChars('\u00A0', '\u00FF');        tokenizer.wordChars('.', '.');        tokenizer.wordChars('-', '-');        tokenizer.wordChars('_', '_');            // Ignore the invoking command name and the OBR command.        int type = tokenizer.nextToken();        type = tokenizer.nextToken();            int EOF = 1;        int SWITCH = 2;        int TARGET = 4;        int VERSION = 8;        int VERSION_VALUE = 16;        // Construct an install record.        ParsedCommand pc = new ParsedCommand();        String currentTargetName = null;        // The state machine starts by expecting either a        // SWITCH or a TARGET.        int expecting = (TARGET);        while (true)        {            // Get the next token type.            type = tokenizer.nextToken();            switch (type)            {                // EOF received.                case StreamTokenizer.TT_EOF:                    // Error if we weren't expecting EOF.                    if ((expecting & EOF) == 0)                    {                        throw new InvalidSyntaxException(                            "Expecting more arguments.", null);                    }                    // Add current target if there is one.                    if (currentTargetName != null)                    {                        pc.addTarget(currentTargetName, null);                    }                    // Return cleanly.                    return pc;                // WORD or quoted WORD received.                case StreamTokenizer.TT_WORD:                case '\'':                case '\"':                    // If we are expecting a target, the record it.                    if ((expecting & TARGET) > 0)                    {                        // Add current target if there is one.                        if (currentTargetName != null)                        {                            pc.addTarget(currentTargetName, null);                        }                        // Set the new target as the current target.                        currentTargetName = tokenizer.sval;                        expecting = (EOF | TARGET | VERSION);                    }                    else if ((expecting & VERSION_VALUE) > 0)                    {                        pc.addTarget(currentTargetName, tokenizer.sval);                        currentTargetName = null;                        expecting = (EOF | TARGET);                    }                    else                    {                        throw new InvalidSyntaxException(                            "Not expecting '" + tokenizer.sval + "'.", null);                    }                    break;                // Version separator character received.                case ';':                    // Error if we weren't expecting the version separator.                    if ((expecting & VERSION) == 0)                    {                        throw new InvalidSyntaxException(                            "Not expecting version.", null);                    }                    // Otherwise, we will only expect a version value next.                    expecting = (VERSION_VALUE);                    break;            }        }    }    private ParsedCommand parseInstallStart(String commandLine)        throws IOException, InvalidSyntaxException    {        // Create a stream tokenizer for the command line string,        // since the syntax for install/start is more sophisticated.        StringReader sr = new StringReader(commandLine);        StreamTokenizer tokenizer = new StreamTokenizer(sr);        tokenizer.resetSyntax();        tokenizer.quoteChar('\'');        tokenizer.quoteChar('\"');        tokenizer.whitespaceChars('\u0000', '\u0020');        tokenizer.wordChars('A', 'Z');        tokenizer.wordChars('a', 'z');        tokenizer.wordChars('0', '9');        tokenizer.wordChars('\u00A0', '\u00FF');        tokenizer.wordChars('.', '.');        tokenizer.wordChars('-', '-');        tokenizer.wordChars('_', '_');            // Ignore the invoking command name and the OBR command.        int type = tokenizer.nextToken();        type = tokenizer.nextToken();            int EOF = 1;        int SWITCH = 2;        int TARGET = 4;        int VERSION = 8;        int VERSION_VALUE = 16;        // Construct an install record.        ParsedCommand pc = new ParsedCommand();        String currentTargetName = null;        // The state machine starts by expecting either a        // SWITCH or a TARGET.        int expecting = (SWITCH | TARGET);        while (true)        {            // Get the next token type.            type = tokenizer.nextToken();            switch (type)            {                // EOF received.                case StreamTokenizer.TT_EOF:                    // Error if we weren't expecting EOF.                    if ((expecting & EOF) == 0)                    {                        throw new InvalidSyntaxException(                            "Expecting more arguments.", null);                    }                    // Add current target if there is one.                    if (currentTargetName != null)                    {                        pc.addTarget(currentTargetName, null);                    }                    // Return cleanly.                    return pc;                // WORD or quoted WORD received.                case StreamTokenizer.TT_WORD:                case '\'':                case '\"':                    // If we are expecting a command SWITCH and the token                    // equals a command SWITCH, then record it.                    if (((expecting & SWITCH) > 0) && tokenizer.sval.equals(NODEPS_SWITCH))                    {                        pc.setResolve(false);                        expecting = (EOF | TARGET);                    }                    // If we are expecting a target, the record it.                    else if ((expecting & TARGET) > 0)                    {                        // Add current target if there is one.                        if (currentTargetName != null)                        {                            pc.addTarget(currentTargetName, null);                        }                        // Set the new target as the current target.                        currentTargetName = tokenizer.sval;                        expecting = (EOF | TARGET | VERSION);                    }                    else if ((expecting & VERSION_VALUE) > 0)                    {                        pc.addTarget(currentTargetName, tokenizer.sval);                        currentTargetName = null;                        expecting = (EOF | TARGET);                    }                    else                    {                        throw new InvalidSyntaxException(                            "Not expecting '" + tokenizer.sval + "'.", null);                    }                    break;                // Version separator character received.                case ';':                    // Error if we weren't expecting the version separator.                    if ((expecting & VERSION) == 0)                    {                        throw new InvalidSyntaxException(                            "Not expecting version.", null);                    }                    // Otherwise, we will only expect a version value next.                    expecting = (VERSION_VALUE);                    break;            }        }    }    private ParsedCommand parseUpdate(String commandLine)        throws IOException, InvalidSyntaxException    {        // Create a stream tokenizer for the command line string,        // since the syntax for install/start is more sophisticated.        StringReader sr = new StringReader(commandLine);        StreamTokenizer tokenizer = new StreamTokenizer(sr);        tokenizer.resetSyntax();        tokenizer.quoteChar('\'');        tokenizer.quoteChar('\"');        tokenizer.whitespaceChars('\u0000', '\u0020');        tokenizer.wordChars('A', 'Z');        tokenizer.wordChars('a', 'z');        tokenizer.wordChars('0', '9');        tokenizer.wordChars('\u00A0', '\u00FF');        tokenizer.wordChars('.', '.');        tokenizer.wordChars('-', '-');        tokenizer.wordChars('_', '_');            // Ignore the invoking command name and the OBR command.        int type = tokenizer.nextToken();        type = tokenizer.nextToken();            int EOF = 1;        int SWITCH = 2;        int TARGET = 4;        int VERSION = 8;        int VERSION_VALUE = 16;        // Construct an install record.        ParsedCommand pc = new ParsedCommand();        String currentTargetName = null;        // The state machine starts by expecting either a        // SWITCH or a TARGET.        int expecting = (SWITCH | TARGET);        while (true)        {            // Get the next token type.            type = tokenizer.nextToken();            switch (type)            {                // EOF received.                case StreamTokenizer.TT_EOF:                    // Error if we weren't expecting EOF.                    if ((expecting & EOF) == 0)                    {                        throw new InvalidSyntaxException(                            "Expecting more arguments.", null);                    }                    // Add current target if there is one.                    if (currentTargetName != null)                    {                        pc.addTarget(currentTargetName, null);                    }                    // Return cleanly.                    return pc;                // WORD or quoted WORD received.                case StreamTokenizer.TT_WORD:                case '\'':                case '\"':                    // If we are expecting a command SWITCH and the token                    // equals a NODEPS switch, then record it.                    if (((expecting & SWITCH) > 0) && tokenizer.sval.equals(NODEPS_SWITCH))                    {                        pc.setResolve(false);                        expecting = (EOF | TARGET);                    }                    // If we are expecting a command SWITCH and the token                    // equals a CHECK swithc, then record it.                    else if (((expecting & SWITCH) > 0) && tokenizer.sval.equals(CHECK_SWITCH))                    {                        pc.setCheck(true);                        expecting = (EOF);                    }                    // If we are expecting a target, the record it.                    else if ((expecting & TARGET) > 0)                    {                        // Add current target if there is one.                        if (currentTargetName != null)                        {                            pc.addTarget(currentTargetName, null);                        }                        // Set the new target as the current target.                        currentTargetName = tokenizer.sval;                        expecting = (EOF | TARGET | VERSION);                    }                    else if ((expecting & VERSION_VALUE) > 0)                    {                        pc.addTarget(currentTargetName, tokenizer.sval);                        currentTargetName = null;                        expecting = (EOF | TARGET);                    }                    else                    {                        throw new InvalidSyntaxException(                            "Not expecting '" + tokenizer.sval + "'.", null);                    }                    break;                // Version separator character received.                case ';':                    // Error if we weren't expecting the version separator.                    if ((expecting & VERSION) == 0)                    {                        throw new InvalidSyntaxException(                            "Not expecting version.", null);                    }                    // Otherwise, we will only expect a version value next.                    expecting = (VERSION_VALUE);                    break;            }        }    }    private ParsedCommand parseSource(String commandLine)        throws IOException, InvalidSyntaxException    {        // Create a stream tokenizer for the command line string,        // since the syntax for install/start is more sophisticated.        StringReader sr = new StringReader(commandLine);        StreamTokenizer tokenizer = new StreamTokenizer(sr);        tokenizer.resetSyntax();        tokenizer.quoteChar('\'');        tokenizer.quoteChar('\"');        tokenizer.whitespaceChars('\u0000', '\u0020');        tokenizer.wordChars('A', 'Z');        tokenizer.wordChars('a', 'z');        tokenizer.wordChars('0', '9');        tokenizer.wordChars('\u00A0', '\u00FF');        tokenizer.wordChars('.', '.');        tokenizer.wordChars('-', '-');        tokenizer.wordChars('_', '_');        tokenizer.wordChars('/', '/');            // Ignore the invoking command name and the OBR command.        int type = tokenizer.nextToken();        type = tokenizer.nextToken();            int EOF = 1;        int SWITCH = 2;        int DIRECTORY = 4;        int TARGET = 8;        int VERSION = 16;        int VERSION_VALUE = 32;        // Construct an install record.        ParsedCommand pc = new ParsedCommand();        String currentTargetName = null;        // The state machine starts by expecting either a        // SWITCH or a DIRECTORY.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -