View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.commons.resourcehandler.resource;
20  
21  /**
22   * Contains the metadata information to reference a resource 
23   * 
24   * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
25   * @version $Revision: 700544 $ $Date: 2008-09-30 13:44:02 -0500 (Mar, 30 Sep 2008) $
26   */
27  public class AliasResourceMetaImpl extends ResourceMetaImpl
28  {
29      private String _realResourceName;
30      
31      private boolean _couldContainValueExpressions;
32  
33      public AliasResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
34              String resourceName, String resourceVersion, String realResourceName, boolean couldContainValueExpressions)
35      {
36          super(prefix, libraryName, libraryVersion,
37              resourceName, resourceVersion);
38          _realResourceName = realResourceName;
39          _couldContainValueExpressions = couldContainValueExpressions;
40      }
41      
42      public String getRealResourceName()
43      {
44          return _realResourceName;
45      }
46  
47      public void setRealResourceName(String realResourceName)
48      {
49          _realResourceName = realResourceName;
50      }
51      
52      @Override
53      public String getResourceIdentifier()
54      {
55          StringBuilder builder = new StringBuilder();
56          boolean firstSlashAdded = false;
57          if (getLocalePrefix() != null && getLocalePrefix().length() > 0)
58          {
59              builder.append(getLocalePrefix());
60              firstSlashAdded = true;
61          }
62          if (getLibraryName() != null)
63          {
64              if (firstSlashAdded) builder.append('/');
65              builder.append(getLibraryName());
66              firstSlashAdded = true;
67          }
68          if (getLibraryVersion() != null)
69          {
70              if (firstSlashAdded) builder.append('/');
71              builder.append(getLibraryVersion());
72              firstSlashAdded = true;
73          }
74          if (getRealResourceName() != null)
75          {
76              if (firstSlashAdded) builder.append('/');
77              builder.append(getRealResourceName());
78              firstSlashAdded = true;
79          }
80          if (getResourceVersion() != null)
81          {
82              if (firstSlashAdded) builder.append('/');
83              builder.append(getResourceVersion());
84              builder.append(
85                      getRealResourceName().substring(getRealResourceName().lastIndexOf('.')));
86              firstSlashAdded = true;
87          }
88          return builder.toString();
89      }
90  
91      @Override
92      public boolean couldResourceContainValueExpressions()
93      {
94          return _couldContainValueExpressions;
95      }
96  }