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

📄 jahiacontainerdefinition.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//////  JahiaContainerDefinition//  EV      27.12.2000////  getID//  getJahiaID//  getPageDefID//  getName//  getTitle//  getStructure//  setID////  structureChanged( structure, jData )//  setStructure( structure, jData )//package org.jahia.data.containers;import java.util.*;                     // Vector, Enumerationimport org.jahia.data.*;            // JahiaDataimport org.jahia.utils.*;           // JahiaConsoleimport org.jahia.data.fields.*;     // JahiaFieldimport org.jahia.exceptions.JahiaException;import org.jahia.services.pages.JahiaPage;/** * * <p>Title: A container definition defines name, title and references to * structure and page references for an actual containerList. </p> * <p>Description: This class is used by Jahia to determine the name of the * containerList to create, the reference to the structure, its properties, * etc... </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: Jahia Ltd</p> * @author Eric Vassalli * @version 1.0 */public class JahiaContainerDefinition {    private int         ID;    private int         jahiaID;    private String      name;    private Properties  ctnDefProperties = null;    /**     * @associates JahiaContainerSubDefinition     */    private Hashtable   subDefs;    /***        * constructor        * EV    24.11.2000        *        */    public JahiaContainerDefinition(    int     ID,                                        int     jahiaID,                                        String  name,                                        Hashtable   subDefs  )    {        this.ID             = ID;        this.jahiaID        = jahiaID;        this.name           = name;        this.subDefs        = subDefs;    } // end constructor    /***        * accessor methods        * EV    24.11.2000        *        */    public  int         getID()             {   return ID;                  }    public  int         getJahiaID()        {   return jahiaID;             }    public  String      getName()           {   return name;                }    public  Hashtable   getSubDefs()        {   return subDefs;             }    public  void        setID( int ID )     {   this.ID = ID;               }    public  void        setName( String name ) { this.name = name;          }    /* getTitle **************************************************************/    public String getTitle( int pageDefID ) {        JahiaContainerSubDefinition theSubDef = getSubDef( pageDefID );        if (theSubDef != null) {            return theSubDef.getTitle();        } else {            return "";        }    }    /* getStructure **********************************************************/    public Enumeration getStructure( String dummy, int pageDefID ) {        return getStructure( "", pageDefID, JahiaContainerStructure.ALL_TYPES );    }    /* getStructure (typeFlag) ***********************************************/    public Enumeration getStructure( String dummy, int pageDefID, int typeFlag ) {        Vector structure;        JahiaContainerSubDefinition theSubDef = getSubDef( pageDefID );        if (theSubDef != null) {            structure = theSubDef.getStructure();        } else {            return (new Vector()).elements();        }        Vector out = new Vector();        for (int i=0; i < structure.size(); i++) {            JahiaContainerStructure theStructure = (JahiaContainerStructure) structure.elementAt(i);            if ((theStructure.getObjectType() & typeFlag) != 0) {                out.add( theStructure );            }        }        return out.elements();    }    /* setTitle **************************************************************/    public void setTitle( String title, int pageDefID )    throws JahiaException    {        JahiaConsole.println("JahiaContainerDefinition.setTitle","Setting title : " + title + " for pagedef " + pageDefID );        JahiaContainerSubDefinition theSubDef = getSubDef( pageDefID );        if (theSubDef == null) {            JahiaConsole.println("JahiaContainerDefinition.setTitle","Creating a new list for pagedef " + pageDefID );            theSubDef = createSubDef( pageDefID );        } else {            JahiaConsole.println("JahiaContainerDefinition.setTitle","Using pagedef " + theSubDef.getPageDefID() + " 's list" );        }        theSubDef.setTitle( title );    }    /* setStructure **********************************************************/    public void setStructure( Vector structure, int pageDefID )    throws JahiaException    {        JahiaContainerSubDefinition theSubDef = getSubDef( pageDefID );        if (theSubDef == null) {            theSubDef = createSubDef( pageDefID );        }        theSubDef.setStructure( structure );    }    /* composeStructure ******************************************************/    public void composeStructure( Vector structure, int pageDefID )    throws JahiaException    {        JahiaContainerSubDefinition theSubDef = getSubDef( pageDefID );        if (theSubDef == null) {            theSubDef = createSubDef( pageDefID );        }        theSubDef.composeStructure( structure );    }    /* getSubDef *************************************************************/    private JahiaContainerSubDefinition getSubDef( int pageDefID )    {        return (JahiaContainerSubDefinition) subDefs.get( new Integer(pageDefID) );    } // end getSubDef    /* createSubDef **********************************************************/    private JahiaContainerSubDefinition createSubDef( int pageDefID )    throws JahiaException    {        JahiaContainerSubDefinition theSubDef = new JahiaContainerSubDefinition( 0, pageDefID, "", null );        if (subDefs == null) {            subDefs = new Hashtable();        }        subDefs.put( new Integer(theSubDef.getPageDefID()), theSubDef );        return theSubDef;    } // end createSubDef    /* findFieldInStructure *************************************************/    public JahiaFieldDefinition findFieldInStructure( String fieldName, int pageDefID )    {        Enumeration structure = getStructure( "", pageDefID );        if (fieldName != null) {            while (structure.hasMoreElements()) {                JahiaContainerStructure theStructure = (JahiaContainerStructure) structure.nextElement();                if ((theStructure.getObjectType() & JahiaContainerStructure.JAHIA_FIELD) != 0) {                    JahiaFieldDefinition theFieldDef = (JahiaFieldDefinition) theStructure.getObjectDef();                    if (fieldName.equals(theFieldDef.getName())) {                        return theFieldDef;                    }                }            }        }        return null;    }    /* findContainerInStructure **********************************************/    public JahiaContainerDefinition findContainerInStructure( String containerName, int pageDefID )    {        Enumeration structure = getStructure( "", pageDefID );        if (containerName != null) {            while (structure.hasMoreElements()) {                JahiaContainerStructure theStructure = (JahiaContainerStructure) structure.nextElement();                if ((theStructure.getObjectType() & JahiaContainerStructure.JAHIA_CONTAINER) != 0) {                    JahiaContainerDefinition theContainerDef = (JahiaContainerDefinition) theStructure.getObjectDef();                    if (containerName.equals(theContainerDef.getName())) {                        return theContainerDef;                    }                }            }        }        return null;    }    /* structureChanged ******************************************************/    public synchronized boolean structureChanged( Vector struct, int pageDefID )    throws JahiaException    {        // gets structure        Vector structure;        JahiaContainerSubDefinition theSubDef = getSubDef( pageDefID );        if (theSubDef != null) {            structure = theSubDef.getStructure();        } else {            structure = null;        }        if ((struct == null) || (structure == null)) {            // compares null            JahiaConsole.println("JahiaContainerDefinition.structureChanged", name + ":Structure non-existant in memory, must load from database");            return true;        } else if (struct.size() != structure.size()) {            // compares sizes            JahiaConsole.println("JahiaContainerDefinition.structureChanged", name + ":Size are not equal (cur=" +                                 Integer.toString(structure.size()) + ", new=" + Integer.toString(struct.size()) + ")");            return true;        } else {            // compares fields            for (int i=0; i < structure.size(); i++)            {                JahiaContainerStructure theStructure    = (JahiaContainerStructure) structure.elementAt(i);                JahiaContainerStructure aStructure      = new JahiaContainerStructure(                                    (String)struct.elementAt(i), theSubDef.getID(), i, pageDefID );                if (!theStructure.equals( aStructure )) {                    JahiaConsole.println("JahiaContainerDefinition.structureChanged", name + ":Size equal, fields not equal.");                    return true;                }            }            // JahiaConsole.println("JahiaContainerDefinition.structureChanged", name + ":Size equal, fields equal.");            return false;        }    } // end structureChanged    public void setProperties(Properties newProperties) {        this.ctnDefProperties = newProperties;    }    public Properties getProperties() {        return this.ctnDefProperties;    }    public String getProperty(String propertyName) {        if (this.ctnDefProperties != null) {            return this.ctnDefProperties.getProperty(propertyName);        } else {            return null;        }    }    public void setProperty(String propertyName, String propertyValue) {        if (this.ctnDefProperties != null) {            this.ctnDefProperties.setProperty(propertyName, propertyValue);        } else {            JahiaConsole.println("JahiaContinaerList.setProperty",                                 "ERROR: Properties object is not defined, ignoring property insertion.");        }    }    /**     * Merge a set of properties passed in parameters with the internal     * properties set. Returns true if the resulting set of internal properties     * must be serialized.     * @param newProperties     * @return true if the result of the merge is a different set of properties     * that needs to be serialized.     */    public boolean mergeProperties(Properties newProperties) {        boolean mustSave = false;        Enumeration newPropKeys = newProperties.keys();        while (newPropKeys.hasMoreElements()) {            String curNewPropName = (String) newPropKeys.nextElement();            String curNewPropValue = newProperties.getProperty(curNewPropName);            if (this.ctnDefProperties.containsKey(curNewPropName)) {                String internalPropValue = this.ctnDefProperties.getProperty(curNewPropName);                if (!internalPropValue.equals(curNewPropValue)) {                    // properties are not equals, lets set it.                    this.ctnDefProperties.setProperty(curNewPropName, curNewPropValue);                    mustSave = true;                }            } else {                // this is a new property.                this.ctnDefProperties.setProperty(curNewPropName, curNewPropValue);                mustSave = true;            }        }        return mustSave;    }    /***        * setStructure        * EV    01.01.2001        *        *//*    public synchronized void setStructure( Vector struct, int pageDefID, int jahiaID )    throws JahiaException    {        this.structure = new Vector();        for (int i=0; i < struct.size(); i++)        {            this.structure.add( new JahiaContainerStructure(                                (String)struct.elementAt(i), this.getID(), i, pageDefID, jahiaID ) );        }    } // end setStructure*/} // end JahiaContainerDefinition

⌨️ 快捷键说明

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