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

📄 a_cmsxmlcontentvalue.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @see org.opencms.xml.types.I_CmsXmlContentValue#getElement()
     */
    public Element getElement() {

        return m_element;
    }

    /**
     * @see org.opencms.widgets.I_CmsWidgetParameter#getId()
     */
    public String getId() {

        StringBuffer result = new StringBuffer(128);
        result.append(getTypeName());
        result.append('.');
        // the '[', ']' and '/' chars from the xpath are invalid for html id's
        result.append(getPath().replace('[', '_').replace(']', '_').replace('/', '.'));
        result.append('.');
        result.append(getIndex());
        return result.toString();
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlContentValue#getIndex()
     */
    public int getIndex() {

        return m_element.getParent().elements(m_element.getQName()).indexOf(m_element);
    }

    /**
     * @see org.opencms.widgets.I_CmsWidgetParameter#getKey()
     */
    public String getKey() {

        StringBuffer result = new StringBuffer(128);
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_prefix)) {
            result.append(m_prefix);
            result.append('.');
        }
        result.append(m_contentDefinition.getInnerName());
        result.append('.');
        result.append(getName());
        return result.toString();
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlContentValue#getLocale()
     */
    public Locale getLocale() {

        return m_locale;
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlContentValue#getMaxIndex()
     */
    public int getMaxIndex() {

        return m_element.getParent().elements(m_element.getQName()).size();
    }

    /**
     * Returns the maximum occurences of this type.<p>
     *
     * @return the maximum occurences of this type
     */
    public int getMaxOccurs() {

        return m_maxOccurs;
    }

    /**
     * Returns the minimum occurences of this type.<p>
     *
     * @return the minimum occurences of this type
     */
    public int getMinOccurs() {

        return m_minOccurs;
    }

    /**
     * Returns the name.<p>
     *
     * @return the name
     */
    public String getName() {

        return m_name;
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlContentValue#getPath()
     */
    public String getPath() {

        String path = m_element.getUniquePath();
        // must remove the first 2 nodes because these are not required for XML content values
        int pos = path.indexOf('/', path.indexOf('/', 1) + 1) + 1;
        path = path.substring(pos);

        // ensure all path elements have an index, even though this may not be required
        return CmsXmlUtils.createXpath(path, 1);
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlContentValue#getPlainText(org.opencms.file.CmsObject)
     */
    public String getPlainText(CmsObject cms) {

        return null;
    }

    /**
     * @see org.opencms.widgets.I_CmsWidgetParameter#hasError()
     */
    public boolean hasError() {

        return false;
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {

        return getTypeName().hashCode();
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlSchemaType#isSimpleType()
     */
    public boolean isSimpleType() {

        // the abstract base type should be used for simple types only
        return true;
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlContentValue#moveDown()
     */
    public void moveDown() {

        int index = getIndex();
        if (index > 0) {
            // only move down if this element is not already at the first index position
            moveValue(false);
            getDocument().initDocument();
        }
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlContentValue#moveUp()
     */
    public void moveUp() {

        int index = getIndex();
        int maxIndex = getMaxIndex();
        if (index < (maxIndex - 1)) {
            // only move up if this element is not already at the last index position
            moveValue(true);
            getDocument().initDocument();
        }
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlSchemaType#setContentDefinition(org.opencms.xml.CmsXmlContentDefinition)
     */
    public void setContentDefinition(CmsXmlContentDefinition contentDefinition) {

        m_contentDefinition = contentDefinition;
    }

    /**
     * Sets the default value for a node of this type.<p>
     * 
     * @param defaultValue the default value to set
     */
    public void setDefault(String defaultValue) {

        m_defaultValue = defaultValue;
    }

    /**
     * @see org.opencms.widgets.I_CmsWidgetParameter#setKeyPrefix(java.lang.String)
     */
    public void setKeyPrefix(String prefix) {

        m_prefix = prefix;
    }

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {

        StringBuffer result = new StringBuffer(128);
        result.append(getClass().getName());
        result.append(": name=");
        result.append(getName());
        result.append(", type=");
        result.append(getTypeName());
        result.append(", path=");
        result.append(getPath());
        String value;
        try {
            value = "'" + getStringValue(null) + "'";
        } catch (Exception e) {
            value = "(CmsObject required to generate)";
        }
        result.append(", value=");
        result.append(value);

        return result.toString();
    }

    /**
     * @see org.opencms.xml.types.I_CmsXmlSchemaType#validateValue(java.lang.String)
     */
    public boolean validateValue(String value) {

        return true;
    }

    /**
     * Moves this XML content element up or down in the XML document.<p> 
     * 
     * Please note: No check is performed if the move violates the XML document schema!<p>
     * 
     * @param moveUp if true, move up, otherwise move down
     */
    protected void moveValue(boolean moveUp) {

        Element e = getElement();
        Element parent = e.getParent();
        List siblings = parent.elements();
        int idx = siblings.indexOf(e);
        int newIdx = moveUp ? idx + 1 : idx - 1;
        siblings.remove(idx);
        siblings.add(newIdx, e);
    }

    /**
     * Convenience method to loads the XML schema definition for this value type from an external file.<p>
     * 
     * @param schemaUri the schema uri to load the XML schema file from
     * 
     * @return the loaded XML schema
     * 
     * @throws CmsRuntimeException if something goes wrong
     */
    protected String readSchemaDefinition(String schemaUri) throws CmsRuntimeException {

        // the schema definition is located in a separate file for easier editing
        String schemaDefinition;
        try {
            schemaDefinition = CmsFileUtil.readFile(schemaUri, CmsEncoder.ENCODING_UTF_8);
        } catch (Exception e) {
            throw new CmsRuntimeException(Messages.get().container(Messages.ERR_XMLCONTENT_LOAD_SCHEMA_1, schemaUri), e);
        }
        return schemaDefinition;
    }
}

⌨️ 快捷键说明

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