Java Code Examples for org.openide.filesystems.FileObject.getExt()

The following are Jave code examples for showing how to use getExt() of the org.openide.filesystems.FileObject class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: DBSchemaManager.java   Source Code and License Vote up 6 votes
/**
 * Overwrites <code>dbschemaFile</code> with the contents of
 * <code>schemaElement</code>.
 */
private static void overwriteDBSchema(SchemaElement schemaElement, FileObject dbschemaFile, DBIdentifier dbschemaName) throws IOException {
    try {
        schemaElement.setName(dbschemaName);
    } catch (DBException e) {
        IOException ioe = new IOException(e);
        throw ioe;
    }

    // cannot just overwrite the file, DBSchemaDataObject would not
    // notice the file has changed.
    FileObject parent = dbschemaFile.getParent();
    String fileName = dbschemaFile.getName();
    String fileExt = dbschemaFile.getExt();
    dbschemaFile.delete();
    FileObject newDBSchemaFile = parent.createData(fileName, fileExt);

    writeSchemaElement(schemaElement, newDBSchemaFile);
}
 
Example 2
Project: incubator-netbeans   File: EncodedReaderFactory.java   Source Code and License Vote up 6 votes
private Reader getReader(FileObject fo, String encoding, FileObject type, String secondFileExt) throws FileNotFoundException {
    if (encoding != null) {
        try {
            return new InputStreamReader(fo.getInputStream(), encoding);
        } catch (UnsupportedEncodingException ueex) {
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ueex);
        }
    }
    Reader r = null;
    String ext = type.getExt();
    if (!"java".equalsIgnoreCase(ext) || !ext.equals(secondFileExt)) {// We read the encoding for Java files explicitely
                                        // If it's not defined, read with default encoding from stream (because of guarded blocks)
                                        // But when the extensions of the two files are different (comparing Java files with something else),
                                        // we have to use the Document approach for both due to possible different line-endings.
        r = getReaderFromEditorSupport(fo, type);
        if (r == null) {
            r = getReaderFromKit(null, fo, type.getMIMEType());
        }
    }
    if (r == null) {
        // Fallback, use current encoding
        r = new InputStreamReader(fo.getInputStream());
    }
    return r;
}
 
Example 3
Project: netbeans-textlint-plugin   File: RefreshAction.java   Source Code and License Vote up 6 votes
@Override
public Action createContextAwareInstance(Lookup lookup) {
    String textlintPath = TextlintOptions.getInstance().getTextlintPath();
    if (textlintPath == null || textlintPath.isEmpty()) {
        OptionsDisplayer.getDefault().open(TextlintOptionsPanelController.OPTIONS_FULL_PATH);
        return this;
    }
    DataObject dataObject = lookup.lookup(DataObject.class);
    if (dataObject == null) {
        return this;
    }
    FileObject fileObject = dataObject.getPrimaryFile();
    if (fileObject == null) {
        return this;
    }
    String ext = fileObject.getExt();
    if ("md".equals(ext) || "txt".endsWith(ext) // NOI18N
            || ("html".equals(ext) && TextlintOptions.getInstance().isHtmlEnabled())) { // NOI18N
        return new RefreshAction(dataObject);
    }
    return this;
}
 
Example 4
Project: incubator-netbeans   File: FolderComparator.java   Source Code and License Vote up 6 votes
/** for sorting folders first and then by extensions and then by names */
private int compareExtensions(Object o1, Object o2) {
    FileObject obj1 = findFileObject(o1);
    FileObject obj2 = findFileObject(o2);

    boolean folder1 = obj1.isFolder();
    boolean folder2 = obj2.isFolder();

    if (folder1 != folder2) {
        return folder1 ? -1 : 1; // folders first
    } else if (folder1) { // && folder2
        return obj1.getNameExt().compareTo(obj2.getNameExt()); // by nameExt
    } else {
        String ext1 = obj1.getExt();
        String ext2 = obj2.getExt();
        if (ext1.equals(ext2)) { // same extensions
            return obj1.getName().compareTo(obj2.getName()); // by name
        } else { // different extensions
            return ext1.compareTo(ext2); // by extension
        }
    }
}
 
Example 5
Project: incubator-netbeans   File: FightWithWrongOrderOfLoadersTest.java   Source Code and License Vote up 6 votes
protected FileObject findPrimaryFile(FileObject fo)
{
    LOG.info("FormKitDataLoader.findPrimaryFile(): " + fo.getNameExt());
    cnt++;

    String ext = fo.getExt();
    if (ext.equals(FORM_EXTENSION))
    {
        return FileUtil.findBrother(fo, JAVA_EXTENSION);
    }
    if (ext.equals(JAVA_EXTENSION) && FileUtil.findBrother(fo, FORM_EXTENSION) != null)
    {
        return fo;
    }
    return null;
}
 
Example 6
Project: incubator-netbeans   File: FileObjectInLookupByMatteoTest.java   Source Code and License Vote up 6 votes
@Override
protected FileObject findPrimaryFile(FileObject fo) {

    if (fo.isFolder()) {
        return null;
    }

    // check if it's itself the primary file
    String ext = fo.getExt();
    if (ext.equalsIgnoreCase(PRIMARY_EXTENSION)) {
        return fo;
    }

    // check if it's a secondary entry
    String completeFileName = fo.getNameExt();
    Matcher m = SECONDARY_PATTERN.matcher(completeFileName);
    if (m.find()) {
        String primaryName = m.group(1);
        FileObject primaryFO = fo.getParent().getFileObject(primaryName, PRIMARY_EXTENSION);
        return primaryFO;
    }

    return null;
}
 
Example 7
Project: incubator-netbeans   File: MultiDataObjectDeleteSecondaryEntryTest.java   Source Code and License Vote up 6 votes
@Override
protected FileObject findPrimaryFile(FileObject fo)
{
    LOG.info("FXKitDataLoader.findPrimaryFile(): " + fo.getNameExt());
    cnt++;

    String ext = fo.getExt();
    if (ext.equals(FX_EXT))
    {
        return FileUtil.findBrother(fo, JAVA_EXTENSION);
    }
    if (ext.equals(JAVA_EXTENSION) && FileUtil.findBrother(fo, FX_EXT) != null)
    {
        return fo;
    }
    return null;
}
 
Example 8
Project: incubator-netbeans   File: FormDataLoader.java   Source Code and License Vote up 5 votes
/** For a given file finds a primary file.
    * @param fo the file to find primary file for
    *
    * @return the primary file for the file or null if the file is not
    *   recognized by this loader
    */
   @Override
   protected FileObject findPrimaryFile(FileObject fo) {
// never recognize folders.
       if (fo.isFolder()) return null;
       String ext = fo.getExt();
       if (ext.equals(FORM_EXTENSION))
           return FileUtil.findBrother(fo, JAVA_EXTENSION);

       FileObject javaFile = findJavaPrimaryFile(fo);
       return javaFile != null
                   && FileUtil.findBrother(javaFile, FORM_EXTENSION) != null ?
           javaFile : null;
   }
 
Example 9
Project: incubator-netbeans   File: BaseFileObjectTestHid.java   Source Code and License Vote up 5 votes
private void testComposeNameImpl(FileObject fo) throws IOException {
    assertTrue(fo.isValid() && fo.isData());
    String fullName = fo.getNameExt();
    String ext = fo.getExt();
    String name = fo.getName();
    FileObject parent = fo.getParent();
    fo.delete();
    FileObject fo2 = parent.createData(name, ext);
    assertEquals(fullName, fo2.getNameExt());
    assertEquals(name, fo2.getName());
    assertEquals(ext, fo2.getExt());
}
 
Example 10
Project: incubator-netbeans   File: BiNode.java   Source Code and License Vote up 5 votes
public static Node createNoSourceNode(FileObject bi) {
    String name = bi.getName();
    name = name.substring(0, name.length() - "BeanInfo".length()); // NOI18N
    String ext = bi.getExt();
    if (ext.length() > 0) {
        name += '.' + ext;
    }
    String msg = NbBundle.getMessage(BiNode.class, "CTL_NODE_MissingBeanFile", name);
    return new Error(msg);
}
 
Example 11
Project: incubator-netbeans   File: XMLPropertiesConvertorTest.java   Source Code and License Vote up 5 votes
/** Test whether instances survive garbage collection.
 */
public void testSameWithGC () throws Exception {
    FileObject tsFO = root.createFolder("testSameWithGC");
    assertNotNull("folder 'testSameWithGC' is not created!", tsFO);
    DataFolder folder = (DataFolder) DataObject.find(tsFO).getCookie(DataFolder.class);
    assertNotNull("missing data folder" + folder);
    
    FooSetting ser = new FooSetting("testSameWithGC");
    
    FileObject prim = InstanceDataObject.create (folder, "MyName", ser, null).getPrimaryFile ();
    String name = prim.getName ();
    String ext = prim.getExt ();
    prim = null;

    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    
    FileObject fo = folder.getPrimaryFile ().getFileObject (name, ext);
    assertNotNull ("MyName.settings not found", fo);
    
    DataObject obj = DataObject.find (fo);
    
    InstanceCookie.Of ic = (InstanceCookie.Of) obj.getCookie(InstanceCookie.Of.class);
    assertNotNull (obj + " does not contain instance cookie", ic);
    
    assertTrue("instanceOf failed", ic.instanceOf(ser.getClass()));
    assertEquals("instanceClass", ser.getClass(), ic.instanceClass());
    
    Object value = ic.instanceCreate ();
    assertEquals("Value is different from stored one", System.identityHashCode(ser), System.identityHashCode(value));
}
 
Example 12
Project: incubator-netbeans   File: DataObjectSaveAsTest.java   Source Code and License Vote up 5 votes
public void testSaveAsOverwriteExisting() throws IOException {
    FileObject fo = obj2.getPrimaryFile();
    String newName = fo.getName();
    String newExt = fo.getExt();
    DataFolder folder = DataFolder.findFolder( fo.getParent() );
    
    try {
        obj1.copyRename( folder, newName, newExt );
        fail( "default implementation of copyRename cannot overwrite existing files" );
    } catch( IOException e ) {
        //this is what we want
    }
    
    sfs.assertEvent(obj1, 0, null);
}
 
Example 13
Project: incubator-netbeans   File: FileNameMatcher.java   Source Code and License Vote up 4 votes
@Override
public boolean pathMatches(FileObject fileObject) {
    String fileExt = fileObject.getExt();
    return fileExt != null && fileExt.equalsIgnoreCase(ext);
}
 
Example 14
Project: incubator-netbeans   File: ScriptingCreateFromTemplateHandler.java   Source Code and License Vote up 4 votes
@Override
public List<FileObject> createFromTemplate(CreateDescriptor desc) throws IOException {
    FileObject template = desc.getTemplate();
    String name = desc.getProposedName();
    Map<String, ?> values = desc.getParameters();
    FileObject f = desc.getTarget();
    
    boolean noExt = desc.hasFreeExtension() && name.indexOf('.') != -1;
    
    String extWithDot;
    if (noExt) {
        extWithDot = null;
    } else {
        extWithDot = '.' + template.getExt();
        if (name.endsWith(extWithDot)) { // Test whether the extension happens to be there already
            // And remove it if yes, it will be appended to the unique name.
            name = name.substring(0, name.length() - extWithDot.length());
        }
    }
    
    String nameUniq = FileUtil.findFreeFileName(f, name, noExt ? null : template.getExt());
    FileObject output = FileUtil.createData(f, noExt ? nameUniq : nameUniq + extWithDot);
    Charset targetEnc = FileEncodingQuery.getEncoding(output);
    Charset sourceEnc = FileEncodingQuery.getEncoding(template);
    
    ScriptEngine eng = engine(template);
    Bindings bind = eng.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
    bind.putAll(values);
    
    if(!values.containsKey(ENCODING_PROPERTY_NAME)) {
        bind.put(ENCODING_PROPERTY_NAME, targetEnc.name());
    }
    
    //Document doc = createDocument(template.getMIMEType());
    FileLock lock = output.lock();
    try (Writer w = new OutputStreamWriter(output.getOutputStream(lock), targetEnc);
         Reader is = new InputStreamReader(template.getInputStream(), sourceEnc);
        /*IndentWriter w2 = new IndentWriter(doc, 0, w, false) */) {
        StringWriter sw = new StringWriter();
        ScriptEngine eng2 = desc.isPreformatted() ? null : indentEngine();
        
        eng.getContext().setWriter(new PrintWriter(eng2 != null ? sw : w));
        //eng.getContext().setBindings(bind, ScriptContext.ENGINE_SCOPE);
        eng.getContext().setAttribute(FileObject.class.getName(), template, ScriptContext.ENGINE_SCOPE);
        eng.getContext().setAttribute(ScriptEngine.FILENAME, template.getNameExt(), ScriptContext.ENGINE_SCOPE);
        eng.eval(is);
        
        if (eng2 != null) {
            eng2.getContext().setAttribute("mimeType", template.getMIMEType(), ScriptContext.ENGINE_SCOPE);
            eng2.getContext().setWriter(w);
            eng2.eval(new StringReader(sw.toString()));
        }
    }catch (ScriptException ex) {
        IOException io = new IOException(ex.getMessage(), ex);
        throw io;
    } finally {
        lock.releaseLock();
    }
    return Collections.singletonList(output);
}
 
Example 15
Project: incubator-netbeans   File: VirtualSourceProviderQuery.java   Source Code and License Vote up 4 votes
public static boolean hasVirtualSource (final FileObject file) {
    Parameters.notNull("file", file);
    final String ext = file.getExt();
    return getExt2ProvMap().keySet().contains(ext);
}
 
Example 16
Project: incubator-netbeans   File: CategoryNode.java   Source Code and License Vote up 4 votes
/** Converts category name to name that can be used as name of folder
 * for the category (restricted even to package name).
 */ 
static String convertCategoryToFolderName( FileObject paletteFO, 
                                                   String name,
                                                   String currentName)
{
    if (name == null || "".equals(name)) // NOI18N
        return null;

    int i;
    int n = name.length();
    StringBuffer nameBuff = new StringBuffer(n);

    char ch = name.charAt(0);
    if (Character.isJavaIdentifierStart(ch)) {
        nameBuff.append(ch);
        i = 1;
    }
    else {
        nameBuff.append('_');
        i = 0;
    }

    while (i < n) {
        ch = name.charAt(i);
        if (Character.isJavaIdentifierPart(ch))
            nameBuff.append(ch);
        i++;
    }

    String fName = nameBuff.toString();
    if ("_".equals(fName)) // NOI18N
        fName = "Category"; // NOI18N
    if (fName.equals(currentName))
        return fName;

    // having the base name, make sure it is not used yet
    String freeName = null;
    boolean nameOK = false;

    for (i=0; !nameOK; i++) {
        freeName = i > 0 ? fName + "_" + i : fName; // NOI18N

        if (Utilities.isWindows()) {
            nameOK = true;
            java.util.Enumeration en = paletteFO.getChildren(false);
            while (en.hasMoreElements()) {
                FileObject fo = (FileObject)en.nextElement();
                String fn = fo.getName();
                String fe = fo.getExt();

                // case-insensitive on Windows
                if ((fe == null || "".equals(fe)) && fn.equalsIgnoreCase(freeName)) { // NOI18N
                    nameOK = false;
                    break;
                }
            }
        }
        else nameOK = paletteFO.getFileObject(freeName) == null;
    }
    return freeName;
}
 
Example 17
Project: incubator-netbeans   File: HtmlRenameRefactoringPlugin.java   Source Code and License Vote up 4 votes
private void refactorFile(FileObject file, ModificationResult modificationResult, HtmlIndex index) {
    //refactor a file in explorer
    LOGGER.fine("refactor file " + file.getPath()); //NOI18N
    String newName = refactoring.getNewName();

    //a. get all importing files
    //b. rename the references
    //c. rename the file itself - done via default rename plugin
    DependenciesGraph deps = index.getDependencies(file);
    if(deps == null) {
        return ; //exception should be logged in index.getDependencies()
    }
    Collection<Node> allRefering = deps.getSourceNode().getReferingNodes();

    for (Node ref : allRefering) {
        FileObject refering = ref.getFile();
        try {
            Source source;
            CloneableEditorSupport editor = GsfUtilities.findCloneableEditorSupport(refering);
            //prefer using editor
            //XXX this approach doesn't match the dependencies graph
            //which is made strictly upon the index data
            if (editor != null && editor.isModified()) {
                source = Source.create(editor.getDocument());
            } else {
                source = Source.create(refering);
            }

            HtmlFileModel model = new HtmlFileModel(source);

            List<Difference> diffs = new ArrayList<>();
            for (Entry entry : model.getReferences()) {
                String imp = entry.getName(); //unquoted
                FileObject resolvedFileObject = WebUtils.resolve(refering, imp);
                if (resolvedFileObject != null && resolvedFileObject.equals(file)) {
                    //the import refers to me - lets refactor it
                    if (entry.isValidInSourceDocument()) {
                        //new relative path creation
                        String newImport;
                        String extension = file.getExt(); //use the same extension as source file
                        int slashIndex = imp.lastIndexOf('/'); //NOI18N
                        if (slashIndex != -1) {
                            newImport = imp.substring(0, slashIndex) + "/" + newName + "." + extension; //NOI18N
                        } else {
                            newImport = newName + "." + extension; //NOI18N
                        }

                        diffs.add(new Difference(Difference.Kind.CHANGE,
                                editor.createPositionRef(entry.getDocumentRange().getStart(), Bias.Forward),
                                editor.createPositionRef(entry.getDocumentRange().getEnd(), Bias.Backward),
                                entry.getName(),
                                newImport,
                                NbBundle.getMessage(HtmlRenameRefactoringPlugin.class, "MSG_Modify_File_Import"))); //NOI18N
                    }
                }
            }

            if(!diffs.isEmpty()) {
                modificationResult.addDifferences(refering, diffs);
            }

        } catch (ParseException ex) {
            Exceptions.printStackTrace(ex);
        }

    }
}
 
Example 18
Project: incubator-netbeans   File: Util.java   Source Code and License Vote up 4 votes
/**
     * Create new DataObject with requested locale and notify that new locale was added
     * @param propertiesDataObject DataObject to add locale
     * @param locale
     * @param copyInitialContent
     */
    public static void createLocaleFile(PropertiesDataObject propertiesDataObject,
                                        String locale,
                                        boolean copyInitialContent)
    {
        try {
            if(locale.length() == 0) {
                // It would mean default locale to create again.
                notifyError(locale);
                return;
            }

            if(propertiesDataObject != null) {
//                FileObject file = propertiesDataObject.getPrimaryFile();
                FileObject file = propertiesDataObject.getBundleStructure().getNthEntry(0).getFile();
                String extension = PropertiesDataLoader.PROPERTIES_EXTENSION;
                if (!file.hasExt(extension)) {
                    if (file.getMIMEType().equalsIgnoreCase(PropertiesDataLoader.PROPERTIES_MIME_TYPE))
                        extension = file.getExt();
                }
                //Default locale may be deleted
                final String newName = getBaseName(file.getName()) + PropertiesDataLoader.PRB_SEPARATOR_CHAR + locale;
                final FileObject folder = file.getParent();
//                                    final PropertiesEditorSupport editor = (PropertiesEditorSupport)propertiesDataObject.getCookie(PropertiesEditorSupport.class);
                java.util.Iterator it = propertiesDataObject.secondaryEntries().iterator();
                while (it.hasNext()) {
                    FileObject f = ((FileEntry)it.next()).getFile();
                    if (newName.startsWith(f.getName()) && f.getName().length() > file.getName().length())
                        file = f;
                }
                if (file.getName().equals(newName)) {
                    return; // do nothing if the file already exists
                }

                if (copyInitialContent) {
                    if (folder.getFileObject(newName, extension) == null) {
                        SaveCookie save = (SaveCookie) propertiesDataObject.getCookie(SaveCookie.class);
                        if (save != null) {
                            save.save();
                        }
                        final FileObject templateFile = file;
                        final String ext = extension;
                        folder.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
                            public void run() throws IOException {
                                templateFile.copy(folder, newName, ext);
                            }
                        });
                        //find just created DataObject
                        PropertiesDataObject dataObject = (PropertiesDataObject) DataObject.find(folder.getFileObject(newName, extension));
                        dataObject.setBundleStructure(propertiesDataObject.getBundleStructure());
                        //update entries in BundleStructure
                        propertiesDataObject.getBundleStructure().updateEntries();
                        //Add it to OpenSupport
                        propertiesDataObject.getOpenSupport().addDataObject(dataObject);
                        //Notify BundleStructure that one file changed
                        propertiesDataObject.getBundleStructure().notifyOneFileChanged(folder.getFileObject(newName, extension));
                    }
                } else {
                    // Create an empty file - creating from template via DataObject
                    // API would create a separate DataObject for the locale file.
                    // After creation force the DataObject to refresh its entries.
                    DataObject.find(folder.createData(newName, extension));
                    //update entries in BundleStructure
                    propertiesDataObject.getBundleStructure().updateEntries();
                }
            }
        } catch(IOException ioe) {
            if(Boolean.getBoolean("netbeans.debug.exceptions")) // NOI18N
                ioe.printStackTrace();

            notifyError(locale);
        }
    }
 
Example 19
Project: incubator-netbeans   File: Util.java   Source Code and License Vote up 4 votes
/**
 *
 * @param f
 * @param parent Directory where to search
 * @param baseName of the locale (name without locale suffix)
 * @return BundleStructure or null 
 * @throws org.openide.loaders.DataObjectNotFoundException
 */
static BundleStructure findBundleStructure (FileObject f, FileObject parent, String baseName) throws DataObjectNotFoundException{
        String fName;
        PropertiesDataObject dataObject = null;
        BundleStructure structure;
        String extension = PropertiesDataLoader.PROPERTIES_EXTENSION;
        if (!f.hasExt(extension)) {
            if (f.getMIMEType().equalsIgnoreCase(PropertiesDataLoader.PROPERTIES_MIME_TYPE))
                extension = f.getExt();
        }
        for (FileObject file : parent.getChildren()) {
            if (!file.hasExt(extension) || file.equals(f)) {
                continue;
            }
            fName = file.getName();
            if (fName.equals(baseName) && file.isValid()) {
                    dataObject = (PropertiesDataObject) DataObject.find(file);
                    if (dataObject == null) continue;
                    structure = dataObject.getBundleStructureOrNull();
                    if (structure != null)
                         return structure;
                    else
                         continue;
            }
            if (fName.indexOf(baseName) != -1) {
                int index = fName.indexOf(PropertiesDataLoader.PRB_SEPARATOR_CHAR);
                if (baseName.length()!=index)
                    continue;
                while (index != -1) {
                    FileObject candidate = file;
                    if (candidate != null && isValidLocaleSuffix(fName.substring(index)) && file.isValid()) {
                        DataObject defaultDataObject = DataObject.find(candidate);
                        if (defaultDataObject instanceof PropertiesDataObject) {
                            dataObject = (PropertiesDataObject) DataObject.find(candidate);
                        } else {
                            index = -1;
                        }
                        if (dataObject == null) continue;
                        structure = dataObject.getBundleStructureOrNull();
                        if (structure != null) 
                            return structure;
                    }
                    index = fName.indexOf(PropertiesDataLoader.PRB_SEPARATOR_CHAR, index + 1);
                }
            }
        }
        return null;
}
 
Example 20
Project: incubator-netbeans   File: MultiBundleStructure.java   Source Code and License Vote up 4 votes
/**
     * Find entries according to PropertiesDataObject
     *
     */
    private synchronized void findEntries() {
//        try {
            if (obj != null) {
                if (!obj.isValid()) {
                    primaryEntry = null;
                    if (files!=null && files.length == 1) {
                        obj = null;
                        files = null;
                        return;
                    }
                } else {
//                    obj = Util.findPrimaryDataObject(obj);
                    primaryEntry = (PropertiesFileEntry) obj.getPrimaryEntry();
                }
            } else {
                return;
            }
            if (primaryEntry != null) {
                FileObject primary = primaryEntry.getFile();
                if(!primary.hasExt(extension)) {
                    if (primary.getMIMEType().equalsIgnoreCase(PropertiesDataLoader.PROPERTIES_MIME_TYPE))
                        extension = primary.getExt();
                }
                parent = primary.getParent();
            } else {
                if (parent == null) {
                    return;
                }
            }
            List<FileObject> listFileObjects = new ArrayList<FileObject>();
            String fName;
            FileObject oldCandidate;
            for (FileObject file : parent.getChildren()) {
                if (!file.hasExt(extension) || !file.getMIMEType().equalsIgnoreCase(PropertiesDataLoader.PROPERTIES_MIME_TYPE)) {
                    continue;
                }
                fName = file.getName();
                if (fName.equals(baseName) && file.isValid()) {
                    listFileObjects.add(0,file);
                }
                if (fName.indexOf(baseName) != -1) {
                    int index = fName.indexOf(PropertiesDataLoader.PRB_SEPARATOR_CHAR, baseName.length() - 1);
                    if (index == baseName.length()) {
                         if (file != null && isValidLocaleSuffix(fName.substring(index)) && file.isValid()) {
                            listFileObjects.add(file);
                        }
                    }
                }
            }
            if (listFileObjects.isEmpty()) {
                // a fallback if no other entries found
                files = new FileObject[] {obj.getPrimaryFile()};
                return;
            }
            files = listFileObjects.toArray(new FileObject[listFileObjects.size()]);
            if (primaryEntry != getNthEntry(0)) {
                //TODO XXX This means that primaryEntry has changed, so need to notify openSupport
                primaryEntry = getNthEntry(0);
                if (primaryEntry != null) {
                    notifyOneFileChanged(primaryEntry.getFile());
                    if(!primaryEntry.getFile().hasExt(extension)) {
                        if (primaryEntry.getFile().getMIMEType().equalsIgnoreCase(PropertiesDataLoader.PROPERTIES_MIME_TYPE))
                            extension = primaryEntry.getFile().getExt();
                    }
                    parent = primaryEntry.getFile().getParent();
                    obj = (PropertiesDataObject) primaryEntry.getDataObject();
                    baseName = Util.getBaseName(obj.getName());
                }
            }
//        } catch (DataObjectNotFoundException ex) {
//            Exceptions.printStackTrace(ex);
//        }
    }