Proto.java :  » Tools » dex2jar » pxb » android » dex2jar » Android Open Source

Android Open Source » Tools » dex2jar 
dex2jar » pxb » android » dex2jar » Proto.java
/*
 * Copyright (c) 2009-2010 Panxiaobo
 * 
 * Licensed 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 pxb.android.dex2jar;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * 
 * @author Panxiaobo [pxb1988@126.com]
 * @version $Id$
 */
public class Proto {
    /**
     * 
     */
    private String desc;
    /**
     * 
     */
    private String[] parameterTypes;
    /**
     * 
     */
    private String returnType;

    public Proto(Dex dex, DataIn in) {
        // int shorty_idx =
        in.readIntx();
        int return_type_idx = in.readIntx();
        int parameters_off = in.readIntx();

        returnType = dex.getType(return_type_idx);
        List<String> parameterTypeList = new ArrayList<String>();
        StringBuilder ps = new StringBuilder("(");
        if (parameters_off != 0) {
            in.pushMove(parameters_off);
            int size = in.readIntx();
            for (int i = 0; i < size; i++) {
                String p = dex.getType(in.readShortx());
                parameterTypeList.add(p);
                ps.append(p);
            }
            in.pop();
        }
        ps.append(")").append(returnType);
        desc = ps.toString();
        parameterTypes = parameterTypeList.toArray(new String[parameterTypeList.size()]);
    }

    public String getDesc() {
        return desc;
    }

    /**
     * @return the parameterTypes
     */
    public String[] getParameterTypes() {
        return parameterTypes;
    }

    public String getReturnType() {
        return returnType;
    }

    public String toString() {
        return desc;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.