Home | History | Annotate | Download | only in mock
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
      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, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.ide.eclipse.mock;
     18 
     19 import org.eclipse.core.resources.IProject;
     20 import org.eclipse.core.resources.IResource;
     21 import org.eclipse.core.runtime.IPath;
     22 import org.eclipse.core.runtime.IProgressMonitor;
     23 import org.eclipse.core.runtime.jobs.ISchedulingRule;
     24 import org.eclipse.jdt.core.IBuffer;
     25 import org.eclipse.jdt.core.IClasspathEntry;
     26 import org.eclipse.jdt.core.IJavaElement;
     27 import org.eclipse.jdt.core.IJavaModel;
     28 import org.eclipse.jdt.core.IJavaProject;
     29 import org.eclipse.jdt.core.IOpenable;
     30 import org.eclipse.jdt.core.IPackageFragment;
     31 import org.eclipse.jdt.core.IPackageFragmentRoot;
     32 import org.eclipse.jdt.core.IRegion;
     33 import org.eclipse.jdt.core.IType;
     34 import org.eclipse.jdt.core.ITypeHierarchy;
     35 import org.eclipse.jdt.core.JavaCore;
     36 import org.eclipse.jdt.core.JavaModelException;
     37 import org.eclipse.jdt.core.WorkingCopyOwner;
     38 import org.eclipse.jdt.core.eval.IEvaluationContext;
     39 
     40 import sun.reflect.generics.reflectiveObjects.NotImplementedException;
     41 
     42 import java.util.Map;
     43 
     44 public class JavaProjectMock implements IJavaProject {
     45 
     46     private IProject mProject;
     47 
     48     private IClasspathEntry[] mEntries;
     49     private IPath mOutputLocation;
     50     private String mCompilerCompliance = "1.4"; //$NON-NLS-1
     51     private String mCompilerSource = "1.4"; //$NON-NLS-1
     52     private String mCompilerTarget = "1.4"; //$NON-NLS-1
     53 
     54     public JavaProjectMock(IClasspathEntry[] entries, IPath outputLocation) {
     55         mEntries = entries;
     56         mOutputLocation = outputLocation;
     57     }
     58 
     59     public IProject getProject() {
     60         if (mProject == null) {
     61             mProject = new ProjectMock();
     62         }
     63 
     64         return mProject;
     65     }
     66 
     67 
     68     public void setRawClasspath(IClasspathEntry[] entries, IProgressMonitor monitor)
     69             throws JavaModelException {
     70         mEntries = entries;
     71     }
     72 
     73     public void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation,
     74             IProgressMonitor monitor) throws JavaModelException {
     75         mEntries = entries;
     76         mOutputLocation = outputLocation;
     77     }
     78 
     79     public IClasspathEntry[] getRawClasspath() throws JavaModelException {
     80         return mEntries;
     81     }
     82 
     83     public IPath getOutputLocation() throws JavaModelException {
     84         return mOutputLocation;
     85     }
     86 
     87     public String getOption(String optionName, boolean inheritJavaCoreOptions) {
     88         if (optionName.equals(JavaCore.COMPILER_COMPLIANCE)) {
     89             return mCompilerCompliance;
     90         } else if (optionName.equals(JavaCore.COMPILER_SOURCE)) {
     91             return mCompilerSource;
     92         } else if (optionName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) {
     93             return mCompilerTarget;
     94         }
     95 
     96         return null;
     97     }
     98 
     99     public void setOption(String optionName, String optionValue) {
    100         if (optionName.equals(JavaCore.COMPILER_COMPLIANCE)) {
    101             mCompilerCompliance = optionValue;
    102         } else if (optionName.equals(JavaCore.COMPILER_SOURCE)) {
    103             mCompilerSource = optionValue;
    104         } else if (optionName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) {
    105             mCompilerTarget = optionValue;
    106         } else {
    107             throw new NotImplementedException();
    108         }
    109     }
    110 
    111 
    112     // -------- UNIMPLEMENTED METHODS ----------------
    113 
    114     public IClasspathEntry decodeClasspathEntry(String encodedEntry) {
    115         throw new NotImplementedException();
    116     }
    117 
    118     public String encodeClasspathEntry(IClasspathEntry classpathEntry) {
    119         throw new NotImplementedException();
    120     }
    121 
    122     public IJavaElement findElement(IPath path) throws JavaModelException {
    123         throw new NotImplementedException();
    124     }
    125 
    126     public IJavaElement findElement(IPath path, WorkingCopyOwner owner) throws JavaModelException {
    127         throw new NotImplementedException();
    128     }
    129 
    130     public IPackageFragment findPackageFragment(IPath path) throws JavaModelException {
    131         throw new NotImplementedException();
    132     }
    133 
    134     public IPackageFragmentRoot findPackageFragmentRoot(IPath path) throws JavaModelException {
    135         throw new NotImplementedException();
    136     }
    137 
    138     public IPackageFragmentRoot[] findPackageFragmentRoots(IClasspathEntry entry) {
    139         throw new NotImplementedException();
    140     }
    141 
    142     public IType findType(String fullyQualifiedName) throws JavaModelException {
    143         throw new NotImplementedException();
    144     }
    145 
    146     public IType findType(String fullyQualifiedName, IProgressMonitor progressMonitor)
    147             throws JavaModelException {
    148         throw new NotImplementedException();
    149     }
    150 
    151     public IType findType(String fullyQualifiedName, WorkingCopyOwner owner)
    152             throws JavaModelException {
    153         throw new NotImplementedException();
    154     }
    155 
    156     public IType findType(String packageName, String typeQualifiedName) throws JavaModelException {
    157         throw new NotImplementedException();
    158     }
    159 
    160     public IType findType(String fullyQualifiedName, WorkingCopyOwner owner,
    161             IProgressMonitor progressMonitor) throws JavaModelException {
    162         throw new NotImplementedException();
    163     }
    164 
    165     public IType findType(String packageName, String typeQualifiedName,
    166             IProgressMonitor progressMonitor) throws JavaModelException {
    167         throw new NotImplementedException();
    168     }
    169 
    170     public IType findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner)
    171             throws JavaModelException {
    172         throw new NotImplementedException();
    173     }
    174 
    175     public IType findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner,
    176             IProgressMonitor progressMonitor) throws JavaModelException {
    177         throw new NotImplementedException();
    178     }
    179 
    180     public IPackageFragmentRoot[] getAllPackageFragmentRoots() throws JavaModelException {
    181         throw new NotImplementedException();
    182     }
    183 
    184     public Object[] getNonJavaResources() throws JavaModelException {
    185         throw new NotImplementedException();
    186     }
    187 
    188     @SuppressWarnings("unchecked")
    189     public Map getOptions(boolean inheritJavaCoreOptions) {
    190         throw new NotImplementedException();
    191     }
    192 
    193     public IPackageFragmentRoot getPackageFragmentRoot(String jarPath) {
    194         throw new NotImplementedException();
    195     }
    196 
    197     public IPackageFragmentRoot getPackageFragmentRoot(IResource resource) {
    198         throw new NotImplementedException();
    199     }
    200 
    201     public IPackageFragmentRoot[] getPackageFragmentRoots() throws JavaModelException {
    202         throw new NotImplementedException();
    203     }
    204 
    205     public IPackageFragmentRoot[] getPackageFragmentRoots(IClasspathEntry entry) {
    206         throw new NotImplementedException();
    207     }
    208 
    209     public IPackageFragment[] getPackageFragments() throws JavaModelException {
    210         throw new NotImplementedException();
    211     }
    212 
    213     public String[] getRequiredProjectNames() throws JavaModelException {
    214         throw new NotImplementedException();
    215     }
    216 
    217     public IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedEntry)
    218             throws JavaModelException {
    219         throw new NotImplementedException();
    220     }
    221 
    222     public boolean hasBuildState() {
    223         throw new NotImplementedException();
    224     }
    225 
    226     public boolean hasClasspathCycle(IClasspathEntry[] entries) {
    227         throw new NotImplementedException();
    228     }
    229 
    230     public boolean isOnClasspath(IJavaElement element) {
    231         throw new NotImplementedException();
    232     }
    233 
    234     public boolean isOnClasspath(IResource resource) {
    235         throw new NotImplementedException();
    236     }
    237 
    238     public IEvaluationContext newEvaluationContext() {
    239         throw new NotImplementedException();
    240     }
    241 
    242     public ITypeHierarchy newTypeHierarchy(IRegion region, IProgressMonitor monitor)
    243             throws JavaModelException {
    244         throw new NotImplementedException();
    245     }
    246 
    247     public ITypeHierarchy newTypeHierarchy(IRegion region, WorkingCopyOwner owner,
    248             IProgressMonitor monitor) throws JavaModelException {
    249         throw new NotImplementedException();
    250     }
    251 
    252     public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, IProgressMonitor monitor)
    253             throws JavaModelException {
    254         throw new NotImplementedException();
    255     }
    256 
    257     public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, WorkingCopyOwner owner,
    258             IProgressMonitor monitor) throws JavaModelException {
    259         throw new NotImplementedException();
    260     }
    261 
    262     public IPath readOutputLocation() {
    263         throw new NotImplementedException();
    264     }
    265 
    266     public IClasspathEntry[] readRawClasspath() {
    267         throw new NotImplementedException();
    268     }
    269 
    270     @SuppressWarnings("unchecked")
    271     public void setOptions(Map newOptions) {
    272         throw new NotImplementedException();
    273     }
    274 
    275     public void setOutputLocation(IPath path, IProgressMonitor monitor) throws JavaModelException {
    276         throw new NotImplementedException();
    277     }
    278 
    279     public void setRawClasspath(IClasspathEntry[] entries, boolean canModifyResources,
    280             IProgressMonitor monitor) throws JavaModelException {
    281         throw new NotImplementedException();
    282     }
    283 
    284     public void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation,
    285             boolean canModifyResources, IProgressMonitor monitor) throws JavaModelException {
    286         throw new NotImplementedException();
    287     }
    288 
    289     public IJavaElement[] getChildren() throws JavaModelException {
    290         throw new NotImplementedException();
    291     }
    292 
    293     public boolean hasChildren() throws JavaModelException {
    294         throw new NotImplementedException();
    295     }
    296 
    297     public boolean exists() {
    298         throw new NotImplementedException();
    299     }
    300 
    301     public IJavaElement getAncestor(int ancestorType) {
    302         throw new NotImplementedException();
    303     }
    304 
    305     public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException {
    306         throw new NotImplementedException();
    307     }
    308 
    309     public IResource getCorrespondingResource() throws JavaModelException {
    310         throw new NotImplementedException();
    311     }
    312 
    313     public String getElementName() {
    314         throw new NotImplementedException();
    315     }
    316 
    317     public int getElementType() {
    318         throw new NotImplementedException();
    319     }
    320 
    321     public String getHandleIdentifier() {
    322         throw new NotImplementedException();
    323     }
    324 
    325     public IJavaModel getJavaModel() {
    326         throw new NotImplementedException();
    327     }
    328 
    329     public IJavaProject getJavaProject() {
    330         throw new NotImplementedException();
    331     }
    332 
    333     public IOpenable getOpenable() {
    334         throw new NotImplementedException();
    335     }
    336 
    337     public IJavaElement getParent() {
    338         throw new NotImplementedException();
    339     }
    340 
    341     public IPath getPath() {
    342         throw new NotImplementedException();
    343     }
    344 
    345     public IJavaElement getPrimaryElement() {
    346         throw new NotImplementedException();
    347     }
    348 
    349     public IResource getResource() {
    350         throw new NotImplementedException();
    351     }
    352 
    353     public ISchedulingRule getSchedulingRule() {
    354         throw new NotImplementedException();
    355     }
    356 
    357     public IResource getUnderlyingResource() throws JavaModelException {
    358         throw new NotImplementedException();
    359     }
    360 
    361     public boolean isReadOnly() {
    362         throw new NotImplementedException();
    363     }
    364 
    365     public boolean isStructureKnown() throws JavaModelException {
    366         throw new NotImplementedException();
    367     }
    368 
    369     @SuppressWarnings("unchecked")
    370     public Object getAdapter(Class adapter) {
    371         throw new NotImplementedException();
    372     }
    373 
    374     public void close() throws JavaModelException {
    375         throw new NotImplementedException();
    376     }
    377 
    378     public String findRecommendedLineSeparator() throws JavaModelException {
    379         throw new NotImplementedException();
    380     }
    381 
    382     public IBuffer getBuffer() throws JavaModelException {
    383         throw new NotImplementedException();
    384     }
    385 
    386     public boolean hasUnsavedChanges() throws JavaModelException {
    387         throw new NotImplementedException();
    388     }
    389 
    390     public boolean isConsistent() throws JavaModelException {
    391         throw new NotImplementedException();
    392     }
    393 
    394     public boolean isOpen() {
    395         throw new NotImplementedException();
    396     }
    397 
    398     public void makeConsistent(IProgressMonitor progress) throws JavaModelException {
    399         throw new NotImplementedException();
    400     }
    401 
    402     public void open(IProgressMonitor progress) throws JavaModelException {
    403         throw new NotImplementedException();
    404     }
    405 
    406     public void save(IProgressMonitor progress, boolean force) throws JavaModelException {
    407         throw new NotImplementedException();
    408     }
    409 
    410 	public IJavaElement findElement(String bindingKey, WorkingCopyOwner owner)
    411 			throws JavaModelException {
    412         throw new NotImplementedException();
    413 	}
    414 }
    415