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

📄 obrcommandimpl.java

📁 OSGI这是一个中间件,与UPNP齐名,是用于移植到嵌入式平台之上
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        int expecting = (SWITCH | DIRECTORY);        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(EXTRACT_SWITCH))                    {                        pc.setExtract(true);                        expecting = (DIRECTORY);                    }                    // If we are expecting a directory, the record it.                    else if ((expecting & DIRECTORY) > 0)                    {                        // Set the directory for the command.                        pc.setDirectory(tokenizer.sval);                        expecting = (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 void help(PrintStream out, StringTokenizer st)    {        String command = HELP_CMD;        if (st.hasMoreTokens())        {            command = st.nextToken();        }        if (command.equals(URLS_CMD))        {            out.println("");            out.println("obr " + URLS_CMD + " [<repository-file-url> ...]");            out.println("");            out.println(                "This command gets or sets the URLs to the repository files\n" +                "used by OBR. Specify no arguments to get the current repository\n" +                 "URLs or specify a space-delimited list of URLs to change the\n" +                "URLs. Each URL should point to a file containing meta-data about\n" +                "available bundles in XML format.");            out.println("");        }        else if (command.equals(LIST_CMD))        {            out.println("");            out.println("obr " + LIST_CMD + " [<string> ...]");            out.println("");            out.println(                "This command lists bundles available in the bundle repository.\n" +                "If no arguments are specified, then all available bundles are\n" +                "listed, otherwise any arguments are concatenated with spaces\n" +                "and used as a substring filter on the bundle names.");            out.println("");        }        else if (command.equals(INFO_CMD))        {            out.println("");            out.println("obr " + INFO_CMD                + " <bundle-name>[;<version>] ...");            out.println("");            out.println(                "This command displays the meta-data for the specified bundles.\n" +                "If a bundle's name contains spaces, then it must be surrounded\n" +                "by quotes. It is also possible to specify a precise version\n" +                "if more than one version exists, such as:\n" +                "\n" +                "    obr info \"Bundle Repository\";1.0.0\n" +                "\n" +                "The above example retrieves the meta-data for version \"1.0.0\"\n" +                "of the bundle named \"Bundle Repository\".");            out.println("");        }        else if (command.equals(DEPLOY_CMD))        {            out.println("");            out.println("obr " + DEPLOY_CMD                + " [" + NODEPS_SWITCH                + "] <bundle-name>[;<version>] ... | <bundle-id> ...");            out.println("");            out.println(                "This command tries to install or update the specified bundles\n" +                "and all of their dependencies by default; use the \"" + NODEPS_SWITCH + "\" switch\n" +                "to ignore dependencies. You can specify either the bundle name or\n" +                "the bundle identifier. If a bundle's name contains spaces, then\n" +                "it must be surrounded by quotes. It is also possible to specify a\n" +                "precise version if more than one version exists, such as:\n" +                "\n" +                "    obr deploy \"Bundle Repository\";1.0.0\n" +                "\n" +                "For the above example, if version \"1.0.0\" of \"Bundle Repository\" is\n" +                "already installed locally, then the command will attempt to update it\n" +                "and all of its dependencies; otherwise, the command will install it\n" +                "and all of its dependencies.");            out.println("");        }        else if (command.equals(INSTALL_CMD))        {            out.println("");            out.println("obr " + INSTALL_CMD                + " [" + NODEPS_SWITCH                + "] <bundle-name>[;<version>] ...");            out.println("");            out.println(                "This command installs the specified bundles and all of their\n" +                "dependencies by default; use the \"" + NODEPS_SWITCH + "\" switch to ignore\n" +                "dependencies. If a bundle's name contains spaces, then it\n" +                "must be surrounded by quotes. If a specified bundle is already\n" +                "installed, then this command has no effect. It is also possible\n" +                "to specify a precise version if more than one version exists,\n" +                "such as:\n" +                "\n" +                "    obr install \"Bundle Repository\";1.0.0\n" +                "\n" +                "The above example installs version \"1.0.0\" of the bundle\n" +                "named \"Bundle Repository\" and its dependencies. ");            out.println("");        }        else if (command.equals(START_CMD))        {            out.println("");            out.println("obr " + START_CMD                + " [" + NODEPS_SWITCH                + "] <bundle-name>[;<version>] ...");            out.println("");            out.println(                "This command installs and starts the specified bundles and all\n" +                "of their dependencies by default; use the \"" + NODEPS_SWITCH + "\" switch to\n" +                "ignore dependencies. If a bundle's name contains spaces, then\n" +                "it must be surrounded by quotes. If a specified bundle is already\n" +                "installed, then this command has no effect. It is also possible\n" +                "to specify a precise version if more than one version exists,\n" +                "such as:\n" +                "\n" +                "    obr start \"Bundle Repository\";1.0.0\n" +                "\n" +                "The above example installs and starts version \"1.0.0\" of the\n" +                "bundle named \"Bundle Repository\" and its dependencies.");            out.println("");        }        else if (command.equals(UPDATE_CMD))        {            out.println("");            out.println("obr " + UPDATE_CMD + " " + CHECK_SWITCH);            out.println("");            out.println("obr " + UPDATE_CMD                + " [" + NODEPS_SWITCH                + "] <bundle-name>[;<version>] ... | <bundle-id> ...");            out.println("");            out.println(                "The first form of the command above checks for available updates\n" +                "and the second updates the specified locally installed bundles\n" +                "and all of their dependencies by default; use the \"" + NODEPS_SWITCH + "\" switch\n" +                "to ignore dependencies. You can specify either the bundle name or\n" +                "the bundle identifier. If a bundle's name contains spaces, then\n" +                "it must be surrounded by quotes. If a specified bundle is not\n" +                "already installed, then this command has no effect. It is also\n" +                "possible to specify a precise version if more than one version\n" +                "exists, such as:\n" +                "\n" +                "    obr update \"Bundle Repository\";1.0.0\n" +                "\n" +                "The above example updates version \"1.0.0\" of the bundle named\n" +                "\"Bundle Repository\" and its dependencies. The update command may\n" +                "install new bundles if the updated bundles have new dependencies.");            out.println("");        }        else if (command.equals(SOURCE_CMD))        {            out.println("");            out.println("obr " + SOURCE_CMD                + " [" + EXTRACT_SWITCH                + "] <local-dir> <bundle-name>[;<version>] ...");            out.println("");            out.println(                "This command retrieves the source archives of the specified\n" +                "bundles and saves them to the specified local directory; use\n" +                "the \"" + EXTRACT_SWITCH + "\" switch to automatically extract the source archives.\n" +                "If a bundle name contains spaces, then it must be surrounded\n" +                "by quotes. It is also possible to specify a precise version if\n" +                "more than one version exists, such as:\n" +                "\n" +                "    obr source /home/rickhall/tmp \"Bundle Repository\";1.0.0\n" +                "\n" +                "The above example retrieves the source archive of version \"1.0.0\"\n" +                "of the bundle named \"Bundle Repository\" and saves it to the\n" +                "specified local directory.");            out.println("");        }        else        {            out.println("obr " + HELP_CMD                + " [" + URLS_CMD + " | " + LIST_CMD                + " | " + INFO_CMD + " | " + INSTALL_CMD                + " | " + DEPLOY_CMD + " | " + START_CMD                + " | " + UPDATE_CMD + " | " + SOURCE_CMD + "]");            out.println("obr " + URLS_CMD + " [<repository-file-url> ...]");            out.println("obr " + LIST_CMD + " [<string> ...]");            out.println("obr " + INFO_CMD                + " <bundle-name>[;<version>] ...");            out.println("obr " + DEPLOY_CMD                + " [" + NODEPS_SWITCH                + "] <bundle-name>[;<version>] ... | <bundle-id> ...");            out.println("obr " + INSTALL_CMD                + " [" + NODEPS_SWITCH                + "] <bundle-name>[;<version>] ...");            out.println("obr " + START_CMD                + " [" + NODEPS_SWITCH                + "] <bundle-name>[;<version>] ...");            out.println("obr " + UPDATE_CMD + " " + CHECK_SWITCH);            out.println("obr " + UPDATE_CMD                + " [" + NODEPS_SWITCH                + "] <bundle-name>[;<version>] ... | <bundle-id> ...");            out.println("obr " + SOURCE_CMD                + " [" + EXTRACT_SWITCH                + "] <local-dir> <bundle-name>[;<version>] ...");        }    }    private static class ParsedCommand    {        private static final int NAME_IDX = 0;        private static final int VERSION_IDX = 1;        private boolean m_isResolve = true;        private boolean m_isCheck = false;        private boolean m_isExtract = false;        private String m_dir = null;        private String[][] m_targets = new String[0][];                public boolean isResolve()        {            return m_isResolve;        }                public void setResolve(boolean b)        {            m_isResolve = b;        }        public boolean isCheck()        {            return m_isCheck;        }                public void setCheck(boolean b)        {            m_isCheck = b;        }        public boolean isExtract()        {            return m_isExtract;        }                public void setExtract(boolean b)        {            m_isExtract = b;        }        public String getDirectory()        {            return m_dir;        }                public void setDirectory(String s)        {            m_dir = s;        }        public int getTargetCount()        {            return m_targets.length;        }                public String getTargetName(int i)        {            if ((i < 0) || (i >= getTargetCount()))            {                return null;            }            return m_targets[i][NAME_IDX];        }                public String getTargetVersion(int i)        {            if ((i < 0) || (i >= getTargetCount()))            {                return null;            }            return m_targets[i][VERSION_IDX];        }        public void addTarget(String name, String version)        {            String[][] newTargets = new String[m_targets.length + 1][];            System.arraycopy(m_targets, 0, newTargets, 0, m_targets.length);            newTargets[m_targets.length] = new String[] { name, version };            m_targets = newTargets;        }    }}

⌨️ 快捷键说明

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