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

📄 advertisementtutorial.java

📁 jxta的例子
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @return The hWArch value     */    public String getHWArch() {        return hwarch;    }    /**     * Gets the OSArch attribute of the AdvertisementTutorial object     *     * @return The OSArch value     */    public String getOSArch() {        return osarch;    }    /**     * Gets the hWVendor attribute of the AdvertisementTutorial object     *     * @return The hWVendor value     */    public String getHWVendor() {        return hwvendor;    }    /**     * returns the id of the device     *     * @return ID the device id     */    @Override    public ID getID() {        return (id == null ? null : id);    }    /**     * Gets the IP attribute of the AdvertisementTutorial object     *     * @return The IP value     */    public String getIP() {        return ip;    }    /**     * Gets the name attribute of the AdvertisementTutorial object     *     * @return The name value     */    public String getName() {        return name;    }    /**     * Gets the OSName attribute of the AdvertisementTutorial object     *     * @return The OSName value     */    public String getOSName() {        return osname;    }    /**     * Gets the Software Inventory text element     *     * @return The Inventory value     */    public String getSWInventory() {        if (inventory == null) {            inventory = "";        }        return inventory;    }    /**     * Gets the OSVersion attribute of the AdvertisementTutorial object     *     * @return The OSVersion value     */    public String getOSVersion() {        return osversion;    }    /**     * Process an individual element from the document.     *     * @param elem the element to be processed.     * @return true if the element was recognized, otherwise false.     */    protected boolean handleElement(TextElement elem) {        if (elem.getName().equals(idTag)) {            try {                URI id = new URI(elem.getTextValue());                setID(IDFactory.fromURI(id));            } catch (URISyntaxException badID) {                throw new IllegalArgumentException("unknown ID format in advertisement: " + elem.getTextValue());            } catch (ClassCastException badID) {                throw new IllegalArgumentException("Id is not a known id type: " + elem.getTextValue());            }            return true;        }        if (elem.getName().equals(nameTag)) {            setName(elem.getTextValue());            return true;        }        if (elem.getName().equals(OSNameTag)) {            setOSName(elem.getTextValue());            return true;        }        if (elem.getName().equals(OSVersionTag)) {            setOSVersion(elem.getTextValue());            return true;        }        if (elem.getName().equals(OSarchTag)) {            setOSArch(elem.getTextValue());            return true;        }        if (elem.getName().equals(ipTag)) {            setIP(elem.getTextValue());            return true;        }        if (elem.getName().equals(hwarchTag)) {            setHWArch(elem.getTextValue());            return true;        }        if (elem.getName().equals(hwvendorTag)) {            setHWVendor(elem.getTextValue());            return true;        }        if (elem.getName().equals(swTag)) {            setSWInventory(elem.getTextValue());            return true;        }        // element was not handled        return false;    }    /**     * Intialize a System advertisement from a portion of a structured document.     *     * @param root document root     */    protected void initialize(Element root) {        if (!TextElement.class.isInstance(root)) {            throw new IllegalArgumentException(getClass().getName() + " only supports TextElement");        }        TextElement doc = (TextElement) root;        if (!doc.getName().equals(getAdvertisementType())) {            throw new IllegalArgumentException(                    "Could not construct : " + getClass().getName() + "from doc containing a " + doc.getName());        }        Enumeration elements = doc.getChildren();        while (elements.hasMoreElements()) {            TextElement elem = (TextElement) elements.nextElement();            if (!handleElement(elem)) {                LOG.warning("Unhandleded element \'" + elem.getName() + "\' in " + doc.getName());            }        }    }    /**     * {@inheritDoc}     */    @Override    public final String[] getIndexFields() {        return fields;    }    /**     * {@inheritDoc}     */    @Override    public boolean equals(Object obj) {        if (this == obj) {            return true;        }        if (obj instanceof AdvertisementTutorial) {            AdvertisementTutorial adv = (AdvertisementTutorial) obj;            return getID().equals(adv.getID());        }        return false;    }    /**     * {@inheritDoc}     */    public int compareTo(Object other) {        return getID().toString().compareTo(other.toString());    }    /**     * All messages have a type (in xml this is &#0033;doctype) which     * identifies the message     *     * @return String "jxta:AdvertisementTutorial"     */    public static String getAdvertisementType() {        return "jxta:AdvertisementTutorial";    }    /**     * Instantiator     */    public static class Instantiator implements AdvertisementFactory.Instantiator {        /**         * Returns the identifying type of this Advertisement.         *         * @return String the type of advertisement         */        public String getAdvertisementType() {            return AdvertisementTutorial.getAdvertisementType();        }        /**         * Constructs an instance of <CODE>Advertisement</CODE> matching the         * type specified by the <CODE>advertisementType</CODE> parameter.         *         * @return The instance of <CODE>Advertisement</CODE> or null if it         *         could not be created.         */        public Advertisement newInstance() {            return new AdvertisementTutorial();        }        /**         * Constructs an instance of <CODE>Advertisement</CODE> matching the         * type specified by the <CODE>advertisementType</CODE> parameter.         *         * @param root Specifies a portion of a StructuredDocument which will         *             be converted into an Advertisement.         * @return The instance of <CODE>Advertisement</CODE> or null if it         *         could not be created.         */        public Advertisement newInstance(net.jxta.document.Element root) {            return new AdvertisementTutorial(root);        }    }    /**     * Main method     *     * @param args command line arguments.  None defined     */    public static void main(String args[]) {        // The following step is required and only need to be done once,        // without this step the AdvertisementFactory has no means of        // associating an advertisement name space with the proper obect        // in this cast the AdvertisementTutorial        AdvertisementFactory.registerAdvertisementInstance(AdvertisementTutorial.getAdvertisementType()                ,                new AdvertisementTutorial.Instantiator());        AdvertisementTutorial advTutorial = new AdvertisementTutorial();        advTutorial.setID(ID.nullID);        advTutorial.setName("AdvertisementTutorial");        try {            advTutorial.setIP(InetAddress.getLocalHost().getHostAddress());        } catch (UnknownHostException ignored) {// ignored        }        advTutorial.setOSName(System.getProperty("os.name"));        advTutorial.setOSVersion(System.getProperty("os.version"));        advTutorial.setOSArch(System.getProperty("os.arch"));        advTutorial.setHWArch(System.getProperty("HOSTTYPE", System.getProperty("os.arch")));        advTutorial.setHWVendor(System.getProperty("java.vm.vendor"));        System.out.println(advTutorial.toString());    }}

⌨️ 快捷键说明

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