本文整理汇总了Java中org.netbeans.api.editor.mimelookup.MimePath.validate方法的典型用法代码示例。如果您正苦于以下问题:Java MimePath.validate方法的具体用法?Java MimePath.validate怎么用?Java MimePath.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.editor.mimelookup.MimePath
的用法示例。
在下文中一共展示了MimePath.validate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInstance
import org.netbeans.api.editor.mimelookup.MimePath; //导入方法依赖的package包/类
public static PathRecognizer createInstance(Map fileAttributes) {
// path ids
Set<String> sourcePathIds = readIdsAttribute(fileAttributes, "sourcePathIds"); //NOI18N
Set<String> libraryPathIds = readIdsAttribute(fileAttributes, "libraryPathIds"); //NOI18N
Set<String> binaryLibraryPathIds = readIdsAttribute(fileAttributes, "binaryLibraryPathIds"); //NOI18N
// mime types
Set<String> mimeTypes = new HashSet<String>();
Object mts = fileAttributes.get("mimeTypes"); //NOI18N
if (mts instanceof String) {
String [] arr = ((String) mts).split(","); //NOI18N
for(String mt : arr) {
mt = mt.trim();
if (mt.length() > 0 && MimePath.validate(mt)) {
mimeTypes.add(mt);
} else {
LOG.log(Level.WARNING, "Invalid mimetype {0}, ignoring.", mt); //NOI18N
}
}
}
return new DefaultPathRecognizer(sourcePathIds, libraryPathIds, binaryLibraryPathIds, Collections.unmodifiableSet(mimeTypes));
}
示例2: CustomizerSelector
import org.netbeans.api.editor.mimelookup.MimePath; //导入方法依赖的package包/类
public CustomizerSelector(PreferencesFactory pf, boolean acceptOldControllers, String allowedMimeTypes) {
this.pf = pf;
this.acceptOldControllers = acceptOldControllers;
if (allowedMimeTypes != null) {
this.allowedMimeTypes = new HashSet<String>();
for(String mimeType : allowedMimeTypes.split(",")) { //NOI18N
mimeType = mimeType.trim();
if (MimePath.validate(mimeType)) {
this.allowedMimeTypes.add(mimeType);
} else {
LOG.warning("Ignoring invalid mimetype '" + mimeType + "'"); //NOI18N
}
}
} else {
this.allowedMimeTypes = null;
}
}
示例3: createActionsLookupResult
import org.netbeans.api.editor.mimelookup.MimePath; //导入方法依赖的package包/类
public static Lookup.Result<Action> createActionsLookupResult(String mimeType) {
if (!MimePath.validate(mimeType)) {
throw new IllegalArgumentException("Ïnvalid mimeType=\"" + mimeType + "\"");
}
Lookup lookup = Lookups.forPath(getPath(mimeType, "Actions"));
return lookup.lookupResult(Action.class);
}
示例4: getAccelerator
import org.netbeans.api.editor.mimelookup.MimePath; //导入方法依赖的package包/类
/**
* Get single-key accelerator for a given declared action.
* Only a single-key accelerators are supported.
*/
public static KeyStroke getAccelerator(FileObject fo) {
if (fo == null) {
throw new IllegalArgumentException("Must be called with non-null fileObject"); // NOI18N
}
boolean fineLoggable = LOG.isLoggable(Level.FINE);
String path = fo.getParent().getPath();
String actionName = (String) fo.getAttribute(Action.NAME);
KeyStroke ks = null;
if (path.startsWith("Editors/")) {
path = path.substring(7); // Leave ending '/' to support "Editors/Actions"
if (path.endsWith("/Actions")) {
path = path.substring(0, path.length() - 8);
if (path.startsWith("/")) {
path = path.substring(1);
}
String mimeType = path;
if (!MimePath.validate(mimeType)) {
LOG.info("Invalid mime-type='" + mimeType + "' of action's fileObject=" + fo); // NOI18N
}
ks = getAccelerator(mimeType, actionName);
} else if (fineLoggable) {
LOG.fine("No \"/Actions\" at end of mime-type='" + path +
"' of action's fileObject=" + fo); // NOI18N
}
} else if (fineLoggable) {
LOG.fine("No \"Editors/\" at begining of mime-type='" + path + // NOI18N
"' of action's fileObject=" + fo); // NOI18N
}
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("Accelerator for action \"" + actionName + "\" is " + ks);
}
return ks;
}
示例5: isValidType
import org.netbeans.api.editor.mimelookup.MimePath; //导入方法依赖的package包/类
private static boolean isValidType(FileObject typeFile) {
if (!typeFile.isFolder()) {
return false;
}
String typeName = typeFile.getNameExt();
return MimePath.validate(typeName, null);
}
示例6: isValidSubtype
import org.netbeans.api.editor.mimelookup.MimePath; //导入方法依赖的package包/类
private static boolean isValidSubtype(FileObject subtypeFile) {
if (!subtypeFile.isFolder()) {
return false;
}
String typeName = subtypeFile.getNameExt();
return MimePath.validate(null, typeName) && !typeName.equals("base"); //NOI18N
}
示例7: isValidSubtype
import org.netbeans.api.editor.mimelookup.MimePath; //导入方法依赖的package包/类
private static boolean isValidSubtype(FileObject subtypeFile) {
if (!subtypeFile.isFolder()) {
return false;
}
String typeName = subtypeFile.getNameExt();
return MimePath.validate(null, typeName);
}
示例8: findKit
import org.netbeans.api.editor.mimelookup.MimePath; //导入方法依赖的package包/类
private EditorKit findKit(String mimeType) {
if (!MimePath.validate(mimeType)) // #146276 - exclude invalid mime paths
return null;
Lookup lookup = MimeLookup.getLookup(MimePath.parse(mimeType));
EditorKit kit = (EditorKit) lookup.lookup(EditorKit.class);
return kit == null ? null : (EditorKit) kit.clone();
}
示例9: detectMimeType
import org.netbeans.api.editor.mimelookup.MimePath; //导入方法依赖的package包/类
private static String detectMimeType(FileObject f) {
String mimeType = f.getParent().getPath().substring("Editors/".length()); //NOI18N
return MimePath.validate(mimeType) && mimeType.length() > 0 ? mimeType : null;
}