Пример #1
0
 private static Location buildLocation(
     String property,
     URL defaultLocation,
     String userDefaultAppendage,
     boolean readOnlyDefault,
     boolean computeReadOnly,
     String dataAreaPrefix) {
   String location = FrameworkProperties.clearProperty(property);
   // the user/product may specify a non-default readOnly setting
   String userReadOnlySetting = FrameworkProperties.getProperty(property + READ_ONLY_AREA_SUFFIX);
   boolean readOnly =
       (userReadOnlySetting == null
           ? readOnlyDefault
           : Boolean.valueOf(userReadOnlySetting).booleanValue());
   // if the instance location is not set, predict where the workspace will be and
   // put the instance area inside the workspace meta area.
   if (location == null)
     return new BasicLocation(
         property,
         defaultLocation,
         userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(defaultLocation),
         dataAreaPrefix);
   String trimmedLocation = location.trim();
   if (trimmedLocation.equalsIgnoreCase(NONE)) return null;
   if (trimmedLocation.equalsIgnoreCase(NO_DEFAULT))
     return new BasicLocation(property, null, readOnly, dataAreaPrefix);
   if (trimmedLocation.startsWith(USER_HOME)) {
     String base = substituteVar(location, USER_HOME, PROP_USER_HOME);
     location = new File(base, userDefaultAppendage).getAbsolutePath();
   } else if (trimmedLocation.startsWith(USER_DIR)) {
     String base = substituteVar(location, USER_DIR, PROP_USER_DIR);
     location = new File(base, userDefaultAppendage).getAbsolutePath();
   }
   URL url = buildURL(location, true);
   BasicLocation result = null;
   if (url != null) {
     result =
         new BasicLocation(
             property,
             null,
             userReadOnlySetting != null || !computeReadOnly ? readOnly : !canWrite(url),
             dataAreaPrefix);
     result.setURL(url, false);
   }
   return result;
 }