📄 30d364adc4b7001a1e5ff42f2510af1d
字号:
/* * ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */package vocal.data;import javax.swing.tree.DefaultMutableTreeNode;import javax.swing.JOptionPane;import javax.swing.JFrame;import java.io.StringReader;import java.util.Stack;import org.w3c.dom.Document;import org.w3c.dom.Node;import org.w3c.dom.NodeList;import org.w3c.dom.Element;import org.w3c.dom.DocumentFragment;import org.xml.sax.Attributes;import org.xml.sax.XMLReader;import org.xml.sax.InputSource;import org.xml.sax.helpers.DefaultHandler;import org.xml.sax.SAXException;import javax.xml.parsers.SAXParser;import javax.xml.parsers.SAXParserFactory;import javax.xml.parsers.ParserConfigurationException;/** * This class creates a new node of the DOM tree and saves data * from the DOM to that new node. The new node is constructed * as a DataFragment, hence the name of the class. * * This class and its sublclass(es) implement the set of interfaces * used by the GUI to read and write data. * * The user may choose to create a new node, enter some data, * and then cancel the whole operation. For this reason, the * node is not actually inserted into the DOM tree until the * user has pressed the "Ok" button. * * Once this node has been saved for the first time (the user * pressed the Ok button) it is no longer valid to use this object * for saving further data changes. Thus the first save causes * an "invalid" flag to be set and any further calls to the object * will then throw an InvalidRequestException. */public class DataFragment extends DataGetSet implements HostPortData, FeatureData, MarshalData, GroupData, CdrData, RedirectData, TreeNodeTypes, DataDefaults{ // protected fields protected ConfigTree configTree = null; protected AccreditConfigTree accreditconfigTree = null; /** * This field is used as a validity check. * Once a DataFragment has been saved, there are no more * valid operations that can be performed on it, * so validity becomes false. */ protected boolean isValid = true; /** * The node of the ConfigTree where this fragment will be inserted. */ protected DefaultMutableTreeNode parentTreeNode; /** * The DOM node where this will be inserted. */ protected Node parentNode; /** * The next node up the DOM. */ protected Node grandparentNode; /** * The DocumentFragment that holds the data. */ protected DocumentFragment fragment; /** * String that creates the Document Fragment for a Feature Server. */ private static String FEATURE_SERVER_STRING = new String("<featureServer host=\"none\" port=\"-1\">" + "<type value=\"none\"/>" + "<group value=\"none\"/>" + "</featureServer>"); /** * String that creates the Document Fragment for a Marshal Server. */ private static String MARSHAL_SERVER_STRING = new String("<marshalServer host=\"none\" port=\"-1\">" + "<type value=\"none\"/>" + "<group value=\"none\"/>" + "<gateway host=\"none\" port=\"-1\"/>" + "<noResponseTimer value=\"100\"/>" + "<allowUnbillableCalls value=\"true\"/>" + "<allowUnknownCallers value=\"false\"/>" + "<conferenceBridge>" + "<bridgeNumber value=\"none\"/>" + "<accessList/>" + "</conferenceBridge>" + "</marshalServer>"); /** * String that creates the Document Fragment for a CDR Server. */ private static String CDR_SERVER_STRING = new String("<cdrServer host=\"none\" port=\"-1\">" + "<group value=\"none\"/>" + "<radiusServer host=\"none\" retries=\"5\" secretKey=\"none\"/>" + "<billing frequency=\"300\"" + " dirPath=\"../billing/\"" + " lockFile=\".billingLock\"" + " dataFile=\"billing.dat\"" + " unsentExtension=\".unsent\"" + " rolloverSize=\"100000\"" + " rolloverPeriod=\"300\"/>" + " billForRingtime=\"false\"/>" + "</cdrServer>"); /** * String that creates the Document Fragment for a PDP Server. */ private static String PDP_SERVER_STRING = new String("<pdpServer host=\"none\" port=\"3288\">" + "<group value=\"none\"/>" + "<maxThreads value=\"8\"/>" + "<keepAliveTimer value=\"5000\"/>" + "<responseTime value=\"10000\"/>" + "</pdpServer>"); /** * String that creates the Document Fragment for a DVR Client. */ private static String DVR_CLIENT_STRING = new String("<dvr host=\"000.000.000.000\" port=\"8001\">" + "<hostname value=\"none\"/>" + "<group value=\"none\"/>" +"<Camera1 Name=\"Camera1\"" +" Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera2 Name=\"Camera2\"" +" Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera3 Name=\"Camera3\"" +" Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera4 Name=\"Camera4\"" +" Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera5 Name=\"Camera5\"" +" Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera6 Name=\"Camera6\"" +" Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera7 Name=\"Camera7\"" +" Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera8 Name=\"Camera8\"" +" Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"</dvr>"); /* private static String DVR_CLIENT_STRING = new String("<dvr host=\"none\" port=\"8001\" hostname=\"none\">" + "<group value=\"none\"/>" +"<Camera1 Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera2 Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera3 Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera4 Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera5 Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera6 Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"<Camera8 Preview=\"false\"" +" Alarm=\"false\"" +" Record=\"false\"" +" Control=\"false\"" +" Port=\"com1\"" +" Address=\"0\"/>" +"</dvr>"); */ /** * String that creates the Document Fragment for a PDP Server. */ private static String ENV_CLIENT_STRING = new String("<env host=\"none\" port=\"8002\">" + "<group value=\"none\"/>" + "<smokeAlarm value=\"8\"/>" + "<temperature value=\"25\"/>" + "<water value=\"100\"/>" + "</env>"); /* private static String ENV_CLIENT_STRING = new String("<env host=\"none\" port=\"3288\">" + "<group value=\"none\"/>" + "<maxThreads value=\"8\"/>" + "<keepAliveTimer value=\"5000\"/>" + "<responseTime value=\"10000\"/>" + "</env>"); */ private static String ACCDVR_CLIENT_STRING = new String("<dvr host=\"000.000.000.000\" port=\"8001\"><hostname value=\"none\"></hostname>" + "<group value=\"DvrGroup\"></group>" + "<Camera1 Name=\"Camera1\" Control=\"false\" History=\"false\"></Camera1>" + "<Camera2 Name=\"Camera2\" Control=\"false\" History=\"false\"></Camera2>" + "<Camera3 Name=\"Camera3\" Control=\"false\" History=\"false\"></Camera3>" + "<Camera4 Name=\"Camera4\" Control=\"false\" History=\"false\"></Camera4>" + "<Camera5 Name=\"Camera5\" Control=\"false\" History=\"false\"></Camera5>" + "<Camera6 Name=\"Camera6\" Control=\"false\" History=\"false\"></Camera6>" + "<Camera7 Name=\"Camera7\" Control=\"false\" History=\"false\"></Camera7>" + "<Camera8 Name=\"Camera8\" Control=\"false\" History=\"false\"></Camera8>" + "</dvr>"); /** * String that creates the Document Fragment for a Redirect Server. */ private static String REDIRECT_SERVER_STRING = new String("<redirectServer host=\"none\" port=\"-1\">" + "<group value=\"none\"/>" + "<syncPort value=\"0\"/>" + "</redirectServer>"); /** * String that creates the Document Fragment for a Heartbeat Server. */ private static String HEARTBEAT_SERVER_STRING = new String("<heartbeatServer host=\"none\" port=\"0\">" + "<group value=\"none\"/>" + "</heartbeatServer>"); /** * String that creates the Document Fragment for a Group. */ protected static String GROUP_STRING = new String("<serverGroup value=\"none\"/>"); // protected static String GROUP_STRING = // new String("<clientGroup value=\"none\"/>"); // Constructors /** * This constructor is used from the GUI to create a DataFragment * in sync with the ConfigTree. */ public DataFragment(int type, ConfigTree tree, DefaultMutableTreeNode node) { super(); configTree = tree; parentTreeNode = node; parentNode = configTree.getNode(parentTreeNode); grandparentNode = parentNode.getParentNode(); Element parentElement = null; Element grandparentElement = null; try { parentElement = (Element) parentNode; grandparentElement = (Element) grandparentNode; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -