1 19 20 package org.netbeans.api.editor.mimelookup; 21 22 import org.netbeans.modules.editor.mimelookup.MimePathLookup; 23 import org.openide.util.Lookup; 24 import org.openide.util.Lookup.Result; 25 import org.openide.util.Lookup.Template; 26 27 72 public final class MimeLookup extends Lookup { 73 74 private MimePathLookup mimePathLookup; 75 76 85 public static Lookup getLookup(MimePath mimePath) { 86 if (mimePath == null) { 87 throw new NullPointerException ("The mimePath parameter must not be null."); } 89 90 return mimePath.getLookup(); 91 } 92 93 100 public static MimeLookup getMimeLookup(String mimeType) { 101 if (mimeType == null) { 102 throw new NullPointerException ("The mimeType parameter must not be null."); } 104 105 return new MimeLookup(MimePath.get(mimeType).getLookup()); 106 } 107 108 115 private MimeLookup(MimePathLookup lookup) { 116 this.mimePathLookup = lookup; 117 } 118 119 131 public MimeLookup childLookup(String mimeType) { 132 if (mimeType == null) { 133 throw new NullPointerException ("The mimeType parameter must not be null."); } 135 136 MimePath mimePath = MimePath.get(mimePathLookup.getMimePath(), mimeType); 137 return new MimeLookup(mimePath.getLookup()); 138 } 139 140 150 public <T> T lookup(Class <T> clazz) { 151 return mimePathLookup.lookup(clazz); 152 } 153 154 163 public <T> Result<T> lookup(Template<T> template) { 164 return mimePathLookup.lookup(template); 165 } 166 167 } 168 | Popular Tags |