Tabnine Logo
AttrHolder.getAttrStorage
Code IndexAdd Tabnine to your IDE (free)

How to use
getAttrStorage
method
in
org.kie.commons.java.nio.base.AttrHolder

Best Java code snippets using org.kie.commons.java.nio.base.AttrHolder.getAttrStorage (Showing top 13 results out of 315)

origin: org.kie.commons/kie-commons-io

protected <V extends AbstractBasicFileAttributeView> V newView( final AttrHolder holder,
                                final Class<V> type ) {
  if ( NeedsPreloadedAttrs.class.isAssignableFrom( type ) && holder.getAttrStorage().getContent().size() == 0 ) {
    readAttributes( (Path) holder );
  }
  try {
    final Constructor<V> constructor = (Constructor<V>) type.getConstructors()[ 0 ];
    final V view = constructor.newInstance( holder );
    holder.addAttrView( view );
    return view;
  } catch ( final Exception e ) {
  }
  return null;
}
origin: org.kie.commons/kie-commons-io

@Override
public Object getAttribute( final Path path,
              final String attribute )
    throws UnsupportedOperationException, IllegalArgumentException, IOException, SecurityException {
  checkNotNull( "path", path );
  Object value;
  try {
    value = Files.getAttribute( path, attribute );
  } catch ( UnsupportedOperationException ex ) {
    value = null;
  }
  if ( value == null && path instanceof AttrHolder ) {
    final AttrHolder holder = ( (AttrHolder) path );
    final String[] attr = split( attribute );
    if ( holder.getAttrStorage().getContent().isEmpty() ) {
      loadDotFile( path );
    }
    return holder.getAttrStorage().getAllContent().get( attr[ 1 ] );
  }
  return value;
}
origin: org.kie.commons/kie-commons-io

@Override
public synchronized boolean deleteIfExists( final Path path,
                      final DeleteOption... options )
    throws IllegalArgumentException, DirectoryNotEmptyException, IOException, SecurityException {
  final boolean result = Files.deleteIfExists( path, options );
  try {
    Files.deleteIfExists( dot( path ), options );
  } catch ( Exception ex ) {
  }
  if ( path instanceof AttrHolder ) {
    ( (AttrHolder) path ).getAttrStorage().clear();
  }
  return result;
}
origin: org.kie.commons/kie-commons-io

@Override
public synchronized void delete( final Path path,
                 final DeleteOption... options )
    throws IllegalArgumentException, NoSuchFileException, DirectoryNotEmptyException,
    IOException, SecurityException {
  Files.delete( path, options );
  try {
    Files.deleteIfExists( dot( path ), options );
  } catch ( Exception ex ) {
  }
  if ( path instanceof AttrHolder ) {
    ( (AttrHolder) path ).getAttrStorage().clear();
  }
}
origin: org.kie.commons/kie-commons-io

protected void loadDotFile( final Path path ) {
  final Properties content = new Properties();
  content.load( newInputStream( dot( path ) ) );
  if ( path instanceof AttrHolder ) {
    ( (AttrHolder) path ).getAttrStorage().loadContent( content );
  }
}
origin: org.kie.commons/kie-commons-io

@Override
public Map<String, Object> readAttributes( final Path path,
                      final String attributes )
    throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException,
    IOException, SecurityException {
  checkNotNull( "path", path );
  checkNotEmpty( "attributes", attributes );
  final Properties original = new Properties( Files.readAttributes( path, attributes ) );
  if ( attributes.equals( "*" ) && exists( dot( path ) ) ) {
    boolean isAttrHolder = path instanceof AttrHolder;
    if ( isAttrHolder && ( (AttrHolder) path ).getAttrStorage().getContent().size() > 0 ) {
      return ( (AttrHolder) path ).getAttrStorage().getAllContent();
    }
    final Properties content = new Properties();
    content.load( newInputStream( dot( path ) ) );
    content.putAll( original );
    if ( isAttrHolder ) {
      ( (AttrHolder) path ).getAttrStorage().loadContent( content );
    }
    return content;
  }
  return original;
}
origin: org.kie.commons/kie-nio2-model

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 ) );
  }
}
origin: org.kie.commons/kie-commons-io

( (AttrHolder) path ).getAttrStorage().clear();
origin: org.kie.commons/kie-commons-io

( (AttrHolder) path ).getAttrStorage().clear();
origin: org.kie.commons/kie-commons-io

assertFalse( ( (AttrHolder) file ).getAttrStorage().getContent().isEmpty() );
assertTrue( ( (AttrHolder) file ).getAttrStorage().getContent().isEmpty() );
origin: org.kie.commons/kie-commons-io

assertTrue( ioService().exists( dot( file ) ) );
assertFalse( ( (AttrHolder) file ).getAttrStorage().getContent().isEmpty() );
assertTrue( ( (AttrHolder) file ).getAttrStorage().getContent().isEmpty() );
origin: org.kie.commons/kie-commons-io

@Test
public void testGetAttribute() {
  final Path file = getFilePath();
  ioService().deleteIfExists( file );
  ioService().write( file, "ooooo!", Collections.<OpenOption>emptySet(), new FileAttribute<Object>() {
    @Override
    public String name() {
      return "dcore.author";
    }
    @Override
    public Object value() {
      return "AuthorName";
    }
  } );
  assertNotNull( ioService().getAttribute( file, "dcore:dcore.author" ) );
  assertNull( ioService().getAttribute( file, "dcore:dcore.not_here" ) );
  assertNotNull( ioService().getAttribute( file, "dcore.author" ) );
  assertNull( ioService().getAttribute( file, "something" ) );
  ( (AttrHolder) file ).getAttrStorage().clear();
  assertNotNull( ioService().getAttribute( file, "dcore:dcore.author" ) );
  assertNull( ioService().getAttribute( file, "dcore:dcore.not_here" ) );
  assertNotNull( ioService().getAttribute( file, "dcore.author" ) );
  assertNull( ioService().getAttribute( file, "something" ) );
}
origin: org.kie.commons/kie-commons-io

@Test
public void testGetAttributeView() {
  final Path file = getFilePath();
  ioService().deleteIfExists( file );
  ioService().write( file, "ooooo!", Collections.<OpenOption>emptySet(), new FileAttribute<Object>() {
    @Override
    public String name() {
      return "dcore.author";
    }
    @Override
    public Object value() {
      return "AuthorName";
    }
  } );
  assertNotNull( ioService().getFileAttributeView( file, BasicFileAttributeView.class ) );
  assertNull( ioService().getFileAttributeView( file, MyAttrsView.class ) );
  assertNotNull( ioService().getFileAttributeView( file, XDublinCoreView.class ) );
  final DublinCoreAttributes attr = ioService().getFileAttributeView( file, XDublinCoreView.class ).readAttributes();
  assertEquals( "AuthorName", attr.getAuthor() );
  ( (AttrHolder) file ).getAttrStorage().clear();
  assertNotNull( ioService().getFileAttributeView( file, BasicFileAttributeView.class ) );
  assertNull( ioService().getFileAttributeView( file, MyAttrsView.class ) );
  assertNotNull( ioService().getFileAttributeView( file, XDublinCoreView.class ) );
}
org.kie.commons.java.nio.baseAttrHoldergetAttrStorage

Popular methods of AttrHolder

  • addAttrView
  • getAttrView

Popular in Java

  • Making http post requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JFrame (javax.swing)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now