comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java @ 22219:1c0f490984d5

Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Wed, 16 Sep 2015 15:36:22 -0700
parents dc83cc1f94f2 f47b601edbc6
children b56fe0d3b560
comparison
equal deleted inserted replaced
22160:0599e2df6a9f 22219:1c0f490984d5
22 * or visit www.oracle.com if you need additional information or have any 22 * or visit www.oracle.com if you need additional information or have any
23 * questions. 23 * questions.
24 */ 24 */
25 package com.oracle.truffle.api.source; 25 package com.oracle.truffle.api.source;
26 26
27 import com.oracle.truffle.api.CompilerAsserts;
28 import com.oracle.truffle.api.TruffleLanguage.Registration;
29 import java.io.BufferedReader; 27 import java.io.BufferedReader;
30 import java.io.ByteArrayInputStream; 28 import java.io.ByteArrayInputStream;
31 import java.io.File; 29 import java.io.File;
32 import java.io.FileInputStream; 30 import java.io.FileInputStream;
33 import java.io.FileNotFoundException; 31 import java.io.FileNotFoundException;
51 import java.util.HashMap; 49 import java.util.HashMap;
52 import java.util.List; 50 import java.util.List;
53 import java.util.Map; 51 import java.util.Map;
54 import java.util.logging.Level; 52 import java.util.logging.Level;
55 import java.util.logging.Logger; 53 import java.util.logging.Logger;
54
55 import com.oracle.truffle.api.CompilerAsserts;
56 import com.oracle.truffle.api.TruffleLanguage.Registration;
56 57
57 /** 58 /**
58 * Representation of a guest language source code unit and its contents. Sources originate in 59 * Representation of a guest language source code unit and its contents. Sources originate in
59 * several ways: 60 * several ways:
60 * <ul> 61 * <ul>
423 */ 424 */
424 public abstract String getPath(); 425 public abstract String getPath();
425 426
426 /** 427 /**
427 * The URL if the source is retrieved via URL. 428 * The URL if the source is retrieved via URL.
428 * 429 *
429 * @return URL or <code>null</code> 430 * @return URL or <code>null</code>
430 */ 431 */
431 public abstract URL getURL(); 432 public abstract URL getURL();
432 433
433 /** 434 /**
907 String findMimeType() { 908 String findMimeType() {
908 if (file.getName().endsWith(".c")) { 909 if (file.getName().endsWith(".c")) {
909 return "text/x-c"; 910 return "text/x-c";
910 } else if (file.getName().endsWith(".R") || file.getName().endsWith(".r")) { 911 } else if (file.getName().endsWith(".R") || file.getName().endsWith(".r")) {
911 return "application/x-r"; 912 return "application/x-r";
913 } else if (file.getName().endsWith(".js") || file.getName().endsWith(".JS")) {
914 return "application/javascript";
912 } else { 915 } else {
913 try { 916 try {
914 return Files.probeContentType(file.toPath()); 917 return Files.probeContentType(file.toPath());
915 } catch (IOException ex) { 918 } catch (IOException ex) {
916 LOG.log(Level.SEVERE, null, ex); 919 LOG.log(Level.SEVERE, null, ex);
995 String findMimeType() { 998 String findMimeType() {
996 if (file.getName().endsWith(".c")) { 999 if (file.getName().endsWith(".c")) {
997 return "text/x-c"; 1000 return "text/x-c";
998 } else if (file.getName().endsWith(".R") || file.getName().endsWith(".r")) { 1001 } else if (file.getName().endsWith(".R") || file.getName().endsWith(".r")) {
999 return "application/x-r"; 1002 return "application/x-r";
1003 } else if (file.getName().endsWith(".js") || file.getName().endsWith(".JS")) {
1004 return "application/javascript";
1000 } else { 1005 } else {
1001 try { 1006 try {
1002 return Files.probeContentType(file.toPath()); 1007 return Files.probeContentType(file.toPath());
1003 } catch (IOException ex) { 1008 } catch (IOException ex) {
1004 LOG.log(Level.SEVERE, null, ex); 1009 LOG.log(Level.SEVERE, null, ex);