Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.HashMap;

public class Main {
    private static HashMap<String, Long> unoTypes = new HashMap<String, Long>();

    public static long NonSearchingJavaToUnoType(Object obj, boolean errorIfMissing) throws Throwable {
        Class<?> firstCls = obj.getClass();
        String clsName = firstCls.getName();
        Long unoTypePtr = unoTypes.get(clsName);
        if (unoTypePtr == null) {
            if (errorIfMissing) {
                String msg = "NonSearchingJavaToUnoType: Could not find uno type for " + clsName;
                throw new Exception(msg);
            } else {
                return 0L;
            }
        }
        return (long) unoTypePtr;
    }

    public static long NonSearchingJavaToUnoType(Class<?> cls, boolean errorIfMissing) throws Throwable {
        String clsName = cls.getName();
        Long unoTypePtr = unoTypes.get(clsName);
        if (unoTypePtr == null) {
            if (errorIfMissing) {
                String msg = "NonSearchingJavaToUnoType: Could not find uno type for " + clsName;
                throw new Exception(msg);
            } else {
                return 0L;
            }
        }
        return (long) unoTypePtr;
    }
}