navigation.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 225 行
JAVA
225 行
/* * Copyright (c) 1998-2000 Caucho Technology -- all rights reserved * * This file is part of Resin(R) Open Source * * Each copy or derived work must preserve the copyright notice and this * notice unmodified. * * Resin Open Source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Resin Open Source 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, or any warranty * of NON-INFRINGEMENT. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with Resin Open Source; if not, write to the * * Free Software Foundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 USA * * @author Emil Ong */package com.caucho.xtpdoc;import com.caucho.vfs.Path;import javax.xml.stream.XMLStreamException;import javax.xml.stream.XMLStreamWriter;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;import java.util.HashMap;import java.util.logging.Logger;public class Navigation { private static final Logger log = Logger.getLogger(Navigation.class.getName()); private Document _document; private Navigation _parent; private int _depth; private Path _rootPath; private String _uri; private String _section; private boolean _threaded; private boolean _comment; private ArrayList<NavigationItem> _items = new ArrayList<NavigationItem>(); private NavigationItem _docItem; private NavigationItem _child; private HashMap<String,NavigationItem> _itemMap = new HashMap<String,NavigationItem>(); public Navigation(Document document, String uri, Path path, int depth) { _document = document; _rootPath = path; _uri = uri; _depth = depth; } public Navigation(Navigation parent, String uri, Path path, int depth) { _parent = parent; _document = parent.getDocument(); _rootPath = path; _uri = uri; _depth = depth; } public Path getRootPath() { return _rootPath; } public void setChild(NavigationItem child) { _child = child; } public String getUri() { return _uri; } public Document getDocument() { return _document; } public Navigation getParent() { return _parent; } public void setSection(String section) { _section = section; } public String getSection() { return _section; } public void setComment(boolean comment) { _comment = comment; } public void setThreaded(boolean threaded) { _threaded = threaded; } public NavigationItem getRoot() { if (_items.size() > 0) return _items.get(0); else return null; } public NavigationItem createItem() { return new NavigationItem(this, null, _depth); } public void addItem(NavigationItem item) { _items.add(item); } public void putItem(String uri, NavigationItem item) { if (_child != null && _child.getUri().equals(uri)) { if (item.getParent() != null) _child.setParent(item.getParent()); _itemMap.put(uri, _child); if (_parent != null) _parent.putItem(uri, item); } else { _itemMap.put(uri, item); if (_parent != null) _parent.putItem(uri, item); } } public NavigationItem getItem(String uri) { return _itemMap.get(uri); } public NavigationItem getRootItem() { if (_items.size() > 0) return _items.get(0); else return null; } public void writeHtml(XMLStreamWriter out) throws XMLStreamException { writeHtml(out, "", 1, 0, 4); } public void writeHtml(XMLStreamWriter out, int styleDepth) throws XMLStreamException { writeHtml(out, "", 1, styleDepth, 4); } public void writeHtml(XMLStreamWriter out, String path, int depth, int styleDepth, int maxDepth) throws XMLStreamException { /* String depthString = (depth == 0) ? "top" : ("" + depth); out.writeStartElement("dl"); out.writeAttribute("class", "atoc-toplevel atoc-toplevel-" + depthString); */ for (NavigationItem item : _items) item.writeHtml(out, path, depth, styleDepth, maxDepth); //out.writeEndElement(); // dl } protected void initSummary() { for (NavigationItem item : _items) item.initSummary(); } public void writeLeftNav(XMLStreamWriter out) throws XMLStreamException { if (_items.size() > 0) { NavigationItem topItem = _items.get(0); } for (NavigationItem item : _items) item.writeLeftNav(out); } public void writeLaTeX(PrintWriter writer) throws IOException { }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?