View Javadoc
1   /*
2    * Copyright 2012-2025 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.storage;
17  
18  import java.time.ZonedDateTime;
19  
20  /**
21   * Represents a storage item (file or directory).
22   */
23  public class StorageItem {
24  
25      private final String name;
26      private final String path;
27      private final boolean directory;
28      private final long size;
29      private final ZonedDateTime lastModified;
30      private final String encodedId;
31  
32      /**
33       * Creates a new StorageItem instance.
34       *
35       * @param name the name of the item
36       * @param path the path of the item
37       * @param directory true if this item is a directory
38       * @param size the size of the item in bytes
39       * @param lastModified the last modified timestamp
40       * @param encodedId the base64-encoded ID of the item
41       */
42      public StorageItem(final String name, final String path, final boolean directory, final long size, final ZonedDateTime lastModified,
43              final String encodedId) {
44          this.name = name;
45          this.path = path;
46          this.directory = directory;
47          this.size = size;
48          this.lastModified = lastModified;
49          this.encodedId = encodedId;
50      }
51  
52      /**
53       * Returns the name of the item.
54       *
55       * @return the item name
56       */
57      public String getName() {
58          return name;
59      }
60  
61      /**
62       * Returns the path of the item.
63       *
64       * @return the item path
65       */
66      public String getPath() {
67          return path;
68      }
69  
70      /**
71       * Returns whether this item is a directory.
72       *
73       * @return true if this item is a directory, false otherwise
74       */
75      public boolean isDirectory() {
76          return directory;
77      }
78  
79      /**
80       * Returns the size of the item in bytes.
81       *
82       * @return the item size
83       */
84      public long getSize() {
85          return size;
86      }
87  
88      /**
89       * Returns the last modified timestamp.
90       *
91       * @return the last modified timestamp
92       */
93      public ZonedDateTime getLastModified() {
94          return lastModified;
95      }
96  
97      /**
98       * Returns the base64-encoded ID of the item.
99       *
100      * @return the encoded ID
101      */
102     public String getEncodedId() {
103         return encodedId;
104     }
105 }