@Override public void loadContent( final Properties properties ) { content.clear(); for ( final Map.Entry<String, Object> attr : properties.entrySet() ) { content.put( attr.getKey(), attr.getValue() ); } }
private synchronized Properties buildProperties( boolean includesNonSerializable ) { final Properties properties = new Properties( content ); for ( final Map.Entry<String, AttributeView> view : viewsNameIndex.entrySet() ) { if ( includesNonSerializable || view.getValue() instanceof ExtendedAttributeView && ( (ExtendedAttributeView) view.getValue() ).isSerializable() ) { final ExtendedAttributeView extendedView = (ExtendedAttributeView) view.getValue(); for ( final Map.Entry<String, Object> attr : extendedView.readAllAttributes().entrySet() ) { properties.put( attr.getKey(), attr.getValue() ); } } } return properties; } }
public void load( final InputStream in, boolean closeOnFinish ) { final XStream xstream = new XStream(); final Properties temp = new Properties(); try { xstream.fromXML( in, temp ); } catch ( final XStreamException ex ) { if ( !ex.getMessage().equals( " : input contained no data" ) ) { throw ex; } } for ( final Map.Entry<String, Object> entry : temp.entrySet() ) { if ( entry.getValue() != null ) { put( entry.getKey(), entry.getValue() ); } } temp.clear(); if ( closeOnFinish ) { try { in.close(); } catch ( IOException e ) { } } }
public static void buildDotFile( final Path path, final OutputStream out, final FileAttribute<?>... attrs ) { if ( attrs != null && attrs.length > 0 ) { final Properties properties = new Properties(); for ( final FileAttribute<?> attr : attrs ) { if ( attr.value() instanceof Serializable ) { properties.put( attr.name(), attr.value() ); } } try { properties.store( out ); } catch ( final Exception e ) { throw new IOException( e ); } if ( path instanceof AttrHolder ) { ( (AttrHolder) path ).getAttrStorage().loadContent( properties ); } } else { path.getFileSystem().provider().deleteIfExists( dot( path ) ); } }