Coverage Report - org.seasar.eclipse.common.variable.AbstractVariable
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractVariable
0%
0/15
N/A
0
 
 1  
 /*
 2  
  * Copyright 2004-2008 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.eclipse.common.variable;
 17  
 
 18  
 import java.io.File;
 19  
 import java.io.IOException;
 20  
 import java.net.URL;
 21  
 
 22  
 import org.eclipse.core.runtime.FileLocator;
 23  
 import org.eclipse.core.runtime.Path;
 24  
 import org.eclipse.jdt.core.ClasspathVariableInitializer;
 25  
 import org.eclipse.jdt.core.JavaCore;
 26  
 import org.eclipse.jdt.core.JavaModelException;
 27  
 
 28  
 /**
 29  
  * @author taichi
 30  
  * 
 31  
  */
 32  
 public abstract class AbstractVariable extends ClasspathVariableInitializer {
 33  
 
 34  
         /**
 35  
          * 
 36  
          */
 37  
         public AbstractVariable() {
 38  0
                 super();
 39  0
         }
 40  
 
 41  
         /*
 42  
          * (non-Javadoc)
 43  
          * 
 44  
          * @see org.eclipse.jdt.core.ClasspathVariableInitializer#initialize(java.lang.String)
 45  
          */
 46  
         @Override
 47  
     public void initialize(String variable) {
 48  0
                 URL installLocation = getInstallLocation();
 49  0
                 URL local = null;
 50  
                 try {
 51  0
                         local = FileLocator.toFileURL(installLocation);
 52  0
                 } catch (IOException e) {
 53  0
                         JavaCore.removeClasspathVariable(variable, null);
 54  0
                         return;
 55  0
                 }
 56  
                 try {
 57  0
                         String fullPath = new File(local.getPath()).getAbsolutePath();
 58  0
                         JavaCore.setClasspathVariable(variable,
 59  
                                         Path.fromOSString(fullPath), null);
 60  0
                 } catch (JavaModelException e1) {
 61  0
                         JavaCore.removeClasspathVariable(variable, null);
 62  0
                 }
 63  
 
 64  0
         }
 65  
 
 66  
         protected abstract URL getInstallLocation();
 67  
 }