Package: ResourceFileSystemNetBeansPlatform
ResourceFileSystemNetBeansPlatform
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
createResourceFile(FileObject) |
|
|
|
|
|
||||||||||||||||||||
findFileByPath(String) |
|
|
|
|
|
||||||||||||||||||||
getRoot() |
|
|
|
|
|
Coverage
1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * NorthernWind - lightweight CMS
5: * http://tidalwave.it/projects/northernwind
6: *
7: * Copyright (C) 2011 - 2025 Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * 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
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/northernwind-src
22: * git clone https://github.com/tidalwave-it/northernwind-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.northernwind.frontend.filesystem.impl;
27:
28: import javax.annotation.Nonnull;
29: import java.util.IdentityHashMap;
30: import org.openide.filesystems.FileObject;
31: import org.openide.filesystems.FileSystem;
32: import it.tidalwave.util.As;
33: import it.tidalwave.northernwind.core.model.ResourceFile;
34: import it.tidalwave.northernwind.core.model.ResourceFileSystem;
35: import lombok.RequiredArgsConstructor;
36: import lombok.experimental.Delegate;
37:
38: /***************************************************************************************************************************************************************
39: *
40: * @author Fabrizio Giudici
41: *
42: **************************************************************************************************************************************************************/
43: @RequiredArgsConstructor
44: public class ResourceFileSystemNetBeansPlatform implements ResourceFileSystem
45: {
46: private final IdentityHashMap<FileObject, ResourceFile> delegateLightWeightMap = new IdentityHashMap<>();
47:
48: @Nonnull
49: private final FileSystem fileSystem;
50:
51: @Delegate
52: private final As asSupport = As.forObject(this);
53:
54: @Override @Nonnull
55: public ResourceFile getRoot()
56: {
57: return createResourceFile(fileSystem.getRoot());
58: }
59:
60: @Override @Nonnull
61: public ResourceFile findFileByPath (@Nonnull final String path)
62: {
63: return createResourceFile(fileSystem.findResource(path));
64: }
65:
66: /* package */
67: synchronized ResourceFile createResourceFile (@Nonnull final FileObject fileObject)
68: {
69:• if (fileObject == null)
70: {
71: return null;
72: }
73:
74: var decorator = delegateLightWeightMap.get(fileObject);
75:
76:• if (decorator == null)
77: {
78: decorator = new ResourceFileNetBeansPlatform(this, fileObject);
79: delegateLightWeightMap.put(fileObject, decorator);
80: }
81:
82: return decorator;
83: }
84:
85: // TODO: equals and hashcode
86: }