Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.apache.cxf.binding.corba.interceptors;
 
 
 public final class SystemExceptionHelper 
     implements org.omg.CORBA.portable.Streamable {
     
     private static final int BAD_CONTEXT = 0;
     private static final int BAD_INV_ORDER = 1;
     private static final int BAD_OPERATION = 2;
     private static final int BAD_PARAM = 3;
     private static final int BAD_QOS = 4;
     private static final int BAD_TYPECODE = 5;
     private static final int CODESET_INCOMPATIBLE = 6;
     private static final int COMM_FAILURE = 7;
     private static final int DATA_CONVERSION = 8;
     private static final int FREE_MEM = 9;
     private static final int IMP_LIMIT = 10;
     private static final int INITIALIZE = 11;
     private static final int INTERNAL = 12;
     private static final int INTF_REPOS = 13;
     private static final int INVALID_TRANSACTION = 14;
     private static final int INV_FLAG = 15;
     private static final int INV_IDENT = 16;
     private static final int INV_OBJREF = 17;
     private static final int INV_POLICY = 18;
     private static final int MARSHAL = 19;
     private static final int NO_IMPLEMENT = 20;
     private static final int NO_MEMORY = 21;
     private static final int NO_PERMISSION = 22;
     private static final int NO_RESOURCES = 23;
     private static final int NO_RESPONSE = 24;
     private static final int OBJECT_NOT_EXIST = 25;
     private static final int OBJ_ADAPTER = 26;
     private static final int PERSIST_STORE = 27;
     private static final int REBIND = 28;
     private static final int TIMEOUT = 29;
     private static final int TRANSACTION_MODE = 30;
     private static final int TRANSACTION_REQUIRED = 31;
     private static final int TRANSACTION_ROLLEDBACK = 32;
     private static final int TRANSACTION_UNAVAILABLE = 33;
     private static final int TRANSIENT = 34;
     private static final int UNKNOWN = 35;
     
     private static final String[] IDS = {
         "IDL:omg.org/CORBA/BAD_CONTEXT:1.0",
         "IDL:omg.org/CORBA/BAD_INV_ORDER:1.0",
         "IDL:omg.org/CORBA/BAD_OPERATION:1.0""IDL:omg.org/CORBA/BAD_PARAM:1.0",
         "IDL:omg.org/CORBA/BAD_QOS:1.0""IDL:omg.org/CORBA/BAD_TYPECODE:1.0",
         "IDL:omg.org/CORBA/CODESET_INCOMPATIBLE:1.0",
         "IDL:omg.org/CORBA/COMM_FAILURE:1.0",
         "IDL:omg.org/CORBA/DATA_CONVERSION:1.0",
         "IDL:omg.org/CORBA/FREE_MEM:1.0""IDL:omg.org/CORBA/IMP_LIMIT:1.0",
         "IDL:omg.org/CORBA/INITIALIZE:1.0""IDL:omg.org/CORBA/INTERNAL:1.0",
         "IDL:omg.org/CORBA/INTF_REPOS:1.0",
         "IDL:omg.org/CORBA/INVALID_TRANSACTION:1.0",
         "IDL:omg.org/CORBA/INV_FLAG:1.0""IDL:omg.org/CORBA/INV_IDENT:1.0",
         "IDL:omg.org/CORBA/INV_OBJREF:1.0""IDL:omg.org/CORBA/INV_POLICY:1.0",
         "IDL:omg.org/CORBA/MARSHAL:1.0""IDL:omg.org/CORBA/NO_IMPLEMENT:1.0",
         "IDL:omg.org/CORBA/NO_MEMORY:1.0""IDL:omg.org/CORBA/NO_PERMISSION:1.0",
         "IDL:omg.org/CORBA/NO_RESOURCES:1.0",
         "IDL:omg.org/CORBA/NO_RESPONSE:1.0",
         "IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0",
         "IDL:omg.org/CORBA/OBJ_ADAPTER:1.0",
         "IDL:omg.org/CORBA/PERSIST_STORE:1.0""IDL:omg.org/CORBA/REBIND:1.0",
         "IDL:omg.org/CORBA/TIMEOUT:1.0",
         "IDL:omg.org/CORBA/TRANSACTION_MODE:1.0",
         "IDL:omg.org/CORBA/TRANSACTION_REQUIRED:1.0",
         "IDL:omg.org/CORBA/TRANSACTION_ROLLEDBACK:1.0",
         "IDL:omg.org/CORBA/TRANSACTION_UNAVAILABLE:1.0",
         "IDL:omg.org/CORBA/TRANSIENT:1.0""IDL:omg.org/CORBA/UNKNOWN:1.0"};
 
 
    
    private SystemExceptionHelper() {
    }
    private SystemExceptionHelper(SystemException ex) {
         = ex;
    }
    
    
    private static int binarySearch(String[] arrString value) {
        int left = 0;
        int right = arr.length;
        int index = -1;
        while (left < right) {
            int m = (left + right) >>> 1;
            int res = arr[m].compareTo(value);
            if (res == 0) {
                index = m;
                break;
            } else if (res > 0) {
                right = m;
            } else {
                left = m + 1;
            }
        }
        return index;
    }
    public static void insert(Any anySystemException val) {
        any.insert_Streamable(new SystemExceptionHelper(val));
    }
    
    
    //CHECKSTYLE:OFF 
    //NCSS is to high for this due to the massive switch statement
    public static SystemException read(org.omg.CORBA.portable.InputStream in) {
        String id = in.read_string();
        int minor = in.read_ulong();
        org.omg.CORBA.CompletionStatus status = org.omg.CORBA.CompletionStatus.from_int(in.read_ulong());
        int n = binarySearch(id);
        SystemException ex = null;
        switch (n) {
        case :
            ex = new org.omg.CORBA.BAD_CONTEXT(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.BAD_INV_ORDER(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.BAD_OPERATION(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.BAD_PARAM(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.BAD_QOS(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.BAD_TYPECODE(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.CODESET_INCOMPATIBLE(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.COMM_FAILURE(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.DATA_CONVERSION(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.FREE_MEM(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.IMP_LIMIT(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.INITIALIZE(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.INTERNAL(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.INTF_REPOS(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.INVALID_TRANSACTION(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.INV_FLAG(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.INV_IDENT(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.INV_OBJREF(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.INV_POLICY(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.MARSHAL(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.NO_IMPLEMENT(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.NO_MEMORY(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.NO_PERMISSION(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.NO_RESOURCES(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.NO_RESPONSE(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.OBJECT_NOT_EXIST(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.OBJ_ADAPTER(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.PERSIST_STORE(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.REBIND(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.TIMEOUT(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.TRANSACTION_MODE(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.TRANSACTION_REQUIRED(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.TRANSACTION_ROLLEDBACK(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.TRANSACTION_UNAVAILABLE(minorstatus);
            break;
        case :
            ex = new org.omg.CORBA.TRANSIENT(minorstatus);
            break;
        case :
        default:
            ex = new org.omg.CORBA.UNKNOWN(minorstatus);
        }
        return ex;
    }
    //CHECKSTYLE:ON
    
    
    
    public void _read(InputStream instream) {
         = read(instream);
    }
    
    public TypeCode _type() {
        if ( == null) {
            ORB orb = ORB.init();
            StructMember[] smBuf = new StructMember[2];
            TypeCode minortc = orb.get_primitive_tc(.);
            smBuf[0] = new StructMember("minor"minortcnull);
            String csLabels[] = {"COMPLETED_YES""COMPLETED_NO""COMPLETED_MAYBE"};
            TypeCode completedtc = orb
                .create_enum_tc("IDL:omg.org/CORBA/CompletionStatus:1.0",
                              "CompletionStatus"csLabels);
            smBuf[1] = new StructMember("completed"completedtcnull);
            String id;
            String name;
            if ( == null) {
                name = "SystemException";
                id = "IDL:omg.org/CORBA/SystemException:1.0";
            } else {
                String className = .getClass().getName();
                name = className.substring(className.lastIndexOf('.') + 1);
                id = "IDL:omg.org/CORBA/" + name + ":1.0";
            }
            
             = orb.create_exception_tc(idnamesmBuf);
        }
        return ;
    }
    public void _write(OutputStream outstream) {
        String id;
        if ( == null) {
             = new org.omg.CORBA.UNKNOWN();
            id = "IDL:omg.org/CORBA/UNKNOWN";
        } else {
            String className = .getClass().getName();
            id = "IDL:omg.org/CORBA/" 
                + className.substring(className.lastIndexOf('.') + 1) + ":1.0";
        }
        outstream.write_string(id);
        outstream.write_ulong(.);
        outstream.write_ulong(..value());
    }
New to GrepCode? Check out our FAQ X