| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 package com.google.dart.runner; | |
| 6 | |
| 7 import com.google.dart.compiler.DartSource; | |
| 8 import com.google.dart.compiler.LibrarySource; | |
| 9 import com.google.dart.compiler.UrlDartSource; | |
| 10 import com.google.dart.compiler.UrlSource; | |
| 11 | |
| 12 import java.net.URISyntaxException; | |
| 13 | |
| 14 class BundleLibrarySource extends UrlSource implements LibrarySource { | |
| 15 | |
| 16 private final class BundleDartSource extends UrlDartSource { | |
| 17 private BundleDartSource(ClassLoader loader, String basePath, String filenam
e) | |
| 18 throws URISyntaxException { | |
| 19 super(loader.getResource(basePath + filename).toURI(), filename, BundleLib
rarySource.this); | |
| 20 } | |
| 21 | |
| 22 @Override | |
| 23 public String getName() { | |
| 24 return basePath + getRelativePath(); | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 private final ClassLoader loader; | |
| 29 private final String basePath; | |
| 30 private final String filename; | |
| 31 | |
| 32 public BundleLibrarySource(ClassLoader loader, String basePath, String filenam
e) | |
| 33 throws URISyntaxException { | |
| 34 super(loader.getResource(basePath + filename).toURI()); | |
| 35 this.loader = loader; | |
| 36 this.basePath = basePath; | |
| 37 this.filename = filename; | |
| 38 } | |
| 39 | |
| 40 @Override | |
| 41 public LibrarySource getImportFor(String relPath) { | |
| 42 try { | |
| 43 return new BundleLibrarySource(loader, basePath, relPath); | |
| 44 } catch (URISyntaxException e) { | |
| 45 return null; | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 @Override | |
| 50 public DartSource getSourceFor(String relPath) { | |
| 51 try { | |
| 52 return new BundleDartSource(loader, basePath, relPath); | |
| 53 } catch (URISyntaxException e) { | |
| 54 return null; | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 @Override | |
| 59 public String getName() { | |
| 60 return basePath + filename; | |
| 61 } | |
| 62 } | |
| OLD | NEW |