📄 syncmlcanonizer.java
字号:
/** * Copyright (C) 2003-2004 Funambol * * This program 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. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package sync4j.server;import java.io.Serializable;import java.util.logging.Logger;import java.util.logging.Level;import sync4j.framework.logging.Sync4jLogger;import sync4j.framework.core.SyncML;import sync4j.framework.core.Sync4jException;import org.apache.commons.lang.StringUtils;/** * This class is used for transformer the message in the canonical form. * */public class SyncMLCanonizer implements Serializable { // ------------------------------------------------------------ Private data private static final Logger log = Sync4jLogger.getLogger("engine"); // ------------------------------------------------------------ Constructors public SyncMLCanonizer() { } // ---------------------------------------------------------- Public methods /** * The message input must be canonized every time before call the XML-Java * mapping tool (JiBX) that it parsers and generates the SyncML object. * * @param message the input XML message * * @return message the input XML message canonized **/ public String canonize(String message) { if (log.isLoggable(Level.FINE)) { log.fine("Starting process of canonization"); } return message; } /** * Remove all namespace from the message. * * @param message the original message xml * */ public String removeNamespaces(String message) { String[] ns = new String[9]; ns[0] = " xmlns=\"syncml:metinf\"" ; ns[1] = " xmlns='syncml:metinf'" ; ns[2] = " xmlns=\"syncml:devinf\"" ; ns[3] = " xmlns='syncml:devinf'" ; ns[4] = " xmlns=\"syncml:devinf\"" ; ns[5] = " xmlns='SYNCML:SYNCML1.0'"; ns[6] = " xmlns=\"SYNCML:SYNCML1.0\""; ns[7] = " xmlns='SYNCML:SYNCML1.1'"; ns[8] = " xmlns=\"SYNCML:SYNCML1.1\""; for (int i=0; i<ns.length; i++) { message = StringUtils.replace(message, ns[i], ""); } return message; } /** * Replace into message the '&' with "&" * * @param message the original message xml * * @return message the message updated */ public String replaceEntity(String message) { return StringUtils.replace(message, "&", "&"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -