// 
//     Licensed to the Apache Software Foundation (ASF) under one
//     or more contributor license agreements.  See the NOTICE file
//     distributed with this work for additional information
//     regarding copyright ownership.  The ASF licenses this file
//     to you under the Apache License, Version 2.0 (the
//     "License"); you may not use this file except in compliance
//     with the License.  You may obtain a copy of the License at
// 
//       http://www.apache.org/licenses/LICENSE-2.0
// 
//     Unless required by applicable law or agreed to in writing,
//     software distributed under the License is distributed on an
//     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//     KIND, either express or implied.  See the License for the
//     specific language governing permissions and limitations
//     under the License.
//

= DevFaqFileAttributes
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqFileAttributes
:description: Apache NetBeans wiki DevFaqFileAttributes
:toc: left
:toc-title:
:syntax: true

== What are File Attributes?

link:DevFaqFileObject.asciidoc[FileObjects] have _attributes_.  These are ad-hoc key-value
pairs which can be associated with a file and persist across shutdown and restart.

Attributes are routinely used in the link:DevFaqModulesLayerFile.asciidoc[module XML files] which define the initial contents of the link:DevFaqSystemFilesystem.asciidoc[system filesystem].  They are used to providing additional configuration data for files, such as declaring sorting order or the path to an icon file.

Attributes are perfectly safe to use freely in `layer.xml` files.

In pre-4.0 NetBeans, they were relatively commonly used for user files on disk.  They still may be used for user files, but this is now discouraged - the infrastructure has been changed to store all attributes in the link:DevFaqUserDir.asciidoc[userdir] rather than sprinking `.nbattrs` files in directories all over the user's disk.  Since they are now stored in a central location, the more attributes there are, the longer it takes to find attributes for any given file.  Using attributes for user files _on disk_ has negative performance implications.

See `link:http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/FileObject.html#getAttribute(java.lang.String)[FileObject.getAttribute]` and
`link:http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/FileObject.html#setAttribute(java.lang.String,%20java.lang.Object)[FileObject.setAttribute]`.

== Apache Migration Information

The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.

This page was exported from link:http://wiki.netbeans.org/DevFaqFileAttributes[http://wiki.netbeans.org/DevFaqFileAttributes] , 
that was last modified by NetBeans user Tboudreau 
on 2010-02-19T01:50:59Z.


*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.
