Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
  * either express or implied. See the License for the specific language
  * governing permissions and limitations under the License.
  */
 package org.dbflute.infra.dfprop;
 
 import java.net.URL;
 import java.util.Map;
 
The handling class for publicMap.dfprop.
 e.g. use default URL
  DfPropPublicMap publicMap = new DfPropPublicMap();
  publicMap.loadMap(); // connecting to network
  String latestVersion = publicMap.getDBFluteLatestVersion();
 

Deprecated:
use public.properties
Author(s):
jflute
Since:
1.0.5K (2014/08/15 Friday)
 
 public class DfPropPublicMap {
 
     // ===================================================================================
     //                                                                          Definition
     //                                                                          ==========
     protected static final String DBFLUTE_LATEST_VERSION = "dbflute.latest.version";
     protected static final String DBFLUTE_LATEST_SNAPSHOT_VERSION = "dbflute.latest.snapshot.version";
     protected static final String DBFLUTE_DOWNLOAD_URL = "dbflute.download.url";
     protected static final String INTRO_DOWNLOAD_URL = "intro.download.url";
 
     protected static final String DEFAULT_DFPROP_URL = "http://dbflute.org/meta/publicMap.dfprop";
     protected static final String VERSION_SUFFIX_VARIABLE = "$$versionSuffix$$";
 
     // ===================================================================================
     //                                                                           Attribute
     //                                                                           =========
     protected Map<StringObject_map;
     protected String _specifiedUrl;
 
     // ===================================================================================
     //                                                                           Load Meta
     //                                                                           =========
     public void loadMap() {
         final String siteUrl = getPublicMapUrl();
         InputStream ins = null;
         try {
             final URL url = new URL(siteUrl);
             ins = url.openStream();
             final MapListFile mapListFile = new MapListFile();
              = mapListFile.readMap(ins);
         } catch (IOException e) {
             throw new IllegalStateException("The url threw the IO exception: url=" + siteUrle);
         } finally {
             if (ins != null) {
                 try {
                     ins.close();
                 } catch (IOException ignored) {}
             }
         }
     }
 
     // ===================================================================================
     //                                                                            Property
     //                                                                            ========
     public String getDBFluteLatestVersion() {
         return getMetaValue();
     }
 
     }
 
     public String getDBFluteDownloadUrl(String downloadVersion) {
         final String key = ;
         final String downloadUrl = getMetaValue(key);
         if (downloadUrl == null) {
             String msg = "Not found the property: key=" + key + ", map=" + ;
             throw new IllegalStateException(msg);
         }
         return buildDBFluteDownloadUrl(downloadUrldownloadVersion);
     }
 
    protected String buildDBFluteDownloadUrl(String downloadUrlString downloadVersion) {
        final String toStr;
        if (Srl.is_NotNull_and_NotTrimmedEmpty(downloadVersion)) {
            toStr = "-" + downloadVersion;
        } else {
            toStr = ""// to remove variable
        }
        return Srl.replace(downloadUrltoStr);
    }
    public String getIntroDownloadUrl() {
        return getMetaValue();
    }
    // ===================================================================================
    //                                                                       Assist Helper
    //                                                                       =============
    protected String getMetaValue(String key) {
        return (String.get(key);
    }
    protected String getPublicMapUrl() {
        return  != null ?  : ;
    }
    // ===================================================================================
    //                                                                              Option
    //                                                                              ======
    public DfPropPublicMap specifyUrl(String url) {
         = url;
        return this;
    }
New to GrepCode? Check out our FAQ X