org.openmdx.base.wbxml.ExternalIdentifiers Maven / Gradle / Ivy
/*
* ====================================================================
* Project: openMDX/Core, http://www.openmdx.org/
* Description: Public Document IDs
* Owner: OMEX AG, Switzerland, http://www.omex.ch
* ====================================================================
*
* This software is published under the BSD license as listed below.
*
* Copyright (c) 2010-2013, OMEX AG, Switzerland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name of the openMDX team nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, 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 product includes software developed by other organizations as
* listed in the NOTICE file.
*/
package org.openmdx.base.wbxml;
import java.util.HashMap;
import java.util.Map;
import org.openmdx.base.exception.ServiceException;
import org.openmdx.kernel.exception.BasicException;
/**
* Public Document IDs
* 0x00
to 0x7F
: Well-Known values are set as specified by the OMA MAG/MAE group processes.
*
0x80
to 0x3FFF: Reserved values, registered and managed by OMNA.
* 0x4000
to 0x1FFFFF
: Experimental values, registered by OMNA only for advisory purposes
*
*/
public class ExternalIdentifiers {
/**
* Public identifiers may also be encoded as strings, in the situation
* where a pre-defined numeric identifier is not available.
*/
public static final int LITERAL = 0x00;
/**
* NULL
represents a missing or unknown public document id.
*/
public static final int NULL = 0x01;
/**
* The well known values are in the range code>0x00 to 0x7F
*/
private static String[] WELL_KNOWN = {
"-//WAPFORUM//DTD WML 1.0//EN", // 0x02 WML 1.0
"-//WAPFORUM//DTD WTA 1.0//EN", // 0x03 DEPRECATED - WTA Event 1.0
"-//WAPFORUM//DTD WML 1.1//EN", // 0x04 WML 1.1
"-//WAPFORUM//DTD SI 1.0//EN", // 0x05 Service Indication 1.0
"-//WAPFORUM//DTD SL 1.0//EN", // 0x06 Service Loading 1.0
"-//WAPFORUM//DTD CO 1.0//EN", // 0x07 Cache Operation 1.0
"-//WAPFORUM//DTD CHANNEL 1.1//EN", // 0x08 Channel 1.1
"-//WAPFORUM//DTD WML 1.2//EN", // 0x09 WML 1.2
"-//WAPFORUM//DTD WML 1.3//EN", // 0x0A WML 1.3
"-//WAPFORUM//DTD PROV 1.0//EN", // 0x0B Provisioning 1.0
"-//WAPFORUM//DTD WTA-WML 1.2//EN", // 0x0C WTA-WML 1.2
"-//WAPFORUM//DTD EMN 1.0//EN", // 0x0D Email Notification 1.0 WAP-297
"-//OMA//DTD DRMREL 1.0//EN", // 0x0E DRM REL 1.0
"-//WIRELESSVILLAGE//DTD CSP 1.0//EN", // 0x0F Wireless Village CSP DTD v1.0
"-//WIRELESSVILLAGE//DTD CSP 1.1//EN", // 0x10 Wireless Village CSP DTD v1.1
"-//OMA//DTD WV-CSP 1.2//EN", // 0x11 OMA IMPS - CSP protocol DTD v1.2
"-//OMA//DTD IMPS-CSP 1.3//EN", // 0x12 This document type is used to carry OMA IMPS 1.3 primitives and the information elements within.
"-//OMA//DRM 2.1//EN", // 0x13 OMA DRM 2.1
"-//OMA//SRM 1.0//EN", // 0x14 OMA SRM 1.0
"-//OMA//DCD 1.0//EN", // 0x15 OMA DCD 1.0
"-//OMA//DTD DS-DataObjectEmail 1.2//EN", // 0x16 In order to use a WBXML representation of the 'email data object' defined by OMA-DS
"-//OMA//DTD DS-DataObjectFolder 1.2//EN", // 0x17 In order to use a WBXML representation of the 'folder data object' defined by OMA-DS
"-//OMA//DTD DS-DataObjectFile 1.2//EN" // 0x18 In order to use a WBXML representation of the 'file data object' defined by OMA-DS
};
/**
* The registered values are in the range 0x80
to 0x3FFF
*/
private static final Map0x4000
to 0x1FFFFF
*/
private static final MapLITERAL
if it has to be transferred literally
*
* @throws ServiceException
*/
public static int toPublicDocumentId(
String xmlDocumentId
) throws ServiceException{
if(xmlDocumentId == null) {
return NULL;
}
for(
int i = 0;
i < WELL_KNOWN.length;
i++
){
if(xmlDocumentId.equals(WELL_KNOWN[i])) {
return i + 0x02;
}
}
for(Map.Entry