📄 cmsjspnavelement.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/flex/jsp/Attic/CmsJspNavElement.java,v $
* Date : $Date: 2002/05/10 21:06:36 $
* Version: $Revision: 1.1.2.1 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2002 The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* First created on 4. Mai 2002, 21:49
*/
package com.opencms.flex.jsp;
import com.opencms.flex.cache.*;
import java.util.*;
import com.opencms.file.*;
import com.opencms.core.*;
/**
* Description of the class CmsJspBeanNav here.
*
* @author Alexander Kandzior (a.kandzior@alkacon.com)
* @version $Revision: 1.1.2.1 $
*/
public class CmsJspNavElement implements Comparable {
private String m_resource;
private String m_text;
private String m_title;
private String m_description;
private float m_position;
private boolean m_hasNav;
public CmsJspNavElement(String resource, Hashtable h) {
m_resource = resource;
m_title = (String)h.get(I_CmsConstants.C_PROPERTY_TITLE);
m_description = (String)h.get(I_CmsConstants.C_PROPERTY_DESCRIPTION);
m_text = (String)h.get(I_CmsConstants.C_PROPERTY_NAVTEXT);
String pos = (String)h.get(I_CmsConstants.C_PROPERTY_NAVPOS);
m_position = Float.MAX_VALUE;
try {
m_position = Float.parseFloat(pos);
} catch (Exception ex) {}
m_hasNav = ((m_text != null) || (m_position != Float.MAX_VALUE));
if (m_text == null) m_text = "[missing " + I_CmsConstants.C_PROPERTY_NAVTEXT + " property for resource " + m_resource + "]";
}
public int compareTo(Object o) {
if (o == null) return 0;
if (! (o instanceof CmsJspNavElement)) return 0;
float f = ((CmsJspNavElement)o).getNavPosition() - m_position;
if (f > 0) return -1;
if (f < 0) return 1;
return 0;
}
public boolean equals(Object o) {
if (o == null) return false;
if (! (o instanceof CmsJspNavElement)) return false;
return m_resource.equals(((CmsJspNavElement)o).getResourceName());
}
public float getNavPosition() {
return m_position;
}
public String getResourceName() {
return m_resource;
}
public String getNavText() {
return m_text;
}
public String getTitle() {
return m_title;
}
public String getDescription() {
return m_description;
}
public boolean isInNavigation() {
return m_hasNav;
}
public boolean isFolderLink() {
return m_resource.endsWith("/");
}
public static ArrayList getNavigationForFolder(CmsObject cms, String folder) {
ArrayList list = new ArrayList();
Vector v = null;
try {
v = cms.getResourcesInFolder(folder);
} catch (Exception e) {
return null;
}
Enumeration e = v.elements();
while (e.hasMoreElements()) {
CmsResource r = (CmsResource)e.nextElement();
if (r.getState() != r.C_STATE_DELETED) {
CmsJspNavElement element = getNavigationForResource(cms, r.getAbsolutePath());
if ((element != null) && element.isInNavigation()) {
list.add(element);
}
}
}
Collections.sort(list);
return list;
}
public static CmsJspNavElement getNavigationForResource(CmsObject cms, String resource) {
Hashtable h;
try {
h = cms.readAllProperties(resource);
} catch (Exception e) {
return null;
}
return new CmsJspNavElement(resource, h);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -