Example usage for java.util Locale JAPAN

List of usage examples for java.util Locale JAPAN

Introduction

In this page you can find the example usage for java.util Locale JAPAN.

Prototype

Locale JAPAN

To view the source code for java.util Locale JAPAN.

Click Source Link

Document

Useful constant for country.

Usage

From source file:net.e_fas.oss.tabijiman.MapsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    e_print("onCreate");

    // ActionBar?
    if (savedInstanceState == null) {
        // customActionBar??
        View customActionBarView = this.getActionBarView();

        // ActionBar??
        ActionBar actionBar = this.getSupportActionBar();

        // ?????('<' <- ???)
        if (actionBar != null) {

            // ???????
            actionBar.setDisplayShowTitleEnabled(false);

            // icon???????
            actionBar.setDisplayShowHomeEnabled(false);

            // ActionBar?customView?
            actionBar.setCustomView(customActionBarView);

            // CutomView??
            actionBar.setDisplayShowCustomEnabled(true);
        }/*from w w  w  . ja v a  2  s  . co m*/
    }

    // ?????
    Locale locale = Locale.getDefault();
    if (locale.equals(Locale.JAPAN) || locale.equals(Locale.JAPANESE)) {
        locale = Locale.JAPAN;
    } else {
        locale = Locale.ENGLISH;
    }

    // ??
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    // Resources??
    config.locale = locale;
    Resources resources = getBaseContext().getResources();
    // Resources??????
    resources.updateConfiguration(config, null);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    try {
        new CreateInitData(this).exec(locale);
        new SPARQL().query(AppSetting.query_place, "place");
        new SPARQL().query(AppSetting.query_frame, "frame");
    } catch (IOException | JSONException e) {
        e.printStackTrace();
    }

    makeTempDir();

    // ???
    ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    if (networkInfo == null) {
        Toast.makeText(getApplicationContext(),
                "???????????",
                Toast.LENGTH_LONG).show();
    }

    buttons = new ArrayList<>();

    View.OnClickListener change_button = new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            CameraPosition cameraPos;

            if (v == TrainButton) {

                zoomLevel = 9.0f;

                cameraPos = new CameraPosition.Builder()
                        .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel)
                        .bearing(0).build();
            } else if (v == CarButton) {

                zoomLevel = 11.0f;

                cameraPos = new CameraPosition.Builder()
                        .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel)
                        .bearing(0).build();
            } else {

                zoomLevel = 14.0f;

                cameraPos = new CameraPosition.Builder()
                        .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel)
                        .bearing(0).build();
            }

            if (!v.isActivated()) {

                v.setActivated(true);

                for (int i = 0; i < buttons.size(); i++) {

                    if (buttons.get(i) != v) {
                        buttons.get(i).setActivated(false);
                    }
                }
            }

            mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos));
        }
    };

    View.OnClickListener marker_change_button = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!v.isActivated()) {

                v.setActivated(true);
                if (v == FrameSwitch) {

                    setMarker("frame");

                    FrameMarkerOptions.clear();
                } else {

                    setMarker("place");

                    PlaceMarkerOptions.clear();
                }
            } else {

                v.setActivated(false);
                if (v == FrameSwitch) {

                    for (Marker m : FrameMarker) {
                        m.remove();
                    }

                    FrameMarker.clear();
                } else {
                    for (Marker m : PlaceMarker) {
                        m.remove();
                    }

                    PlaceMarker.clear();
                }
            }
        }
    };

    // LocationManager?
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    TakePicture = (ImageButton) findViewById(R.id.takePicture);
    TakePicture.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent TakePictureView = new Intent(getApplicationContext(), TakePicture.class);
            startActivity(TakePictureView);
        }
    });

    TrainButton = (ImageButton) findViewById(R.id.Train);
    TrainButton.setActivated(false);
    TrainButton.setOnClickListener(change_button);

    CarButton = (ImageButton) findViewById(R.id.Car);
    CarButton.setActivated(true);
    CarButton.setOnClickListener(change_button);

    WalkButton = (ImageButton) findViewById(R.id.Walk);
    WalkButton.setActivated(false);
    WalkButton.setOnClickListener(change_button);

    buttons = Arrays.asList(TrainButton, CarButton, WalkButton);

    FrameSwitch = (ImageButton) findViewById(R.id.showFrame);
    FrameSwitch.setActivated(true);
    FrameSwitch.setOnClickListener(marker_change_button);

    PlaceSwitch = (ImageButton) findViewById(R.id.showPlace);
    PlaceSwitch.setActivated(true);
    PlaceSwitch.setOnClickListener(marker_change_button);

    GoFukuiButton = (ImageButton) findViewById(R.id.GoFukuiButton);

    //        new AppSetting(this);
    //        AppSetting.context = getApplicationContext();
    AppSetting.Inc_CountRun();
    e_print("Run_Count >> " + AppSetting.CountRun());

    if (AppSetting.CountRun() % 20 == 0) {
        GoFukuiButton.setVisibility(View.VISIBLE);
    }

    FrameCollectionButton = (ImageButton) findViewById(R.id.frameCollection);
    FrameCollectionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent collection = new Intent(getApplicationContext(), FrameCollection.class);
            startActivity(collection);
        }
    });

    mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    //        mapFragment.getMap();

    helper = new SQLiteHelper(this);
    db = helper.getWritableDatabase();

}

From source file:hk.idv.kenson.jrconsole.Console.java

/**
 * /*from  ww w . j a va 2s. co m*/
 * @param localeString
 * @return
 */
private static Locale getLocale(String localeString) {
    if ("default".equals(localeString))
        return Locale.getDefault();
    if ("canada".equals(localeString))
        return Locale.CANADA;
    if ("canada_french".equals(localeString))
        return Locale.CANADA_FRENCH;
    if ("china".equals(localeString))
        return Locale.CHINA;
    if ("chinese".equals(localeString))
        return Locale.CHINESE;
    if ("english".equals(localeString))
        return Locale.ENGLISH;
    if ("franch".equals(localeString))
        return Locale.FRANCE;
    if ("german".equals(localeString))
        return Locale.GERMAN;
    if ("germany".equals(localeString))
        return Locale.GERMANY;
    if ("italian".equals(localeString))
        return Locale.ITALIAN;
    if ("italy".equals(localeString))
        return Locale.ITALY;
    if ("japan".equals(localeString))
        return Locale.JAPAN;
    if ("japanese".equals(localeString))
        return Locale.JAPANESE;
    if ("korea".equals(localeString))
        return Locale.KOREA;
    if ("korean".equals(localeString))
        return Locale.KOREAN;
    if ("prc".equals(localeString))
        return Locale.PRC;
    if ("simplified_chinese".equals(localeString))
        return Locale.SIMPLIFIED_CHINESE;
    if ("taiwan".equals(localeString))
        return Locale.TAIWAN;
    if ("traditional_chinese".equals(localeString))
        return Locale.TRADITIONAL_CHINESE;
    if ("uk".equals(localeString))
        return Locale.UK;
    if ("us".equals(localeString))
        return Locale.US;

    String parts[] = localeString.split("_", -1);
    if (parts.length == 1)
        return new Locale(parts[0]);
    else if (parts.length == 2)
        return new Locale(parts[0], parts[1]);
    else
        return new Locale(parts[0], parts[1], parts[2]);
}

From source file:com.hybris.backoffice.cockpitng.dataaccess.facades.DefaultPlatformPermissionFacadeStrategyTest.java

@Test
public void testGetReadableLocalesForInstanceAsAdmin() {
    final Set<Locale> locales = new HashSet<Locale>();
    locales.add(Locale.ENGLISH);//from  w  w w  . j  a  v  a  2s .  c  o m
    locales.add(Locale.GERMAN);
    locales.add(Locale.JAPAN);

    final DefaultPlatformPermissionFacadeStrategy permissionFacade = new DefaultPlatformPermissionFacadeStrategy() {
        @Override
        public Set<Locale> getAllReadableLocalesForCurrentUser() {
            return locales;
        }

        @Override
        public Set<Locale> getAllWritableLocalesForCurrentUser() {
            return locales;
        }
    };

    permissionFacade.setCatalogTypeService(catalogTypeService);
    permissionFacade.setCommonI18NService(commonI18NService);
    permissionFacade.setUserService(userService);

    Mockito.when(userService.isAdmin(user)).thenReturn(true);

    LanguageModel german = new LanguageModel();
    german.setIsocode(GERMAN_ISO_CODE);
    catalog.setLanguages(Collections.singletonList(german));

    final Set<Locale> readableLocalesForInstance = permissionFacade.getReadableLocalesForInstance(product);

    //Even though catalog is restricted for geramn language only - in case of admin, facade returns all readable languages of the admin user - all defined. In this test - English
    Assert.assertTrue(readableLocalesForInstance.containsAll(locales));
}

From source file:jp.ne.sakura.kkkon.android.exceptionhandler.testapp.ExceptionHandlerReportApp.java

/** Called when the activity is first created. */
@Override//w w  w .ja v a 2 s .  c  o  m
public void onCreate(Bundle savedInstanceState) {
    final Context context = this.getApplicationContext();

    {
        ExceptionHandler.initialize(context);
        if (ExceptionHandler.needReport()) {
            final String fileName = ExceptionHandler.getBugReportFileAbsolutePath();
            final File file = new File(fileName);
            final File fileZip;
            {
                String strFileZip = file.getAbsolutePath();
                {
                    int index = strFileZip.lastIndexOf('.');
                    if (0 < index) {
                        strFileZip = strFileZip.substring(0, index);
                        strFileZip += ".zip";
                    }
                }
                Log.d(TAG, strFileZip);
                fileZip = new File(strFileZip);
                if (fileZip.exists()) {
                    fileZip.delete();
                }
            }
            if (file.exists()) {
                Log.d(TAG, file.getAbsolutePath());
                InputStream inStream = null;
                ZipOutputStream outStream = null;
                try {
                    inStream = new FileInputStream(file);
                    String strFileName = file.getAbsolutePath();
                    {
                        int index = strFileName.lastIndexOf(File.separatorChar);
                        if (0 < index) {
                            strFileName = strFileName.substring(index + 1);
                        }
                    }
                    Log.d(TAG, strFileName);

                    outStream = new ZipOutputStream(new FileOutputStream(fileZip));
                    byte[] buff = new byte[8124];
                    {
                        ZipEntry entry = new ZipEntry(strFileName);
                        outStream.putNextEntry(entry);

                        int len = 0;
                        while (0 < (len = inStream.read(buff))) {
                            outStream.write(buff, 0, len);
                        }
                        outStream.closeEntry();
                    }
                    outStream.finish();
                    outStream.flush();

                } catch (IOException e) {
                    Log.e(TAG, "got exception", e);
                } finally {
                    if (null != outStream) {
                        try {
                            outStream.close();
                        } catch (Exception e) {
                        }
                    }
                    outStream = null;

                    if (null != inStream) {
                        try {
                            inStream.close();
                        } catch (Exception e) {
                        }
                    }
                    inStream = null;
                }
                Log.i(TAG, "zip created");
            }

            if (file.exists()) {
                // upload or send e-mail
                InputStream inStream = null;
                StringBuilder sb = new StringBuilder();
                try {
                    inStream = new FileInputStream(file);
                    byte[] buff = new byte[8124];
                    int readed = 0;
                    do {
                        readed = inStream.read(buff);
                        for (int i = 0; i < readed; i++) {
                            sb.append((char) buff[i]);
                        }
                    } while (readed >= 0);

                    final String str = sb.toString();
                    Log.i(TAG, str);
                } catch (IOException e) {
                    Log.e(TAG, "got exception", e);
                } finally {
                    if (null != inStream) {
                        try {
                            inStream.close();
                        } catch (Exception e) {
                        }
                    }
                    inStream = null;
                }

                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                final Locale defaultLocale = Locale.getDefault();

                String title = "";
                String message = "";
                String positive = "";
                String negative = "";

                boolean needDefaultLang = true;
                if (null != defaultLocale) {
                    if (defaultLocale.equals(Locale.JAPANESE) || defaultLocale.equals(Locale.JAPAN)) {
                        title = "";
                        message = "?????????";
                        positive = "?";
                        negative = "";
                        needDefaultLang = false;
                    }
                }
                if (needDefaultLang) {
                    title = "ERROR";
                    message = "Got unexpected error. Do you want to send information of error.";
                    positive = "Send";
                    negative = "Cancel";
                }
                alertDialog.setTitle(title);
                alertDialog.setMessage(message);
                alertDialog.setPositiveButton(positive + " mail", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface di, int i) {
                        DefaultUploaderMailClient.upload(context, file,
                                new String[] { "diverKon+sakura@gmail.com" });
                    }
                });
                alertDialog.setNeutralButton(positive + " http", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface di, int i) {
                        DefaultUploaderWeb.upload(ExceptionHandlerReportApp.this, fileZip,
                                "http://kkkon.sakura.ne.jp/android/bug");
                    }
                });
                alertDialog.setNegativeButton(negative, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface di, int i) {
                        ExceptionHandler.clearReport();
                    }
                });
                alertDialog.show();
            }
            // TODO separate activity for crash report
            //DefaultCheckerAPK.checkAPK( this, null );
        }
        ExceptionHandler.registHandler();
    }

    super.onCreate(savedInstanceState);

    /* Create a TextView and set its content.
     * the text is retrieved by calling a native
     * function.
     */
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);

    TextView tv = new TextView(this);
    tv.setText("ExceptionHandler");
    layout.addView(tv);

    Button btn1 = new Button(this);
    btn1.setText("invoke Exception");
    btn1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final int count = 2;
            int[] array = new int[count];
            int value = array[count]; // invoke IndexOutOfBOundsException
        }
    });
    layout.addView(btn1);

    Button btn2 = new Button(this);
    btn2.setText("reinstall apk");
    btn2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            boolean foundApk = false;
            {
                final String apkPath = context.getPackageCodePath(); // API8
                Log.d(TAG, "PackageCodePath: " + apkPath);
                final File fileApk = new File(apkPath);
                if (fileApk.exists()) {
                    foundApk = true;

                    Intent promptInstall = new Intent(Intent.ACTION_VIEW);
                    promptInstall.setDataAndType(Uri.fromFile(fileApk),
                            "application/vnd.android.package-archive");
                    promptInstall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(promptInstall);
                }
            }

            if (false == foundApk) {
                for (int i = 0; i < 10; ++i) {
                    File fileApk = new File("/data/app/" + context.getPackageName() + "-" + i + ".apk");
                    Log.d(TAG, "check apk:" + fileApk.getAbsolutePath());
                    if (fileApk.exists()) {
                        Log.i(TAG, "apk found. path=" + fileApk.getAbsolutePath());
                        /*
                         * // require parmission
                        {
                        final String strCmd = "pm install -r " + fileApk.getAbsolutePath();
                        try
                        {
                            Runtime.getRuntime().exec( strCmd );
                        }
                        catch ( IOException e )
                        {
                            Log.e( TAG, "got exception", e );
                        }
                        }
                        */
                        Intent promptInstall = new Intent(Intent.ACTION_VIEW);
                        promptInstall.setDataAndType(Uri.fromFile(fileApk),
                                "application/vnd.android.package-archive");
                        promptInstall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        context.startActivity(promptInstall);
                        break;
                    }
                }
            }
        }
    });
    layout.addView(btn2);

    Button btn3 = new Button(this);
    btn3.setText("check apk");
    btn3.setOnClickListener(new View.OnClickListener() {
        private boolean checkApk(final File fileApk, final ZipEntryFilter filter) {
            final boolean[] result = new boolean[1];
            result[0] = true;

            final Thread thread = new Thread(new Runnable() {

                @Override
                public void run() {
                    if (fileApk.exists()) {
                        ZipFile zipFile = null;
                        try {
                            zipFile = new ZipFile(fileApk);
                            List<ZipEntry> list = new ArrayList<ZipEntry>(zipFile.size());
                            for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements();) {
                                ZipEntry ent = e.nextElement();
                                Log.d(TAG, ent.getName());
                                Log.d(TAG, "" + ent.getSize());
                                final boolean accept = filter.accept(ent);
                                if (accept) {
                                    list.add(ent);
                                }
                            }

                            Log.d(TAG, Build.CPU_ABI); // API 4
                            Log.d(TAG, Build.CPU_ABI2); // API 8

                            final String[] abiArray = { Build.CPU_ABI // API 4
                                    , Build.CPU_ABI2 // API 8
                            };

                            String abiMatched = null;
                            {
                                boolean foundMatched = false;
                                for (final String abi : abiArray) {
                                    if (null == abi) {
                                        continue;
                                    }
                                    if (0 == abi.length()) {
                                        continue;
                                    }

                                    for (final ZipEntry entry : list) {
                                        Log.d(TAG, entry.getName());

                                        final String prefixABI = "lib/" + abi + "/";
                                        if (entry.getName().startsWith(prefixABI)) {
                                            abiMatched = abi;
                                            foundMatched = true;
                                            break;
                                        }
                                    }

                                    if (foundMatched) {
                                        break;
                                    }
                                }
                            }
                            Log.d(TAG, "matchedAbi=" + abiMatched);

                            if (null != abiMatched) {
                                boolean needReInstall = false;

                                for (final ZipEntry entry : list) {
                                    Log.d(TAG, entry.getName());

                                    final String prefixABI = "lib/" + abiMatched + "/";
                                    if (entry.getName().startsWith(prefixABI)) {
                                        final String jniName = entry.getName().substring(prefixABI.length());
                                        Log.d(TAG, "jni=" + jniName);

                                        final String strFileDst = context.getApplicationInfo().nativeLibraryDir
                                                + "/" + jniName;
                                        Log.d(TAG, strFileDst);
                                        final File fileDst = new File(strFileDst);
                                        if (!fileDst.exists()) {
                                            Log.w(TAG, "needReInstall: content missing " + strFileDst);
                                            needReInstall = true;
                                        } else {
                                            assert (entry.getSize() <= Integer.MAX_VALUE);
                                            if (fileDst.length() != entry.getSize()) {
                                                Log.w(TAG, "needReInstall: size broken " + strFileDst);
                                                needReInstall = true;
                                            } else {
                                                //org.apache.commons.io.IOUtils.contentEquals( zipFile.getInputStream( entry ), new FileInputStream(fileDst) );

                                                final int size = (int) entry.getSize();
                                                byte[] buffSrc = new byte[size];

                                                {
                                                    InputStream inStream = null;
                                                    try {
                                                        inStream = zipFile.getInputStream(entry);
                                                        int pos = 0;
                                                        {
                                                            while (pos < size) {
                                                                final int ret = inStream.read(buffSrc, pos,
                                                                        size - pos);
                                                                if (ret <= 0) {
                                                                    break;
                                                                }
                                                                pos += ret;
                                                            }
                                                        }
                                                    } catch (IOException e) {
                                                        Log.d(TAG, "got exception", e);
                                                    } finally {
                                                        if (null != inStream) {
                                                            try {
                                                                inStream.close();
                                                            } catch (Exception e) {
                                                            }
                                                        }
                                                    }
                                                }
                                                byte[] buffDst = new byte[(int) fileDst.length()];
                                                {
                                                    InputStream inStream = null;
                                                    try {
                                                        inStream = new FileInputStream(fileDst);
                                                        int pos = 0;
                                                        {
                                                            while (pos < size) {
                                                                final int ret = inStream.read(buffDst, pos,
                                                                        size - pos);
                                                                if (ret <= 0) {
                                                                    break;
                                                                }
                                                                pos += ret;
                                                            }
                                                        }
                                                    } catch (IOException e) {
                                                        Log.d(TAG, "got exception", e);
                                                    } finally {
                                                        if (null != inStream) {
                                                            try {
                                                                inStream.close();
                                                            } catch (Exception e) {
                                                            }
                                                        }
                                                    }
                                                }

                                                if (Arrays.equals(buffSrc, buffDst)) {
                                                    Log.d(TAG, " content equal " + strFileDst);
                                                    // OK
                                                } else {
                                                    Log.w(TAG, "needReInstall: content broken " + strFileDst);
                                                    needReInstall = true;
                                                }
                                            }

                                        }

                                    }
                                } // for ZipEntry

                                if (needReInstall) {
                                    // need call INSTALL APK
                                    Log.w(TAG, "needReInstall apk");
                                    result[0] = false;
                                } else {
                                    Log.d(TAG, "no need ReInstall apk");
                                }
                            }

                        } catch (IOException e) {
                            Log.d(TAG, "got exception", e);
                        } finally {
                            if (null != zipFile) {
                                try {
                                    zipFile.close();
                                } catch (Exception e) {
                                }
                            }
                        }
                    }
                }

            });
            thread.setName("check jni so");

            thread.start();
            /*
            while ( thread.isAlive() )
            {
            Log.d( TAG, "check thread.id=" + android.os.Process.myTid() + ",state=" + thread.getState() );
            if ( ! thread.isAlive() )
            {
                break;
            }
            AlertDialog.Builder alertDialog = new AlertDialog.Builder( ExceptionHandlerTestApp.this );
            final Locale defaultLocale = Locale.getDefault();
                    
            String title = "";
            String message = "";
            String positive = "";
            String negative = "";
                    
            boolean needDefaultLang = true;
            if ( null != defaultLocale )
            {
                if ( defaultLocale.equals( Locale.JAPANESE ) || defaultLocale.equals( Locale.JAPAN ) )
                {
                    title = "";
                    message = "???????";
                    positive = "?";
                    negative = "";
                    needDefaultLang = false;
                }
            }
            if ( needDefaultLang )
            {
                title = "INFO";
                message = "Now checking installation. Cancel check?";
                positive = "Wait";
                negative = "Cancel";
            }
            alertDialog.setTitle( title );
            alertDialog.setMessage( message );
            alertDialog.setPositiveButton( positive, null);
            alertDialog.setNegativeButton( negative, new DialogInterface.OnClickListener() {
                    
                @Override
                public void onClick(DialogInterface di, int i) {
                    if ( thread.isAlive() )
                    {
                        Log.d( TAG, "request interrupt" );
                        thread.interrupt();
                    }
                    else
                    {
                        // nothing
                    }
                }
            } );
                    
            if ( ! thread.isAlive() )
            {
                break;
            }
                    
            alertDialog.show();
                    
            if ( ! Thread.State.RUNNABLE.equals(thread.getState()) )
            {
                break;
            }
                    
            }
            */

            try {
                thread.join();
            } catch (InterruptedException e) {
                Log.d(TAG, "got exception", e);
            }

            return result[0];
        }

        @Override
        public void onClick(View view) {
            boolean foundApk = false;
            {
                final String apkPath = context.getPackageCodePath(); // API8
                Log.d(TAG, "PackageCodePath: " + apkPath);
                final File fileApk = new File(apkPath);
                this.checkApk(fileApk, new ZipEntryFilter() {
                    @Override
                    public boolean accept(ZipEntry entry) {
                        if (entry.isDirectory()) {
                            return false;
                        }

                        final String filename = entry.getName();
                        if (filename.startsWith("lib/")) {
                            return true;
                        }

                        return false;
                    }
                });
            }

        }
    });
    layout.addView(btn3);

    Button btn4 = new Button(this);
    btn4.setText("print dir and path");
    btn4.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            {
                final File file = context.getCacheDir();
                Log.d(TAG, "Ctx.CacheDir=" + file.getAbsoluteFile());
            }
            {
                final File file = context.getExternalCacheDir(); // API 8
                if (null == file) {
                    // no permission
                    Log.d(TAG, "Ctx.ExternalCacheDir=");
                } else {
                    Log.d(TAG, "Ctx.ExternalCacheDir=" + file.getAbsolutePath());
                }
            }
            {
                final File file = context.getFilesDir();
                Log.d(TAG, "Ctx.FilesDir=" + file.getAbsolutePath());
            }
            {
                final String value = context.getPackageResourcePath();
                Log.d(TAG, "Ctx.PackageResourcePath=" + value);
            }
            {
                final String[] files = context.fileList();
                if (null == files) {
                    Log.d(TAG, "Ctx.fileList=" + files);
                } else {
                    for (final String filename : files) {
                        Log.d(TAG, "Ctx.fileList=" + filename);
                    }
                }
            }

            {
                final File file = Environment.getDataDirectory();
                Log.d(TAG, "Env.DataDirectory=" + file.getAbsolutePath());
            }
            {
                final File file = Environment.getDownloadCacheDirectory();
                Log.d(TAG, "Env.DownloadCacheDirectory=" + file.getAbsolutePath());
            }
            {
                final File file = Environment.getExternalStorageDirectory();
                Log.d(TAG, "Env.ExternalStorageDirectory=" + file.getAbsolutePath());
            }
            {
                final File file = Environment.getRootDirectory();
                Log.d(TAG, "Env.RootDirectory=" + file.getAbsolutePath());
            }
            {
                final ApplicationInfo appInfo = context.getApplicationInfo();
                Log.d(TAG, "AppInfo.dataDir=" + appInfo.dataDir);
                Log.d(TAG, "AppInfo.nativeLibraryDir=" + appInfo.nativeLibraryDir); // API 9
                Log.d(TAG, "AppInfo.publicSourceDir=" + appInfo.publicSourceDir);
                {
                    final String[] sharedLibraryFiles = appInfo.sharedLibraryFiles;
                    if (null == sharedLibraryFiles) {
                        Log.d(TAG, "AppInfo.sharedLibraryFiles=" + sharedLibraryFiles);
                    } else {
                        for (final String fileName : sharedLibraryFiles) {
                            Log.d(TAG, "AppInfo.sharedLibraryFiles=" + fileName);
                        }
                    }
                }
                Log.d(TAG, "AppInfo.sourceDir=" + appInfo.sourceDir);
            }
            {
                Log.d(TAG, "System.Properties start");
                final Properties properties = System.getProperties();
                if (null != properties) {
                    for (final Object key : properties.keySet()) {
                        String value = properties.getProperty((String) key);
                        Log.d(TAG, " key=" + key + ",value=" + value);
                    }
                }
                Log.d(TAG, "System.Properties end");
            }
            {
                Log.d(TAG, "System.getenv start");
                final Map<String, String> mapEnv = System.getenv();
                if (null != mapEnv) {
                    for (final Map.Entry<String, String> entry : mapEnv.entrySet()) {
                        final String key = entry.getKey();
                        final String value = entry.getValue();
                        Log.d(TAG, " key=" + key + ",value=" + value);
                    }
                }
                Log.d(TAG, "System.getenv end");
            }
        }
    });
    layout.addView(btn4);

    Button btn5 = new Button(this);
    btn5.setText("check INSTALL_NON_MARKET_APPS");
    btn5.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            SettingsCompat.initialize(context);
            if (SettingsCompat.isAllowedNonMarketApps()) {
                Log.d(TAG, "isAllowdNonMarketApps=true");
            } else {
                Log.d(TAG, "isAllowdNonMarketApps=false");
            }
        }
    });
    layout.addView(btn5);

    Button btn6 = new Button(this);
    btn6.setText("send email");
    btn6.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent mailto = new Intent();
            mailto.setAction(Intent.ACTION_SENDTO);
            mailto.setType("message/rfc822");
            mailto.setData(Uri.parse("mailto:"));
            mailto.putExtra(Intent.EXTRA_EMAIL, new String[] { "" });
            mailto.putExtra(Intent.EXTRA_SUBJECT, "[BugReport] " + context.getPackageName());
            mailto.putExtra(Intent.EXTRA_TEXT, "body text");
            //mailto.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
            //context.startActivity( mailto );
            Intent intent = Intent.createChooser(mailto, "Send Email");
            if (null != intent) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                try {
                    context.startActivity(intent);
                } catch (android.content.ActivityNotFoundException e) {
                    Log.d(TAG, "got Exception", e);
                }
            }
        }
    });
    layout.addView(btn6);

    Button btn7 = new Button(this);
    btn7.setText("upload http thread");
    btn7.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Log.d(TAG, "brd=" + Build.BRAND);
            Log.d(TAG, "prd=" + Build.PRODUCT);

            //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS)
            Log.d(TAG, "fng=" + Build.FINGERPRINT);
            final List<NameValuePair> list = new ArrayList<NameValuePair>(16);
            list.add(new BasicNameValuePair("fng", Build.FINGERPRINT));

            final Thread thread = new Thread(new Runnable() {

                @Override
                public void run() {
                    Log.d(TAG, "upload thread tid=" + android.os.Process.myTid());
                    try {
                        HttpPost httpPost = new HttpPost("http://kkkon.sakura.ne.jp/android/bug");
                        //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) );
                        httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8));
                        DefaultHttpClient httpClient = new DefaultHttpClient();
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
                                new Integer(5 * 1000));
                        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                                new Integer(5 * 1000));
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        // <uses-permission android:name="android.permission.INTERNET"/>
                        // got android.os.NetworkOnMainThreadException, run at UI Main Thread
                        HttpResponse response = httpClient.execute(httpPost);
                        Log.d(TAG, "response=" + response.getStatusLine().getStatusCode());
                    } catch (Exception e) {
                        Log.d(TAG, "got Exception. msg=" + e.getMessage(), e);
                    }
                    Log.d(TAG, "upload finish");
                }
            });
            thread.setName("upload crash");

            thread.start();
            /*
            while ( thread.isAlive() )
            {
            Log.d( TAG, "thread tid=" + android.os.Process.myTid() + ",state=" + thread.getState() );
            if ( ! thread.isAlive() )
            {
                break;
            }
            AlertDialog.Builder alertDialog = new AlertDialog.Builder( ExceptionHandlerTestApp.this );
            final Locale defaultLocale = Locale.getDefault();
                    
            String title = "";
            String message = "";
            String positive = "";
            String negative = "";
                    
            boolean needDefaultLang = true;
            if ( null != defaultLocale )
            {
                if ( defaultLocale.equals( Locale.JAPANESE ) || defaultLocale.equals( Locale.JAPAN ) )
                {
                    title = "";
                    message = "???????";
                    positive = "?";
                    negative = "";
                    needDefaultLang = false;
                }
            }
            if ( needDefaultLang )
            {
                title = "INFO";
                message = "Now uploading error information. Cancel upload?";
                positive = "Wait";
                negative = "Cancel";
            }
            alertDialog.setTitle( title );
            alertDialog.setMessage( message );
            alertDialog.setPositiveButton( positive, null);
            alertDialog.setNegativeButton( negative, new DialogInterface.OnClickListener() {
                    
                @Override
                public void onClick(DialogInterface di, int i) {
                    if ( thread.isAlive() )
                    {
                        Log.d( TAG, "request interrupt" );
                        thread.interrupt();
                    }
                    else
                    {
                        // nothing
                    }
                }
            } );
                    
            if ( ! thread.isAlive() )
            {
                break;
            }
                    
            alertDialog.show();
                    
            if ( ! Thread.State.RUNNABLE.equals(thread.getState()) )
            {
                break;
            }
                    
            }
            */

            /*
            try
            {
            thread.join(); // must call. leak handle...
            }
            catch ( InterruptedException e )
            {
            Log.d( TAG, "got Exception", e );
            }
            */
        }
    });
    layout.addView(btn7);

    Button btn8 = new Button(this);
    btn8.setText("upload http AsyncTask");
    btn8.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            AsyncTask<String, Void, Boolean> asyncTask = new AsyncTask<String, Void, Boolean>() {

                @Override
                protected Boolean doInBackground(String... paramss) {
                    Boolean result = true;
                    Log.d(TAG, "upload AsyncTask tid=" + android.os.Process.myTid());
                    try {
                        //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS)
                        Log.d(TAG, "fng=" + Build.FINGERPRINT);
                        final List<NameValuePair> list = new ArrayList<NameValuePair>(16);
                        list.add(new BasicNameValuePair("fng", Build.FINGERPRINT));

                        HttpPost httpPost = new HttpPost(paramss[0]);
                        //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) );
                        httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8));
                        DefaultHttpClient httpClient = new DefaultHttpClient();
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
                                new Integer(5 * 1000));
                        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                                new Integer(5 * 1000));
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        // <uses-permission android:name="android.permission.INTERNET"/>
                        // got android.os.NetworkOnMainThreadException, run at UI Main Thread
                        HttpResponse response = httpClient.execute(httpPost);
                        Log.d(TAG, "response=" + response.getStatusLine().getStatusCode());
                    } catch (Exception e) {
                        Log.d(TAG, "got Exception. msg=" + e.getMessage(), e);
                        result = false;
                    }
                    Log.d(TAG, "upload finish");
                    return result;
                }

            };

            asyncTask.execute("http://kkkon.sakura.ne.jp/android/bug");
            asyncTask.isCancelled();
        }
    });
    layout.addView(btn8);

    Button btn9 = new Button(this);
    btn9.setText("call checkAPK");
    btn9.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final boolean result = DefaultCheckerAPK.checkAPK(ExceptionHandlerReportApp.this, null);
            Log.i(TAG, "checkAPK result=" + result);
        }
    });
    layout.addView(btn9);

    setContentView(layout);
}

From source file:net.massbank.validator.RecordValidator.java

/**
 * ??/*from w ww  . jav  a 2s  . c  o  m*/
 * 
 * @param db
 *            DB
 * @param op
 *            PrintWriter?
 * @param dataPath
 *            ?
 * @param registPath
 *            
 * @param ver
 *            ?
 * @return ??Map<??, ?>
 * @throws IOException
 *             
 */
private static TreeMap<String, String> validationRecord(DatabaseAccess dbx, PrintStream op, String dataPath,
        String registPath, int ver) throws IOException {

    if (ver == 1) {
        op.println(msgInfo("check record format version is [version 1]."));
    }

    final String[] dataList = (new File(dataPath)).list();
    TreeMap<String, String> validationMap = new TreeMap<String, String>();

    if (dataList.length == 0) {
        op.println(msgWarn("no file for validation."));
        return validationMap;
    }

    // ----------------------------------------------------
    // ???
    // ----------------------------------------------------
    String[] requiredList = new String[] { // Ver.2
            "ACCESSION: ", "RECORD_TITLE: ", "DATE: ", "AUTHORS: ", "LICENSE: ", "CH$NAME: ",
            "CH$COMPOUND_CLASS: ", "CH$FORMULA: ", "CH$EXACT_MASS: ", "CH$SMILES: ", "CH$IUPAC: ",
            "AC$INSTRUMENT: ", "AC$INSTRUMENT_TYPE: ", "AC$MASS_SPECTROMETRY: MS_TYPE ",
            "AC$MASS_SPECTROMETRY: ION_MODE ", "PK$NUM_PEAK: ", "PK$PEAK: " };
    if (ver == 1) { // Ver.1
        requiredList = new String[] { "ACCESSION: ", "RECORD_TITLE: ", "DATE: ", "AUTHORS: ", "COPYRIGHT: ",
                "CH$NAME: ", "CH$COMPOUND_CLASS: ", "CH$FORMULA: ", "CH$EXACT_MASS: ", "CH$SMILES: ",
                "CH$IUPAC: ", "AC$INSTRUMENT: ", "AC$INSTRUMENT_TYPE: ", "AC$ANALYTICAL_CONDITION: MODE ",
                "PK$NUM_PEAK: ", "PK$PEAK: " };
    }
    for (int i = 0; i < dataList.length; i++) {
        String name = dataList[i];
        String status = "";
        StringBuilder detailsErr = new StringBuilder();
        StringBuilder detailsWarn = new StringBuilder();

        // ????
        File file = new File(dataPath + name);
        if (file.isDirectory()) {
            // ??
            status = STATUS_ERR;
            detailsErr.append("[" + name + "] is directory.");
            validationMap.put(name, status + "\t" + detailsErr.toString());
            continue;
        } else if (file.isHidden()) {
            // ???
            status = STATUS_ERR;
            detailsErr.append("[" + name + "] is hidden.");
            validationMap.put(name, status + "\t" + detailsErr.toString());
            continue;
        } else if (name.lastIndexOf(REC_EXTENSION) == -1) {
            // ????
            status = STATUS_ERR;
            detailsErr.append("file extension of [" + name + "] is not [" + REC_EXTENSION + "].");
            validationMap.put(name, status + "\t" + detailsErr.toString());
            continue;
        }

        // ??
        boolean isEndTagRead = false;
        boolean isInvalidInfo = false;
        boolean isDoubleByte = false;
        ArrayList<String> fileContents = new ArrayList<String>();
        boolean existLicense = false; // LICENSE?Ver.1
        ArrayList<String> workChName = new ArrayList<String>(); // RECORD_TITLE??CH$NAME??Ver.1?
        String workAcInstrumentType = ""; // RECORD_TITLE??AC$INSTRUMENT_TYPE??Ver.1?
        String workAcMsType = ""; // RECORD_TITLE??AC$MASS_SPECTROMETRY:
        // MS_TYPE??Ver.2
        String line = "";
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(file));
            while ((line = br.readLine()) != null) {
                if (isEndTagRead) {
                    if (!line.equals("")) {
                        isInvalidInfo = true;
                    }
                }

                // 
                if (line.startsWith("//")) {
                    isEndTagRead = true;
                }
                fileContents.add(line);

                // LICENSE?Ver.1
                if (line.startsWith("LICENSE: ")) {
                    existLicense = true;
                }
                // CH$NAME?Ver.1?
                else if (line.startsWith("CH$NAME: ")) {
                    workChName.add(line.trim().replaceAll("CH\\$NAME: ", ""));
                }
                // AC$INSTRUMENT_TYPE?Ver.1?
                else if (line.startsWith("AC$INSTRUMENT_TYPE: ")) {
                    workAcInstrumentType = line.trim().replaceAll("AC\\$INSTRUMENT_TYPE: ", "");
                }
                // AC$MASS_SPECTROMETRY: MS_TYPE?Ver.2
                else if (ver != 1 && line.startsWith("AC$MASS_SPECTROMETRY: MS_TYPE ")) {
                    workAcMsType = line.trim().replaceAll("AC\\$MASS_SPECTROMETRY: MS_TYPE ", "");
                }

                // ?
                if (!isDoubleByte) {
                    byte[] bytes = line.getBytes("MS932");
                    if (bytes.length != line.length()) {
                        isDoubleByte = true;
                    }
                }
            }
        } catch (IOException e) {
            Logger.getLogger("global").severe("file read failed." + NEW_LINE + "    " + file.getPath());
            e.printStackTrace();
            op.println(msgErr("server error."));
            validationMap.clear();
            return validationMap;
        } finally {
            try {
                if (br != null) {
                    br.close();
                }
            } catch (IOException e) {
            }
        }
        if (isInvalidInfo) {
            // ?????
            if (status.equals(""))
                status = STATUS_WARN;
            detailsWarn.append("invalid after the end tag [//].");
        }
        if (isDoubleByte) {
            // ?????
            if (status.equals(""))
                status = STATUS_ERR;
            detailsErr.append("double-byte character included.");
        }
        if (ver == 1 && existLicense) {
            // LICENSE???Ver.1
            if (status.equals(""))
                status = STATUS_ERR;
            detailsErr.append("[LICENSE: ] tag can not be used in record format  [version 1].");
        }

        // ----------------------------------------------------
        // ????
        // ----------------------------------------------------
        boolean isNameCheck = false;
        int peakNum = -1;
        for (int j = 0; j < requiredList.length; j++) {
            String requiredStr = requiredList[j];
            ArrayList<String> valStrs = new ArrayList<String>(); // 
            boolean findRequired = false; // 
            boolean findValue = false; // 
            boolean isPeakMode = false; // 
            for (int k = 0; k < fileContents.size(); k++) {
                String lineStr = fileContents.get(k);

                // ????RELATED_RECORD??????
                if (lineStr.startsWith("//")) { // Ver.1?
                    break;
                } else if (ver == 1 && lineStr.startsWith("RELATED_RECORD:")) { // Ver.1
                    break;
                }
                // ?????
                else if (isPeakMode) {
                    findRequired = true;
                    if (!lineStr.trim().equals("")) {
                        valStrs.add(lineStr);
                    }
                }
                // ??????
                else if (lineStr.indexOf(requiredStr) != -1) {
                    // 
                    findRequired = true;
                    if (requiredStr.equals("PK$PEAK: ")) {
                        isPeakMode = true;
                        findValue = true;
                        valStrs.add(lineStr.replace(requiredStr, ""));
                    } else {
                        // 
                        String tmpVal = lineStr.replace(requiredStr, "");
                        if (!tmpVal.trim().equals("")) {
                            findValue = true;
                            valStrs.add(tmpVal);
                        }
                        break;
                    }
                }
            }
            if (!findRequired) {
                // ??????
                status = STATUS_ERR;
                detailsErr.append("no required item [" + requiredStr + "].");
            } else {
                if (!findValue) {
                    // ?????
                    status = STATUS_ERR;
                    detailsErr.append("no value of required item [" + requiredStr + "].");
                } else {
                    // ???

                    // ----------------------------------------------------
                    // ??
                    // ----------------------------------------------------
                    String val = (valStrs.size() > 0) ? valStrs.get(0) : "";
                    // ACESSIONVer.1?
                    if (requiredStr.equals("ACCESSION: ")) {
                        if (!val.equals(name.replace(REC_EXTENSION, ""))) {
                            status = STATUS_ERR;
                            detailsErr.append("value of required item [" + requiredStr
                                    + "] not correspond to file name.");
                        }
                        if (val.length() != 8) {
                            status = STATUS_ERR;
                            detailsErr.append(
                                    "value of required item [" + requiredStr + "] is 8 digits necessary.");
                        }
                    }
                    // RECORD_TITLEVer.1?
                    else if (requiredStr.equals("RECORD_TITLE: ")) {
                        if (!val.equals(DEFAULT_VALUE)) {
                            if (val.indexOf(";") != -1) {
                                String[] recTitle = val.split(";");
                                if (!workChName.contains(recTitle[0].trim())) {
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], compound name is not included in the [CH$NAME].");
                                }
                                if (!workAcInstrumentType.equals(recTitle[1].trim())) {
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], instrument type is different from [AC$INSTRUMENT_TYPE].");
                                }
                                if (ver != 1 && !workAcMsType.equals(recTitle[2].trim())) { // Ver.2
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], ms type is different from [AC$MASS_SPECTROMETRY: MS_TYPE].");
                                }
                            } else {
                                if (status.equals(""))
                                    status = STATUS_WARN;
                                detailsWarn.append("value of required item [" + requiredStr
                                        + "] is not record title format.");

                                if (!workChName.contains(val)) {
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], compound name is not included in the [CH$NAME].");
                                }
                                if (!workAcInstrumentType.equals(DEFAULT_VALUE)) {
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], instrument type is different from [AC$INSTRUMENT_TYPE].");
                                }
                                if (ver != 1 && !workAcMsType.equals(DEFAULT_VALUE)) { // Ver.2
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], ms type is different from [AC$MASS_SPECTROMETRY: MS_TYPE].");
                                }
                            }
                        } else {
                            if (!workAcInstrumentType.equals(DEFAULT_VALUE)) {
                                if (status.equals(""))
                                    status = STATUS_WARN;
                                detailsWarn.append("value of required item [" + requiredStr
                                        + "], instrument type is different from [AC$INSTRUMENT_TYPE].");
                            }
                            if (ver != 1 && !workAcMsType.equals(DEFAULT_VALUE)) { // Ver.2
                                if (status.equals(""))
                                    status = STATUS_WARN;
                                detailsWarn.append("value of required item [" + requiredStr
                                        + "], ms type is different from [AC$MASS_SPECTROMETRY: MS_TYPE].");
                            }
                        }
                    }
                    // DATEVer.1?
                    else if (requiredStr.equals("DATE: ") && !val.equals(DEFAULT_VALUE)) {
                        val = val.replace(".", "/");
                        val = val.replace("-", "/");
                        try {
                            DateFormat.getDateInstance(DateFormat.SHORT, Locale.JAPAN).parse(val);
                        } catch (ParseException e) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn
                                    .append("value of required item [" + requiredStr + "] is not date format.");
                        }
                    }
                    // CH$COMPOUND_CLASSVer.1?
                    else if (requiredStr.equals("CH$COMPOUND_CLASS: ") && !val.equals(DEFAULT_VALUE)) {
                        if (!val.startsWith("Natural Product") && !val.startsWith("Non-Natural Product")) {

                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr
                                    + "] is not compound class format.");
                        }
                    }
                    // CH$EXACT_MASSVer.1?
                    else if (requiredStr.equals("CH$EXACT_MASS: ") && !val.equals(DEFAULT_VALUE)) {
                        try {
                            Double.parseDouble(val);
                        } catch (NumberFormatException e) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr + "] is not numeric.");
                        }
                    }
                    // AC$INSTRUMENT_TYPEVer.1?
                    else if (requiredStr.equals("AC$INSTRUMENT_TYPE: ") && !val.equals(DEFAULT_VALUE)) {
                        if (val.trim().indexOf(" ") != -1) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn
                                    .append("value of required item [" + requiredStr + "] is space included.");
                        }
                        if (val.trim().indexOf(" ") != -1) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn
                                    .append("value of required item [" + requiredStr + "] is space included.");
                        }
                    }
                    // AC$MASS_SPECTROMETRY: MS_TYPEVer.2
                    else if (ver != 1 && requiredStr.equals("AC$MASS_SPECTROMETRY: MS_TYPE ")
                            && !val.equals(DEFAULT_VALUE)) {
                        boolean isMsType = true;
                        if (val.startsWith("MS")) {
                            val = val.replace("MS", "");
                            if (!val.equals("")) {
                                try {
                                    Integer.parseInt(val);
                                } catch (NumberFormatException e) {
                                    isMsType = false;
                                }
                            }
                        } else {
                            isMsType = false;
                        }
                        if (!isMsType) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr + "] is not \"MSn\".");
                        }
                    }
                    // AC$MASS_SPECTROMETRY:
                    // ION_MODEVer.2?AC$ANALYTICAL_CONDITION: MODEVer.1
                    else if ((ver != 1 && requiredStr.equals("AC$MASS_SPECTROMETRY: ION_MODE ")
                            && !val.equals(DEFAULT_VALUE))
                            || (ver == 1 && requiredStr.equals("AC$ANALYTICAL_CONDITION: MODE ")
                                    && !val.equals(DEFAULT_VALUE))) {
                        if (!val.equals("POSITIVE") && !val.equals("NEGATIVE")) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr
                                    + "] is not \"POSITIVE\" or \"NEGATIVE\".");
                        }
                    }
                    // PK$NUM_PEAKVer.1?
                    else if (requiredStr.equals("PK$NUM_PEAK: ") && !val.equals(DEFAULT_VALUE)) {
                        try {
                            peakNum = Integer.parseInt(val);
                        } catch (NumberFormatException e) {
                            status = STATUS_ERR;
                            detailsErr.append("value of required item [" + requiredStr + "] is not numeric.");
                        }
                    }
                    // PK$PEAK:Ver.1?
                    else if (requiredStr.equals("PK$PEAK: ")) {
                        if (valStrs.size() == 0 || !valStrs.get(0).startsWith("m/z int. rel.int.")) {
                            status = STATUS_ERR;
                            detailsErr.append(
                                    "value of required item [PK$PEAK: ] , the first line is not \"PK$PEAK: m/z int. rel.int.\".");
                        } else {
                            boolean isNa = false;
                            String peak = "";
                            String mz = "";
                            String intensity = "";
                            boolean mzDuplication = false;
                            boolean mzNotNumeric = false;
                            boolean intensityNotNumeric = false;
                            boolean invalidFormat = false;
                            HashSet<String> mzSet = new HashSet<String>();
                            for (int l = 0; l < valStrs.size(); l++) {
                                peak = valStrs.get(l).trim();
                                // N/A
                                if (peak.indexOf(DEFAULT_VALUE) != -1) {
                                    isNa = true;
                                    break;
                                }
                                if (l == 0) {
                                    continue;
                                } // m/z int. rel.int.??????????

                                if (peak.indexOf(" ") != -1) {
                                    mz = peak.split(" ")[0];
                                    if (!mzSet.add(mz)) {
                                        mzDuplication = true;
                                    }
                                    try {
                                        Double.parseDouble(mz);
                                    } catch (NumberFormatException e) {
                                        mzNotNumeric = true;
                                    }
                                    intensity = peak.split(" ")[1];
                                    try {
                                        Double.parseDouble(intensity);
                                    } catch (NumberFormatException e) {
                                        intensityNotNumeric = true;
                                    }
                                } else {
                                    invalidFormat = true;
                                }
                                if (mzDuplication && mzNotNumeric && intensityNotNumeric && invalidFormat) {
                                    break;
                                }
                            }
                            if (isNa) {// PK$PEAK:?N/A??
                                if (peakNum != -1) { // PK$NUM_PEAK:N/A??
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn
                                            .append("value of required item [PK$NUM_PEAK: ] is mismatch or \""
                                                    + DEFAULT_VALUE + "\".");
                                }
                                if (valStrs.size() - 1 > 0) { // PK$PEAK:????????
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append(
                                            "value of required item [PK$NUM_PEAK: ] is invalid peak information exists.");
                                }
                            } else {
                                if (mzDuplication) {
                                    status = STATUS_ERR;
                                    detailsErr.append(
                                            "mz value of required item [" + requiredStr + "] is duplication.");
                                }
                                if (mzNotNumeric) {
                                    status = STATUS_ERR;
                                    detailsErr.append(
                                            "mz value of required item [" + requiredStr + "] is not numeric.");
                                }
                                if (intensityNotNumeric) {
                                    status = STATUS_ERR;
                                    detailsErr.append("intensity value of required item [" + requiredStr
                                            + "] is not numeric.");
                                }
                                if (invalidFormat) {
                                    status = STATUS_ERR;
                                    detailsErr.append(
                                            "value of required item [" + requiredStr + "] is not peak format.");
                                }
                                if (peakNum != 0 && valStrs.size() - 1 == 0) { // ?????N/A????PK$NUM_PEAK:?0???????
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append(
                                            "value of required item [PK$PEAK: ] is no value.  at that time, please add \""
                                                    + DEFAULT_VALUE + "\". ");
                                }
                                if (peakNum != valStrs.size() - 1) {
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn
                                            .append("value of required item [PK$NUM_PEAK: ] is mismatch or \""
                                                    + DEFAULT_VALUE + "\".");
                                }
                            }
                        }
                    }
                }
            }
        }
        String details = detailsErr.toString() + detailsWarn.toString();
        if (status.equals("")) {
            status = STATUS_OK;
            details = " ";
        }
        validationMap.put(name, status + "\t" + details);
    }

    //      // ----------------------------------------------------
    //      // ????
    //      // ----------------------------------------------------
    //      // ?ID?DB
    //      HashSet<String> regIdList = new HashSet<String>();
    //      String[] sqls = { "SELECT ID FROM SPECTRUM ORDER BY ID",
    //            "SELECT ID FROM RECORD ORDER BY ID",
    //            "SELECT ID FROM PEAK GROUP BY ID ORDER BY ID",
    //            "SELECT ID FROM CH_NAME ID ORDER BY ID",
    //            "SELECT ID FROM CH_LINK ID ORDER BY ID",
    //            "SELECT ID FROM TREE WHERE ID IS NOT NULL AND ID<>'' ORDER BY ID" };
    //      for (int i = 0; i < sqls.length; i++) {
    //         String execSql = sqls[i];
    //         ResultSet rs = null;
    //         try {
    //            rs = db.executeQuery(execSql);
    //            while (rs.next()) {
    //               String idStr = rs.getString("ID");
    //               regIdList.add(idStr);
    //            }
    //         } catch (SQLException e) {
    //            Logger.getLogger("global").severe("    sql : " + execSql);
    //            e.printStackTrace();
    //            op.println(msgErr("database access error."));
    //            return new TreeMap<String, String>();
    //         } finally {
    //            try {
    //               if (rs != null) {
    //                  rs.close();
    //               }
    //            } catch (SQLException e) {
    //            }
    //         }
    //      }
    //      // ?ID?
    //      final String[] recFileList = (new File(registPath)).list();
    //      for (int i = 0; i < recFileList.length; i++) {
    //         String name = recFileList[i];
    //         File file = new File(registPath + File.separator + name);
    //         if (!file.isFile() || file.isHidden()
    //               || name.lastIndexOf(REC_EXTENSION) == -1) {
    //            continue;
    //         }
    //         String idStr = name.replace(REC_EXTENSION, "");
    //         regIdList.add(idStr);
    //      }

    //      // ??
    //      for (Map.Entry<String, String> e : validationMap.entrySet()) {
    //         String statusStr = e.getValue().split("\t")[0];
    //         if (statusStr.equals(STATUS_ERR)) {
    //            continue;
    //         }
    //         String nameStr = e.getKey();
    //         String idStr = e.getKey().replace(REC_EXTENSION, "");
    //         String detailsStr = e.getValue().split("\t")[1];
    //         if (regIdList.contains(idStr)) {
    //            statusStr = STATUS_WARN;
    //            detailsStr += "id ["
    //                  + idStr + "] of file name ["
    //                  + nameStr
    //                  + "] already registered.";
    //            validationMap.put(nameStr, statusStr + "\t" + detailsStr);
    //         }
    //      }

    return validationMap;
}

From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
    final View layout;
    MENU_ID menu_id = MENU_ID.getMenuIdEnum(item.getItemId());
    assert menu_id != null;
    switch (menu_id) {
    case SETTING:
        FlurryAgent.logEvent("Setting");
        // ?// w w w.  j a  va 2s .  c  o  m
        layout = inflater.inflate(R.layout.setting, (ViewGroup) findViewById(R.id.layout_root));

        mAlertDialog = new AlertDialog.Builder(this);
        mAlertDialog.setTitle(this.getString(R.string.dialog_title_setting));
        mAlertDialog.setIcon(R.drawable.ic_settings_black_48dp);
        mAlertDialog.setView(layout);
        mAlertDialog.setNegativeButton(this.getString(R.string.dialog_button_ok), null);

        setSeekBarInLayout(layout);
        setSwitchInLayout(layout);
        setRadioGroupInLayout(layout);
        setToggleButtonInLayout(layout);
        mAlertDialog.show();
        break;
    case TWITTER:
        FlurryAgent.logEvent("Share twitter");
        if (!TwitterUtility.hasAccessToken(this)) {
            startAuthorize();
        } else {
            layout = inflater.inflate(R.layout.sharetotwitter,
                    (ViewGroup) findViewById(R.id.layout_root_twitter));
            String timeStamp = new SimpleDateFormat(DateUtil.DATE_FORMAT.YYYYMMDD_HHmmss.getFormat(),
                    Locale.JAPAN).format(Calendar.getInstance().getTime());
            mAlertDialog = new AlertDialog.Builder(this);
            mAlertDialog.setTitle(this.getString(R.string.dialog_title_tweet));
            mAlertDialog.setIcon(R.drawable.ic_share_black_48dp);
            mAlertDialog.setView(layout);
            mTweetText = (EditText) layout.findViewById(R.id.edtTweet);
            mTweetText.setText(getString(R.string.twitter_tweetText) + "\n"
                    + String.format(getString(R.string.app_googlePlay_url), getPackageName()) + "\n"
                    + timeStamp);
            mAlertDialog.setPositiveButton(this.getString(R.string.dialog_button_send),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            tweet(mTweetText.getText().toString());
                        }
                    });
            mAlertDialog.setCancelable(false);
            mAlertDialog.setNegativeButton(this.getString(R.string.dialog_button_cancel), null);
            mAlertDialog.show();
        }
        break;
    case HISTORY:
        Intent intent = new Intent(MainActivity.this, HistoryActivity.class);
        startActivity(intent);
        break;
    case FACEBOOK:
        showShareDialog();
        break;
    case LINE:
        LINEUtil.sendStringMessage(this, getString(R.string.twitter_tweetText) + "\n"
                + String.format(getString(R.string.app_googlePlay_url), getPackageName()));
        break;
    case FEEDBACK:
        Toast.makeText(this, "??????????", Toast.LENGTH_LONG).show();
        new EasyFeedback.Builder(this).withEmail("0825elle@gmail.com").build().start();
        break;
    case LICENSE:
        new LibsBuilder()
                //provide a style (optional) (LIGHT, DARK, LIGHT_DARK_TOOLBAR)
                .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR).withAboutIconShown(true)
                .withAboutVersionShown(true)
                //                        .withAboutDescription("T")
                //start the activity
                .start(this);
        break;

    }
    return true;
}

From source file:net.e_fas.oss.tabijiman.MapsActivity.java

public void exec(Locale locale) throws IOException, JSONException {

    JSONArray datas;/*  ww w . j a  v a2 s  .c  o m*/
    String line;
    data = new ArrayList<>();

    assetManager = Init_context.getResources().getAssets();
    // assets/initFrameJSON.json
    input = assetManager.open("initFrameJSON.json");

    BufferedReader reader = new BufferedReader(new InputStreamReader(input));
    StringBuilder stringBuilder = new StringBuilder();

    while ((line = reader.readLine()) != null) {
        stringBuilder.append(line);
    }
    reader.close();
    jsonString = stringBuilder.toString();
    json = new JSONObject(jsonString);

    String Hash = AppSetting.Encrypt(String.valueOf(json));
    e_print("new Hash >> " + Hash + "\nstore Hash >> " + AppSetting.getUdInitHash());

    if (AppSetting.isHashChanged(Hash, AppSetting.getUdInitHash())) {

        e_print("make a new init data");
        AppSetting.setUdInitHash(Hash);

        if (locale.equals(Locale.JAPAN)) {

            datas = json.getJSONObject("results").getJSONObject("bindings").getJSONArray("jp");
        } else {

            datas = json.getJSONObject("results").getJSONObject("bindings").getJSONArray("en");
        }

        e_print("datas_count >> " + datas.length());

        for (int i = 0; i < datas.length(); i++) {

            temp = new HashMap<>();

            temp.put("name", datas.getJSONObject(i).getJSONObject("name").getString("value"));
            temp.put("desc", datas.getJSONObject(i).getJSONObject("desc").getString("value"));
            temp.put("img", datas.getJSONObject(i).getJSONObject("img").getString("value"));
            temp.put("lat", datas.getJSONObject(i).getJSONObject("lat").getString("value"));
            temp.put("lng", datas.getJSONObject(i).getJSONObject("lng").getString("value"));
            if (!datas.getJSONObject(i).isNull("area")) {
                temp.put("area", datas.getJSONObject(i).getJSONObject("area").getString("value"));
            }

            print("initFrame_temp " + i + " >> " + temp);

            data.add(temp);
        }

        InsertFrame(data);

    } else {

        e_print("Already Inserted Init Data");

    }
}

From source file:net.massbank.validator.RecordValidator.java

/**
 * ??//from  w  ww  .  j  a v  a 2s.com
 * 
 * @param db
 *            DB
 * @param op
 *            PrintWriter?
 * @param dataPath
 *            ?
 * @param registPath
 *            
 * @param ver
 *            ?
 * @return ??Map<??, ?>
 * @throws IOException
 *             
 */
private static TreeMap<String, String> validationRecordOnline(DatabaseAccess db, PrintStream op,
        String dataPath, String registPath, int ver) throws IOException {

    op.println(msgInfo("validation archive is [" + UPLOAD_RECDATA_ZIP + "] or [" + UPLOAD_RECDATA_MSBK + "]."));
    if (ver == 1) {
        op.println(msgInfo("check record format version is [version 1]."));
    }

    final String[] dataList = (new File(dataPath)).list();
    TreeMap<String, String> validationMap = new TreeMap<String, String>();

    if (dataList.length == 0) {
        op.println(msgWarn("no file for validation."));
        return validationMap;
    }

    // ----------------------------------------------------
    // ???
    // ----------------------------------------------------
    String[] requiredList = new String[] { // Ver.2
            "ACCESSION: ", "RECORD_TITLE: ", "DATE: ", "AUTHORS: ", "LICENSE: ", "CH$NAME: ",
            "CH$COMPOUND_CLASS: ", "CH$FORMULA: ", "CH$EXACT_MASS: ", "CH$SMILES: ", "CH$IUPAC: ",
            "AC$INSTRUMENT: ", "AC$INSTRUMENT_TYPE: ", "AC$MASS_SPECTROMETRY: MS_TYPE ",
            "AC$MASS_SPECTROMETRY: ION_MODE ", "PK$NUM_PEAK: ", "PK$PEAK: " };
    if (ver == 1) { // Ver.1
        requiredList = new String[] { "ACCESSION: ", "RECORD_TITLE: ", "DATE: ", "AUTHORS: ", "COPYRIGHT: ",
                "CH$NAME: ", "CH$COMPOUND_CLASS: ", "CH$FORMULA: ", "CH$EXACT_MASS: ", "CH$SMILES: ",
                "CH$IUPAC: ", "AC$INSTRUMENT: ", "AC$INSTRUMENT_TYPE: ", "AC$ANALYTICAL_CONDITION: MODE ",
                "PK$NUM_PEAK: ", "PK$PEAK: " };
    }
    for (int i = 0; i < dataList.length; i++) {
        String name = dataList[i];
        String status = "";
        StringBuilder detailsErr = new StringBuilder();
        StringBuilder detailsWarn = new StringBuilder();

        // ????
        File file = new File(dataPath + name);
        if (file.isDirectory()) {
            // ??
            status = STATUS_ERR;
            detailsErr.append("[" + name + "] is directory.");
            validationMap.put(name, status + "\t" + detailsErr.toString());
            continue;
        } else if (file.isHidden()) {
            // ???
            status = STATUS_ERR;
            detailsErr.append("[" + name + "] is hidden.");
            validationMap.put(name, status + "\t" + detailsErr.toString());
            continue;
        } else if (name.lastIndexOf(REC_EXTENSION) == -1) {
            // ????
            status = STATUS_ERR;
            detailsErr.append("file extension of [" + name + "] is not [" + REC_EXTENSION + "].");
            validationMap.put(name, status + "\t" + detailsErr.toString());
            continue;
        }

        // ??
        boolean isEndTagRead = false;
        boolean isInvalidInfo = false;
        boolean isDoubleByte = false;
        ArrayList<String> fileContents = new ArrayList<String>();
        boolean existLicense = false; // LICENSE?Ver.1
        ArrayList<String> workChName = new ArrayList<String>(); // RECORD_TITLE??CH$NAME??Ver.1?
        String workAcInstrumentType = ""; // RECORD_TITLE??AC$INSTRUMENT_TYPE??Ver.1?
        String workAcMsType = ""; // RECORD_TITLE??AC$MASS_SPECTROMETRY:
        // MS_TYPE??Ver.2
        String line = "";
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(file));
            while ((line = br.readLine()) != null) {
                if (isEndTagRead) {
                    if (!line.equals("")) {
                        isInvalidInfo = true;
                    }
                }

                // 
                if (line.startsWith("//")) {
                    isEndTagRead = true;
                }
                fileContents.add(line);

                // LICENSE?Ver.1
                if (line.startsWith("LICENSE: ")) {
                    existLicense = true;
                }
                // CH$NAME?Ver.1?
                else if (line.startsWith("CH$NAME: ")) {
                    workChName.add(line.trim().replaceAll("CH\\$NAME: ", ""));
                }
                // AC$INSTRUMENT_TYPE?Ver.1?
                else if (line.startsWith("AC$INSTRUMENT_TYPE: ")) {
                    workAcInstrumentType = line.trim().replaceAll("AC\\$INSTRUMENT_TYPE: ", "");
                }
                // AC$MASS_SPECTROMETRY: MS_TYPE?Ver.2
                else if (ver != 1 && line.startsWith("AC$MASS_SPECTROMETRY: MS_TYPE ")) {
                    workAcMsType = line.trim().replaceAll("AC\\$MASS_SPECTROMETRY: MS_TYPE ", "");
                }

                // ?
                if (!isDoubleByte) {
                    byte[] bytes = line.getBytes("MS932");
                    if (bytes.length != line.length()) {
                        isDoubleByte = true;
                    }
                }
            }
        } catch (IOException e) {
            Logger.getLogger("global").severe("file read failed." + NEW_LINE + "    " + file.getPath());
            e.printStackTrace();
            op.println(msgErr("server error."));
            validationMap.clear();
            return validationMap;
        } finally {
            try {
                if (br != null) {
                    br.close();
                }
            } catch (IOException e) {
            }
        }
        if (isInvalidInfo) {
            // ?????
            if (status.equals(""))
                status = STATUS_WARN;
            detailsWarn.append("invalid after the end tag [//].");
        }
        if (isDoubleByte) {
            // ?????
            if (status.equals(""))
                status = STATUS_ERR;
            detailsErr.append("double-byte character included.");
        }
        if (ver == 1 && existLicense) {
            // LICENSE???Ver.1
            if (status.equals(""))
                status = STATUS_ERR;
            detailsErr.append("[LICENSE: ] tag can not be used in record format  [version 1].");
        }

        // ----------------------------------------------------
        // ????
        // ----------------------------------------------------
        boolean isNameCheck = false;
        int peakNum = -1;
        for (int j = 0; j < requiredList.length; j++) {
            String requiredStr = requiredList[j];
            ArrayList<String> valStrs = new ArrayList<String>(); // 
            boolean findRequired = false; // 
            boolean findValue = false; // 
            boolean isPeakMode = false; // 
            for (int k = 0; k < fileContents.size(); k++) {
                String lineStr = fileContents.get(k);

                // ????RELATED_RECORD??????
                if (lineStr.startsWith("//")) { // Ver.1?
                    break;
                } else if (ver == 1 && lineStr.startsWith("RELATED_RECORD:")) { // Ver.1
                    break;
                }
                // ?????
                else if (isPeakMode) {
                    findRequired = true;
                    if (!lineStr.trim().equals("")) {
                        valStrs.add(lineStr);
                    }
                }
                // ??????
                else if (lineStr.indexOf(requiredStr) != -1) {
                    // 
                    findRequired = true;
                    if (requiredStr.equals("PK$PEAK: ")) {
                        isPeakMode = true;
                        findValue = true;
                        valStrs.add(lineStr.replace(requiredStr, ""));
                    } else {
                        // 
                        String tmpVal = lineStr.replace(requiredStr, "");
                        if (!tmpVal.trim().equals("")) {
                            findValue = true;
                            valStrs.add(tmpVal);
                        }
                        break;
                    }
                }
            }
            if (!findRequired) {
                // ??????
                status = STATUS_ERR;
                detailsErr.append("no required item [" + requiredStr + "].");
            } else {
                if (!findValue) {
                    // ?????
                    status = STATUS_ERR;
                    detailsErr.append("no value of required item [" + requiredStr + "].");
                } else {
                    // ???

                    // ----------------------------------------------------
                    // ??
                    // ----------------------------------------------------
                    String val = (valStrs.size() > 0) ? valStrs.get(0) : "";
                    // ACESSIONVer.1?
                    if (requiredStr.equals("ACCESSION: ")) {
                        if (!val.equals(name.replace(REC_EXTENSION, ""))) {
                            status = STATUS_ERR;
                            detailsErr.append("value of required item [" + requiredStr
                                    + "] not correspond to file name.");
                        }
                        if (val.length() != 8) {
                            status = STATUS_ERR;
                            detailsErr.append(
                                    "value of required item [" + requiredStr + "] is 8 digits necessary.");
                        }
                    }
                    // RECORD_TITLEVer.1?
                    else if (requiredStr.equals("RECORD_TITLE: ")) {
                        if (!val.equals(DEFAULT_VALUE)) {
                            if (val.indexOf(";") != -1) {
                                String[] recTitle = val.split(";");
                                if (!workChName.contains(recTitle[0].trim())) {
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], compound name is not included in the [CH$NAME].");
                                }
                                if (!workAcInstrumentType.equals(recTitle[1].trim())) {
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], instrument type is different from [AC$INSTRUMENT_TYPE].");
                                }
                                if (ver != 1 && !workAcMsType.equals(recTitle[2].trim())) { // Ver.2
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], ms type is different from [AC$MASS_SPECTROMETRY: MS_TYPE].");
                                }
                            } else {
                                if (status.equals(""))
                                    status = STATUS_WARN;
                                detailsWarn.append("value of required item [" + requiredStr
                                        + "] is not record title format.");

                                if (!workChName.contains(val)) {
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], compound name is not included in the [CH$NAME].");
                                }
                                if (!workAcInstrumentType.equals(DEFAULT_VALUE)) {
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], instrument type is different from [AC$INSTRUMENT_TYPE].");
                                }
                                if (ver != 1 && !workAcMsType.equals(DEFAULT_VALUE)) { // Ver.2
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], ms type is different from [AC$MASS_SPECTROMETRY: MS_TYPE].");
                                }
                            }
                        } else {
                            if (!workAcInstrumentType.equals(DEFAULT_VALUE)) {
                                if (status.equals(""))
                                    status = STATUS_WARN;
                                detailsWarn.append("value of required item [" + requiredStr
                                        + "], instrument type is different from [AC$INSTRUMENT_TYPE].");
                            }
                            if (ver != 1 && !workAcMsType.equals(DEFAULT_VALUE)) { // Ver.2
                                if (status.equals(""))
                                    status = STATUS_WARN;
                                detailsWarn.append("value of required item [" + requiredStr
                                        + "], ms type is different from [AC$MASS_SPECTROMETRY: MS_TYPE].");
                            }
                        }
                    }
                    // DATEVer.1?
                    else if (requiredStr.equals("DATE: ") && !val.equals(DEFAULT_VALUE)) {
                        val = val.replace(".", "/");
                        val = val.replace("-", "/");
                        try {
                            DateFormat.getDateInstance(DateFormat.SHORT, Locale.JAPAN).parse(val);
                        } catch (ParseException e) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn
                                    .append("value of required item [" + requiredStr + "] is not date format.");
                        }
                    }
                    // CH$COMPOUND_CLASSVer.1?
                    else if (requiredStr.equals("CH$COMPOUND_CLASS: ") && !val.equals(DEFAULT_VALUE)) {
                        if (!val.startsWith("Natural Product") && !val.startsWith("Non-Natural Product")) {

                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr
                                    + "] is not compound class format.");
                        }
                    }
                    // CH$EXACT_MASSVer.1?
                    else if (requiredStr.equals("CH$EXACT_MASS: ") && !val.equals(DEFAULT_VALUE)) {
                        try {
                            Double.parseDouble(val);
                        } catch (NumberFormatException e) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr + "] is not numeric.");
                        }
                    }
                    // AC$INSTRUMENT_TYPEVer.1?
                    else if (requiredStr.equals("AC$INSTRUMENT_TYPE: ") && !val.equals(DEFAULT_VALUE)) {
                        if (val.trim().indexOf(" ") != -1) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn
                                    .append("value of required item [" + requiredStr + "] is space included.");
                        }
                        if (val.trim().indexOf(" ") != -1) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn
                                    .append("value of required item [" + requiredStr + "] is space included.");
                        }
                    }
                    // AC$MASS_SPECTROMETRY: MS_TYPEVer.2
                    else if (ver != 1 && requiredStr.equals("AC$MASS_SPECTROMETRY: MS_TYPE ")
                            && !val.equals(DEFAULT_VALUE)) {
                        boolean isMsType = true;
                        if (val.startsWith("MS")) {
                            val = val.replace("MS", "");
                            if (!val.equals("")) {
                                try {
                                    Integer.parseInt(val);
                                } catch (NumberFormatException e) {
                                    isMsType = false;
                                }
                            }
                        } else {
                            isMsType = false;
                        }
                        if (!isMsType) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr + "] is not \"MSn\".");
                        }
                    }
                    // AC$MASS_SPECTROMETRY:
                    // ION_MODEVer.2?AC$ANALYTICAL_CONDITION: MODEVer.1
                    else if ((ver != 1 && requiredStr.equals("AC$MASS_SPECTROMETRY: ION_MODE ")
                            && !val.equals(DEFAULT_VALUE))
                            || (ver == 1 && requiredStr.equals("AC$ANALYTICAL_CONDITION: MODE ")
                                    && !val.equals(DEFAULT_VALUE))) {
                        if (!val.equals("POSITIVE") && !val.equals("NEGATIVE")) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr
                                    + "] is not \"POSITIVE\" or \"NEGATIVE\".");
                        }
                    }
                    // PK$NUM_PEAKVer.1?
                    else if (requiredStr.equals("PK$NUM_PEAK: ") && !val.equals(DEFAULT_VALUE)) {
                        try {
                            peakNum = Integer.parseInt(val);
                        } catch (NumberFormatException e) {
                            status = STATUS_ERR;
                            detailsErr.append("value of required item [" + requiredStr + "] is not numeric.");
                        }
                    }
                    // PK$PEAK:Ver.1?
                    else if (requiredStr.equals("PK$PEAK: ")) {
                        if (valStrs.size() == 0 || !valStrs.get(0).startsWith("m/z int. rel.int.")) {
                            status = STATUS_ERR;
                            detailsErr.append(
                                    "value of required item [PK$PEAK: ] , the first line is not \"PK$PEAK: m/z int. rel.int.\".");
                        } else {
                            boolean isNa = false;
                            String peak = "";
                            String mz = "";
                            String intensity = "";
                            boolean mzDuplication = false;
                            boolean mzNotNumeric = false;
                            boolean intensityNotNumeric = false;
                            boolean invalidFormat = false;
                            HashSet<String> mzSet = new HashSet<String>();
                            for (int l = 0; l < valStrs.size(); l++) {
                                peak = valStrs.get(l).trim();
                                // N/A
                                if (peak.indexOf(DEFAULT_VALUE) != -1) {
                                    isNa = true;
                                    break;
                                }
                                if (l == 0) {
                                    continue;
                                } // m/z int. rel.int.??????????

                                if (peak.indexOf(" ") != -1) {
                                    mz = peak.split(" ")[0];
                                    if (!mzSet.add(mz)) {
                                        mzDuplication = true;
                                    }
                                    try {
                                        Double.parseDouble(mz);
                                    } catch (NumberFormatException e) {
                                        mzNotNumeric = true;
                                    }
                                    intensity = peak.split(" ")[1];
                                    try {
                                        Double.parseDouble(intensity);
                                    } catch (NumberFormatException e) {
                                        intensityNotNumeric = true;
                                    }
                                } else {
                                    invalidFormat = true;
                                }
                                if (mzDuplication && mzNotNumeric && intensityNotNumeric && invalidFormat) {
                                    break;
                                }
                            }
                            if (isNa) {// PK$PEAK:?N/A??
                                if (peakNum != -1) { // PK$NUM_PEAK:N/A??
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn
                                            .append("value of required item [PK$NUM_PEAK: ] is mismatch or \""
                                                    + DEFAULT_VALUE + "\".");
                                }
                                if (valStrs.size() - 1 > 0) { // PK$PEAK:????????
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append(
                                            "value of required item [PK$NUM_PEAK: ] is invalid peak information exists.");
                                }
                            } else {
                                if (mzDuplication) {
                                    status = STATUS_ERR;
                                    detailsErr.append(
                                            "mz value of required item [" + requiredStr + "] is duplication.");
                                }
                                if (mzNotNumeric) {
                                    status = STATUS_ERR;
                                    detailsErr.append(
                                            "mz value of required item [" + requiredStr + "] is not numeric.");
                                }
                                if (intensityNotNumeric) {
                                    status = STATUS_ERR;
                                    detailsErr.append("intensity value of required item [" + requiredStr
                                            + "] is not numeric.");
                                }
                                if (invalidFormat) {
                                    status = STATUS_ERR;
                                    detailsErr.append(
                                            "value of required item [" + requiredStr + "] is not peak format.");
                                }
                                if (peakNum != 0 && valStrs.size() - 1 == 0) { // ?????N/A????PK$NUM_PEAK:?0???????
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append(
                                            "value of required item [PK$PEAK: ] is no value.  at that time, please add \""
                                                    + DEFAULT_VALUE + "\". ");
                                }
                                if (peakNum != valStrs.size() - 1) {
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn
                                            .append("value of required item [PK$NUM_PEAK: ] is mismatch or \""
                                                    + DEFAULT_VALUE + "\".");
                                }
                            }
                        }
                    }
                }
            }
        }
        String details = detailsErr.toString() + detailsWarn.toString();
        if (status.equals("")) {
            status = STATUS_OK;
            details = " ";
        }
        validationMap.put(name, status + "\t" + details);
    }

    // ----------------------------------------------------
    // ????
    // ----------------------------------------------------
    // ?ID?DB
    HashSet<String> regIdList = new HashSet<String>();
    String[] sqls = { "SELECT ID FROM SPECTRUM ORDER BY ID", "SELECT ID FROM RECORD ORDER BY ID",
            "SELECT ID FROM PEAK GROUP BY ID ORDER BY ID", "SELECT ID FROM CH_NAME ID ORDER BY ID",
            "SELECT ID FROM CH_LINK ID ORDER BY ID",
            "SELECT ID FROM TREE WHERE ID IS NOT NULL AND ID<>'' ORDER BY ID" };
    for (int i = 0; i < sqls.length; i++) {
        String execSql = sqls[i];
        ResultSet rs = null;
        try {
            rs = db.executeQuery(execSql);
            while (rs.next()) {
                String idStr = rs.getString("ID");
                regIdList.add(idStr);
            }
        } catch (SQLException e) {
            Logger.getLogger("global").severe("    sql : " + execSql);
            e.printStackTrace();
            op.println(msgErr("database access error."));
            return new TreeMap<String, String>();
        } finally {
            try {
                if (rs != null) {
                    rs.close();
                }
            } catch (SQLException e) {
            }
        }
    }
    // ?ID?
    final String[] recFileList = (new File(registPath)).list();
    for (int i = 0; i < recFileList.length; i++) {
        String name = recFileList[i];
        File file = new File(registPath + File.separator + name);
        if (!file.isFile() || file.isHidden() || name.lastIndexOf(REC_EXTENSION) == -1) {
            continue;
        }
        String idStr = name.replace(REC_EXTENSION, "");
        regIdList.add(idStr);
    }

    // ??
    for (Map.Entry<String, String> e : validationMap.entrySet()) {
        String statusStr = e.getValue().split("\t")[0];
        if (statusStr.equals(STATUS_ERR)) {
            continue;
        }
        String nameStr = e.getKey();
        String idStr = e.getKey().replace(REC_EXTENSION, "");
        String detailsStr = e.getValue().split("\t")[1];
        if (regIdList.contains(idStr)) {
            statusStr = STATUS_WARN;
            detailsStr += "id [" + idStr + "] of file name [" + nameStr + "] already registered.";
            validationMap.put(nameStr, statusStr + "\t" + detailsStr);
        }
    }

    return validationMap;
}