📄 datagetset.java
字号:
/* * ==================================================================== * 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 org.w3c.dom.Element;import org.w3c.dom.Node;import org.w3c.dom.NodeList;import org.w3c.dom.Document;import java.util.Vector;/** * This class takes care of saving GUI data to the DOM tree * and to file. It also takes data from the DOM tree and gives * it to the GUI. The concrete class DataFragment implements the * methods necessary for a new node, and the concrete class * DataToDOM implements the methods necessary for an existing node. * * This class and its sublclass(es) implement the set of interfaces * used by the GUI to read and write data. The GUI screen classes * must request a DataManager object from the ConfigTree after * any significant event (ie switching context or saving the data * to the DOM). The ConfigTree passes back either an instance of DataToDOM * or an new instance of DataFragment, depending on the desired behavior. * Thus the only state information kept by a GUI screen is the contents * of its own data fields. When the GUI screen does a read or write to its * DataManager object, the concrete DataManager class takes care * of the correct implementation of that read or write method. */public abstract class DataGetSet implements HostPortData, FeatureData, MarshalData, GroupData, CdrData, HeartbeatData, PDPData, DvrData, DvrAccreditData, EnvData, OSPData, RedirectData, TreeNodeTypes, DataDefaults{ // methods from FeatureData /** * */ public String getTypeData() throws InvalidRequestException { checkValidity("getTypeData"); return getValue("type"); } /** * */ public void setTypeData(String data) throws InvalidRequestException { checkValidity("setTypeData"); setValue("type", data); } /** * */ public String getGroupData() throws InvalidRequestException { checkValidity("getGroupData"); return getValue("group"); } /** * * @param data * * @throws InvalidRequestException */ public void setGroupData(String data) throws InvalidRequestException { checkValidity("setGroupData"); setValue("group", data); } /** * Helper method that puts the uaVMServers tag * into the XML if it is not already there. * We have this method to ease the transition from * an old style of data where these elements did * not exist, to a new where they are required. * @return the new element inserted. */ private Element insertUaVMElement() { Element featureElement = getElement("featureServer"); Document doc = featureElement.getOwnerDocument(); Element uaVMServers = doc.createElement("uaVMServers"); featureElement.appendChild(uaVMServers); uaVMServers.setAttribute("host", "none"); uaVMServers.setAttribute("firstPort", "0"); uaVMServers.setAttribute("lastPort", "0"); uaVMServers.setAttribute("vmType", "voicemail"); return uaVMServers; } /** * * @param data * * @throws InvalidRequestException */ public void setUaVMHostData(String data) throws InvalidRequestException { System.out.println("setUaVMHostData " + data); checkValidity("setUaVMHostData"); Element uaVMServers = getElement("uaVMServers"); if (uaVMServers == null) { System.out.println("request for uaVMServers returned null"); uaVMServers = insertUaVMElement(); } else { System.out.println("request for uaVMServers returned non-null " + uaVMServers); } uaVMServers.setAttribute("host", data); } /** * */ public String getUaVMHostData() throws InvalidRequestException { checkValidity("getUaVMHostData"); Element uaVMServers = getElement("uaVMServers"); if (uaVMServers == null) { uaVMServers = insertUaVMElement(); } return uaVMServers.getAttribute("host"); } /** * * @param data * * @throws InvalidRequestException */ public void setUaVMFirstPortData(String data) throws InvalidRequestException { System.out.println("setUaVMFirstPortData " + data); checkValidity("setUaVMFirstPortData"); Element uaVMServers = getElement("uaVMServers"); if (uaVMServers == null) { uaVMServers = insertUaVMElement(); } uaVMServers.setAttribute("firstPort", data); } /** * */ public String getUaVMFirstPortData() throws InvalidRequestException { checkValidity("getUaVMFirstPortData"); Element uaVMServers = getElement("uaVMServers"); if (uaVMServers == null) { uaVMServers = insertUaVMElement(); } return uaVMServers.getAttribute("firstPort"); } /** * * @param data * * @throws InvalidRequestException */ public void setUaVMLastPortData(String data) throws InvalidRequestException { System.out.println("setUaVMLastPortData " + data); checkValidity("setUaVMLastPortData"); Element uaVMServers = getElement("uaVMServers"); if (uaVMServers == null) { uaVMServers = insertUaVMElement(); } uaVMServers.setAttribute("lastPort", data); } /** * */ public String getUaVMLastPortData() throws InvalidRequestException { checkValidity("getUaVMLastPortData"); Element uaVMServers = getElement("uaVMServers"); if (uaVMServers == null) { uaVMServers = insertUaVMElement(); } return uaVMServers.getAttribute("lastPort"); } /** * */ public String getUaVMTypeData() throws InvalidRequestException { checkValidity("getUaVMTypeData"); Element uaVMServers = getElement("uaVMServers"); if (uaVMServers == null) { uaVMServers = insertUaVMElement(); } return uaVMServers.getAttribute("vmType"); } /** * * @param data * * @throws InvalidRequestException */ public void setUaVMTypeData(String data) throws InvalidRequestException { System.out.println("setUaVMLastPortData " + data); checkValidity("setUaVMTypeData"); Element uaVMServers = getElement("uaVMServers"); if (uaVMServers == null) { uaVMServers = insertUaVMElement(); } uaVMServers.setAttribute("vmType", data); } // methods from MarshalData /** * * */ public String getGatewayHostData() throws InvalidRequestException { checkValidity("getGatewayHostData"); Element element = getElement("gateway"); if (element == null) { return ""; } return element.getAttribute("host"); } /** * * @param data * * @throws InvalidRequestException */ public void setGatewayHostData(String data) throws InvalidRequestException { checkValidity("setGatewayHostData"); Element element = getElement("gateway"); if (element != null) { element.setAttribute("host", data); } } /** * */ public String getGatewayPortData() throws InvalidRequestException { checkValidity("getGatewayPortData"); Element element = getElement("gateway"); if (element == null) { return ""; } return element.getAttribute("port"); } /** * * @param data * * @throws InvalidRequestException */ public void setGatewayPortData(String data) throws InvalidRequestException { checkValidity("setGatewayPortData"); Element element = getElement("gateway"); if (element != null) { element.setAttribute("port", data); } } /** * */ public String getNoResponseTimerData() throws InvalidRequestException { checkValidity("NoResponseTimerData"); return getValue("noResponseTimer"); } /** * * @param data * * @throws InvalidRequestException */ public void setNoResponseTimerData(String data) throws InvalidRequestException { checkValidity("setNoResponseTimerData"); setValue("noResponseTimer", data); } /** * */ public String getAllowUnbillableCallsData() throws InvalidRequestException { checkValidity("AllowUnbillableCallsData"); return getValue("allowUnbillableCalls"); } /** * * @param data * * @throws InvalidRequestException */ public void setAllowUnbillableCallsData(String data) throws InvalidRequestException { checkValidity("setAllowUnbillableCallsData"); setValue("allowUnbillableCalls", data); } /** * */ public String getConferenceBridgeNumberData() throws InvalidRequestException { checkValidity("ConferenceBridgeNumberData"); return getValue("bridgeNumber"); } /** * */ public void setConferenceBridgeNumberData(String data) throws InvalidRequestException { checkValidity("setConferenceBridgeNumberData"); setValue("bridgeNumber", data); } /** * */ public Vector getAccessListData() throws InvalidRequestException { checkValidity("getAccessListData"); Vector vector = new Vector(); Element accessListElement = getElement("accessList"); if (accessListElement == null) { return vector; } NodeList accessNumbers = accessListElement.getElementsByTagName("accessNumber"); for (int i = 0; i < accessNumbers.getLength(); i++) { Element accessNumber = (Element) accessNumbers.item(i); System.out.println("found access number: " + accessNumber.getAttribute("value")); vector.addElement(accessNumber.getAttribute("value")); } return vector; } /** * * @param vector * * @throws InvalidRequestException */ public void setAccessListData(Vector vector) throws InvalidRequestException { checkValidity("setAccessListData"); Element accessList = getElement("accessList"); if (accessList == null) { // This will only happen when an old format is read. // So we'll live with the inefficiency of creating the node twice. Element marshalElement = getElement("marshalServer"); Document doc = marshalElement.getOwnerDocument(); accessList = doc.createElement("accessList"); marshalElement.appendChild(accessList); } Node parent = accessList.getParentNode(); Document doc = accessList.getOwnerDocument(); Element newAccessList = doc.createElement("accessList"); for (int i = 0; i < vector.size(); i++) { System.out.println("found access number at " + Integer.toString(i)); Element accessNumber = doc.createElement("accessNumber"); accessNumber.setAttribute("value", (String) vector.elementAt(i)); newAccessList.appendChild(accessNumber); } parent.replaceChild(newAccessList, accessList); } // added to support Michael Foxworthy's work May 16, 2001 public String getAllowUnknownCallers() throws InvalidRequestException { checkValidity("getAllowUnknownCallers"); return getValue("allowUnknownCallers"); } public void setAllowUnknownCallers(String data) throws InvalidRequestException { checkValidity("setAllowUnknownCallers"); setValue("allowUnknownCallers", data); } // methods from CdrServerData /** * */ public String getRadiusHostData() throws InvalidRequestException { checkValidity("getRadiusHostData"); return getElement("radiusServer").getAttribute("host"); } /** * * @param data * * @throws InvalidRequestException */ public void setRadiusHostData(String data) throws InvalidRequestException { checkValidity("setRadiusHostData"); getElement("radiusServer").setAttribute("host", data); } /** * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -