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

📄 mpeg7instancemetadata.java

📁 基于MPEG 7 标准,符合未来语义网架构,很值得参考
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }

        return contentCreationLocation;
    }

    /**
     * where the description has been created
     *
     * @param contentCreationLocation
     */
    public void setContentCreationLocation(String contentCreationLocation, String contentType) {
        this.contentCreationLocation = contentCreationLocation;
        String xPath = OFFSET + "Description/MultimediaContent/" + contentType + "/MediaInformation/CreationInformation/Creation/CreationCoordinates/CreationLocation/Name";
        writeXmlValue(xPath, this.contentCreationLocation);
    }

    /**
     * set a prived identifier to identify this record. This should be used instead of "Recorc/RecordId" of
     * Serachresults
     *
     * @param idUri
     */
    public void setDescriptionUri(String idUri) {
        // uses the Private identivier of MPEG-7. Tag should be addedd after the DescripitonMetata/Commment tag accoring
        // to the mpeg7-schema. Order is: Comment, PublicIdendifier(0..n), PrivateIdentifier(0..n)
        this.descriptionMediaId = idUri;
        String xPath = OFFSET + "DescriptionMetadata/PrivateIdentifier";
        writeXmlValue(xPath, this.descriptionMediaId);
    }

    /**
     * get the prived identifier to identify this record. This should be used instead of "Recorc/RecordId" of
     * Serachresults
     */
    public String getDescriptionUri() {
        // uses the Private identivier of MPEG-7. Tag should be addedd after the DescripitonMetata/Commment tag accoring
        // to the mpeg7-schema. Order is: Comment, PublicIdendifier(0..n), PrivateIdentifier(0..n)

        String xPath = OFFSET + "DescriptionMetadata/PrivateIdentifier";
        //System.out.println(mpeg7.toString());
        descriptionMediaId = readXmlValue(xPath, descriptionMediaId);
        if (descriptionMediaId == null) {
            descriptionMediaId = "";
        }

        return descriptionMediaId;
    }

    public Date getDescriptionCreationTime() {
        String xPath = OFFSET + "DescriptionMetadata/CreationTime";
        //System.out.println(mpeg7.toString());
        String dateStr = readXmlValue(xPath, "");
        if (dateStr.length() > 0) {
            descriptionCreationTime = Mpeg7ConversionTools.getReference().timePointToDate(dateStr);
        } else {
            descriptionCreationTime = null;
        }

        return descriptionCreationTime;
    }

    public void setDescriptionCreationTime(Date descriptionCreationTime) {
        this.descriptionCreationTime = descriptionCreationTime;
        String xPath = OFFSET + "DescriptionMetadata/CreationTime";
        writeXmlValue(xPath, Mpeg7ConversionTools.getReference().dateTotimePoint(this.descriptionCreationTime));
    }

    /**
     * who has created this description
     *
     * @return
     */
    public String getDescriptionCreatorAgentFamilyName() {
        String xPath = OFFSET + "DescriptionMetadata/Creator/Agent/Name/FamilyName";
        //System.out.println(mpeg7.toString());
        descriptionCreatorAgentFamilyName = readXmlValue(xPath, descriptionCreatorAgentFamilyName);
        if (descriptionCreatorAgentFamilyName == null) {
            descriptionCreatorAgentFamilyName = "";
        }

        return descriptionCreatorAgentFamilyName;
    }

    public void setDescriptionCreatorAgentFamilyName(String descriptionCreatorAgentFamilyName) {
        this.descriptionCreatorAgentFamilyName = descriptionCreatorAgentFamilyName;
        String xPath = OFFSET + "DescriptionMetadata/Creator/Agent/Name/FamilyName";
        writeXmlValue(xPath, this.descriptionCreatorAgentFamilyName);
    }

    public String getDescriptionCreatorAgentGivenName() {
        String xPath = OFFSET + "DescriptionMetadata/Creator/Agent/Name/GivenName";
        //System.out.println(mpeg7.toString());
        descriptionCreatorAgentGivenName = readXmlValue(xPath, descriptionCreatorAgentGivenName);
        if (descriptionCreatorAgentGivenName == null) {
            descriptionCreatorAgentGivenName = "";
        }
        return descriptionCreatorAgentGivenName;
    }

    public void setDescriptionCreatorAgentGivenName(String descriptionCreatorAgentGivenName) {
        this.descriptionCreatorAgentGivenName = descriptionCreatorAgentGivenName;
        String xPath = OFFSET + "DescriptionMetadata/Creator/Agent/Name/GivenName";
        writeXmlValue(xPath, this.descriptionCreatorAgentGivenName);
    }

    /**
     * e.g. creator
     *
     * @return
     */
    public String getDescriptionCreatorRole() {
        String xPath = OFFSET + "DescriptionMetadata/Creator/Role/Name";
        //System.out.println(mpeg7.toString());
        descriptionCreatorRole = readXmlValue(xPath, descriptionCreatorRole);
        if (descriptionCreatorRole == null) {
            descriptionCreatorRole = "";
        }
        return descriptionCreatorRole;
    }

    public void setDescriptionCreatorRole(String descriptionCreatorRole) {
        this.descriptionCreatorRole = descriptionCreatorRole;
        String xPath = OFFSET + "DescriptionMetadata/Creator/Role/Name";
        writeXmlValue(xPath, this.descriptionCreatorRole);
    }

    public Date getDescriptionLastUpdate() {
        String xPath = OFFSET + "DescriptionMetadata/LastUpdate";
        //System.out.println(mpeg7.toString());
        String dateStr = readXmlValue(xPath, "");
        if (dateStr.length() > 0) {
            descriptionLastUpdate = Mpeg7ConversionTools.getReference().timePointToDate(dateStr);
        } else {
            descriptionLastUpdate = null;
        }
        return descriptionLastUpdate;
    }

    public void setDescriptionLastUpdate(Date descriptionLastUpdate) {
        this.descriptionLastUpdate = descriptionLastUpdate;
        String xPath = OFFSET + "DescriptionMetadata/LastUpdate";
        writeXmlValue(xPath, Mpeg7ConversionTools.getReference().dateTotimePoint(this.descriptionLastUpdate));
    }

    /**
     * Summary describing the description purpose and context
     *
     * @return
     */
    public String getDescriptionSummary() {
        String xPath = OFFSET + "DescriptionMetadata/Comment/FreeTextAnnotation";
        //System.out.println(mpeg7.toString());
        descriptionSummary = readXmlValue(xPath, descriptionSummary);
        if (descriptionSummary == null) {
            descriptionSummary = "";
        }
        return descriptionSummary;
    }

    /**
     * Summary describing the description purpose and context
     *
     * @param descriptionSummary
     */
    public void setDescriptionSummary(String descriptionSummary) {
        this.descriptionSummary = descriptionSummary;
        String xPath = OFFSET + "DescriptionMetadata/Comment/FreeTextAnnotation";
        writeXmlValue(xPath, this.descriptionSummary);
    }

    /**
     * meaningful title descripting this desctipion and the content
     * Don't know where to get this title. There is just an FreeTextannotation and this fit better as "Summary"
     * @return
     */
    /*public String getDescriptionTitle() {
        String xPath = OFFSET + "DescriptionMetadata/Comment/FreeTextAnnotation";
        //System.out.println(mpeg7.toString());
        descriptionTitle = readXmlValue(xPath, descriptionTitle);
        if (descriptionTitle == null) {
            descriptionTitle = "";
        }
        return descriptionTitle;
    }*/

    /**
     * meaningful title descripting this desctipion and the content
     *
     * @param descriptionTitle
     */
    /*public void setDescriptionTitle(String descriptionTitle) {
        this.descriptionTitle = descriptionTitle;
        String xPath = OFFSET + "DescriptionMetadata/Comment/FreeTextAnnotation";
        writeXmlValue(xPath, this.descriptionTitle);
        //System.out.println(mpeg7.toString());
    }*/


    /**
     * name of the tool (Softwareaplication) used for createing the desctiption
     *
     * @return
     */
    public String getDescriptionTool() {
        String xPath = OFFSET + "DescriptionMetadata/Instrument/Tool/Name";
        //System.out.println(mpeg7.toString());
        descriptionTool = readXmlValue(xPath, descriptionTool);
        if (descriptionTool == null) {
            descriptionTool = "";
        }
        return descriptionTool;
    }

    /**
     * name of the tool (Softwareaplication) used for createing the desctiption
     *
     * @param descriptionTool
     */
    public void setDescriptionTool(String descriptionTool) {
        this.descriptionTool = descriptionTool;
        String xPath = OFFSET + "DescriptionMetadata/Instrument/Tool/Name";
        writeXmlValue(xPath, this.descriptionTool);
    }

    public String getDescriptionVersion() {
        String xPath = OFFSET + "DescriptionMetadata/Version";
        //System.out.println(mpeg7.toString());
        descriptionVersion = readXmlValue(xPath, descriptionVersion);
        if (descriptionVersion == null) {
            descriptionVersion = "";
        }
        return descriptionVersion;
    }

    public void setDescriptionVersion(String descriptionVersion) {
        this.descriptionVersion = descriptionVersion;
        String xPath = OFFSET + "DescriptionMetadata/Version";
        writeXmlValue(xPath, this.descriptionVersion);
    }


    private String readXmlValue(String xPath, String defaultValue, boolean doGetElementName) {
        String value = defaultValue;
        if (mpeg7 != null) {
            //value = mpeg7.getDomValue(xPath, defaultValue);
            //List<Element> valueList = XmlTools.xpathQuery(mpeg7.getDocument((Document) null), xPath, Mpeg7Template.getMpeg7Namespace());
            //System.out.println(mpeg7.toString());
            /*Document d = mpeg7.getDocument((Document) null);
            Namespace ns = d.getRootElement().getNamespace();*/
            //XmlTools.removeAllNamespacesRecursive(d.getRootElement());
            //xPath = "Mpeg7";
            List<Element> valueList = XmlTools.xpathQuery(mpeg7.getDocument((Document) null), xPath);
            //List<Element> valueList = XmlTools.xpathQuery(mpeg7.getDocument((Document) null), xPath, Mpeg7Template.getMpeg7Namespace());
            if (!valueList.isEmpty()) {
                Element valueElelement = valueList.get(0);
                if (valueElelement != null) {
                    if (doGetElementName) {
                        value = valueElelement.getName();
                    } else {
                        value = valueElelement.getText();
                    }
                }
            }
        }

        return value;
    }

    private String readXmlValue(String xPath, String defaultValue) {
        return readXmlValue(xPath, defaultValue, false);
    }


    private void writeXmlValue(String xPath, String value) {
        if (mpeg7 != null) {
            //mpeg7.setDomValue(xPath, Mpeg7Template.getMpeg7Namespace(), value, "");
            mpeg7.setDomValue(xPath, value);
        }
    }

    public Mpeg7Template getMpeg7() {
        return mpeg7;
    }

    public void setMpeg7(Mpeg7Template mpeg7) {
        this.mpeg7 = mpeg7;
        //if (this.mpeg7.getDocument((Document) null).)
    }

    public double getDescriptionVersion(double defaultValue) {
        double returnValue = defaultValue;

        try {
            Double.parseDouble(this.getDescriptionVersion());
        } catch (Exception e) {
            //e.printStackTrace();
            //silent catch: use defaultvalue on error
        }

        return returnValue;
    }
}

⌨️ 快捷键说明

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