View Javadoc
1   /*
2    * Copyright (C) 2005-2015 Schlichtherle IT Services.
3    * All rights reserved. Use is subject to license terms.
4    */
5   package net.java.truevfs.kernel.spec;
6   
7   import java.io.IOException;
8   import java.util.Map;
9   import javax.annotation.CheckForNull;
10  import javax.annotation.concurrent.ThreadSafe;
11  import net.java.truecommons.cio.Entry;
12  import net.java.truecommons.cio.Entry.Access;
13  import net.java.truecommons.cio.Entry.Type;
14  import net.java.truecommons.cio.InputSocket;
15  import net.java.truecommons.cio.OutputSocket;
16  import net.java.truecommons.shed.BitField;
17  
18  /**
19   * An abstract decorator for a file system controller.
20   *
21   * @author Christian Schlichtherle
22   */
23  @ThreadSafe
24  public abstract class FsDecoratingController extends FsAbstractController {
25  
26      /** The decorated file system controller. */
27      protected final FsController controller;
28  
29      protected FsDecoratingController(final FsController controller) {
30          super(controller.getModel());
31          this.controller = controller;
32      }
33  
34      @Override
35      public FsController getParent() {
36          return controller.getParent();
37      }
38  
39      @Override
40      public @CheckForNull FsNode node(
41              BitField<FsAccessOption> options,
42              FsNodeName name)
43      throws IOException {
44          return controller.node(options, name);
45      }
46  
47      @Override
48      public void checkAccess(
49              BitField<FsAccessOption> options,
50              FsNodeName name,
51              BitField<Access> types)
52      throws IOException {
53          controller.checkAccess(options, name, types);
54      }
55  
56      @Override
57      public void setReadOnly(BitField<FsAccessOption> options, FsNodeName name)
58      throws IOException {
59          controller.setReadOnly(options, name);
60      }
61  
62      @Override
63      public boolean setTime(
64              BitField<FsAccessOption> options,
65              FsNodeName name,
66              Map<Access, Long> times)
67      throws IOException {
68          return controller.setTime(options, name, times);
69      }
70  
71      @Override
72      public boolean setTime(
73              BitField<FsAccessOption> options,
74              FsNodeName name,
75              BitField<Access> types,
76              long value)
77      throws IOException {
78          return controller.setTime(options, name, types, value);
79      }
80  
81      @Override
82      public InputSocket<? extends Entry> input(
83              BitField<FsAccessOption> options,
84              FsNodeName name) {
85          return controller.input(options, name);
86      }
87  
88      @Override
89      public OutputSocket<? extends Entry> output(
90              BitField<FsAccessOption> options,
91              FsNodeName name,
92              @CheckForNull Entry template) {
93          return controller.output(options, name, template);
94      }
95  
96      @Override
97      public void make(
98              BitField<FsAccessOption> options,
99              FsNodeName name,
100             Type type,
101             @CheckForNull Entry template)
102     throws IOException {
103         controller.make(options, name, type, template);
104     }
105 
106     @Override
107     public void unlink(
108             BitField<FsAccessOption> options,
109             FsNodeName name)
110     throws IOException {
111         controller.unlink(options, name);
112     }
113 
114     @Override
115     public void sync(BitField<FsSyncOption> options) throws FsSyncException {
116         controller.sync(options);
117     }
118 
119     @Override
120     public String toString() {
121         return String.format("%s@%x[controller=%s]",
122                 getClass().getName(),
123                 hashCode(),
124                 controller);
125     }
126 }