org.openide.filesystems.FileUtil.findBrother()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.openide.filesystems.FileUtil.findBrother()方法的一些代码示例,展示了FileUtil.findBrother()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.findBrother()方法的具体详情如下:
包路径:org.openide.filesystems.FileUtil
类名称:FileUtil
方法名:findBrother

FileUtil.findBrother介绍

[英]Finds brother file with same base name but different extension.
[中]查找基名称相同但扩展名不同的兄弟文件。

代码示例

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-io-javame

protected FileObject findPrimaryFile (FileObject fileObject) {
  String ext = fileObject.getExt ();
  if (EXT_DESIGN.equals (ext))
    return FileUtil.findBrother (fileObject, EXT_JAVA);
  if (EXT_JAVA.equals (ext))
    if (FileUtil.findBrother (fileObject, EXT_DESIGN) != null)
      return fileObject;
  return null;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-io-javame

public FileObject getDesignFile () {
  return FileUtil.findBrother(getPrimaryFile(), "vmd"); //NOI18N
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-io-javame

protected MultiDataObject createMultiObject (FileObject primaryFile) throws DataObjectExistsException, java.io.IOException {
  return new MEDesignDataObject (primaryFile, FileUtil.findBrother (primaryFile, EXT_DESIGN), this);
}

代码示例来源:origin: nl.cloudfarming.client/geometry-shape-type

@Override
protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
  List<FileObject> secondary = new ArrayList<>();
  for(String manditory : MANDITORY_EXT){
    FileObject found = FileUtil.findBrother(primaryFile, manditory);
    if(found != null){
      secondary.add(found);
    }
  }
  for(String optional : OPTIONAL_EXT){
    FileObject found = FileUtil.findBrother(primaryFile, optional);
    if(found != null){
      secondary.add(found);
    }
  }
  ShapeDataObject dataObject = new ShapeDataObject(primaryFile, this);
  dataObject.setSecondaryFiles(secondary);
  return dataObject;
}

代码示例来源:origin: nl.cloudfarming.client/field-shape-type

@Override
protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
  List<FileObject> secondary = new ArrayList<>();
  for(String manditory : MANDITORY_EXT){
    FileObject found = FileUtil.findBrother(primaryFile, manditory);
    if(found != null){
      secondary.add(found);
    }
  }
  for(String optional : OPTIONAL_EXT){
    FileObject found = FileUtil.findBrother(primaryFile, optional);
    if(found != null){
      secondary.add(found);
    }
  }
  ShapeDataObject dataObject = new ShapeDataObject(primaryFile, this);
  dataObject.setSecondaryFiles(secondary);
  return dataObject;
}

代码示例来源:origin: nl.cloudfarming.client/field-shape-type

@Override
protected FileObject findPrimaryFile(FileObject fo) {
  // never recognize folders.
  if (fo.isFolder()) {
    return null;
  }
  String ext = fo.getExt();
  // check if (secondary) file has one of the secondary extentions
  if (Arrays.binarySearch(MANDITORY_EXT, ext) >= 0 || Arrays.binarySearch(OPTIONAL_EXT, ext) >= 0 || Arrays.binarySearch(OPTIONAL_EXT, getDoubleExtension(fo)) >= 0 ) {
    LOGGER.log(Level.FINEST, "FileObject {0} has secondary extention, creating secondary entry and returing find brother with primary", fo);
    
    return FileUtil.findBrother(fo, PRIMARY_EXT);
  }
  FileObject shapeFile = findShapePrimaryFile(fo);
  // perform check if manditory brothers exist
  if (shapeFile != null) {
    for (String manditory : MANDITORY_EXT) {
      if (FileUtil.findBrother(shapeFile, manditory) == null) {
        LOGGER.log(Level.FINEST, "Failed to find brother manditory extention {0} for FileObject {1}", new Object[]{manditory, fo});
        return null;
      }
    }
    // all manditory extentions found
    return shapeFile;
  }
  LOGGER.log(Level.FINEST, "No primary file found for FileObject {0}", fo);
  return null;
}

代码示例来源:origin: nl.cloudfarming.client/geometry-shape-type

@Override
protected FileObject findPrimaryFile(FileObject fo) {
  // never recognize folders.
  if (fo.isFolder()) {
    return null;
  }
  String ext = fo.getExt();
  // check if (secondary) file has one of the secondary extentions
  if (Arrays.binarySearch(MANDITORY_EXT, ext) >= 0 || Arrays.binarySearch(OPTIONAL_EXT, ext) >= 0 || Arrays.binarySearch(OPTIONAL_EXT, getDoubleExtension(fo)) >= 0 ) {
    LOGGER.log(Level.FINEST, "FileObject {0} has secondary extention, creating secondary entry and returing find brother with primary", fo);
    
    return FileUtil.findBrother(fo, PRIMARY_EXT);
  }
  FileObject shapeFile = findShapePrimaryFile(fo);
  // perform check if manditory brothers exist
  if (shapeFile != null) {
    for (String manditory : MANDITORY_EXT) {
      if (FileUtil.findBrother(shapeFile, manditory) == null) {
        LOGGER.log(Level.FINEST, "Failed to find brother manditory extention {0} for FileObject {1}", new Object[]{manditory, fo});
        return null;
      }
    }
    // all manditory extentions found
    return shapeFile;
  }
  LOGGER.log(Level.FINEST, "No primary file found for FileObject {0}", fo);
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-wizards

@Override
  public void run() throws IOException {
    FileObject target = FileUtil.createData(getProject().getProjectDirectory(), path);
    if (tokens == null) {
      copyByteAfterByte(content, target);
    } else {
      copyAndSubstituteTokens(content, target, tokens);
    }
    // #129446: form editor doesn't work sanely unless you do this:
    if (target.hasExt("form")) { // NOI18N
      FileObject java = FileUtil.findBrother(target, "java"); // NOI18N
      if (java != null) {
        java.setAttribute("justCreatedByNewWizard", true); // NOI18N
      }
    } else if (target.hasExt("java") && FileUtil.findBrother(target, "form") != null) { // NOI18N
      target.setAttribute("justCreatedByNewWizard", true); // NOI18N
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd

@Override
public Set<DataObject> instantiate() throws IOException {
  TemplateWizard wiz = templateWizard;
  DataFolder targetFolder = wiz.getTargetFolder();
  DataObject template = wiz.getTemplate();
  String sourceFileName = wiz.getTargetName();
  FileObject sourceTemplate = template.files().iterator().next();
  Set<DataObject> res = new LinkedHashSet<DataObject>();
  FileObject bro = FileUtil.findBrother(sourceTemplate, "h"); // NOI18N
  if (bro != null) {
    DataObject dobjBro = DataObject.find(bro);
    String headerFileName = (String) wiz.getProperty("headerFileName"); // NOI18N
    DataFolder headerFolderName = (DataFolder) wiz.getProperty("headerFolder"); // NOI18N
    res.add(dobjBro.createFromTemplate(headerFolderName, headerFileName));
  } else {
    String errmsg = NbBundle.getMessage(CndClassWizardIterator.class, "MSG_missing_class_header_template", sourceTemplate.getName()+".h"); // NOI18N
    NotifyDescriptor.Message msg = new NotifyDescriptor.
      Message(errmsg, NotifyDescriptor.INFORMATION_MESSAGE);
    DialogDisplayer.getDefault().notify(msg);
  }
  res.add(template.createFromTemplate(targetFolder, sourceFileName ));
  return res;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-form-j2ee

FileObject formFile = FileUtil.findBrother(dob.getPrimaryFile(), "form"); // NOI18N

相关文章