View Javadoc
1   package org.apache.maven.resolver.internal.ant.types;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  import org.apache.maven.resolver.internal.ant.AntRepoSys;
25  import org.apache.tools.ant.types.DataType;
26  import org.apache.tools.ant.types.Reference;
27  
28  /**
29   */
30  public class Settings
31      extends DataType
32  {
33  
34      private File file;
35  
36      private File globalFile;
37  
38      protected Settings getRef()
39      {
40          return (Settings) getCheckedRef();
41      }
42  
43      public void setRefid( Reference ref )
44      {
45          if ( file != null || globalFile != null )
46          {
47              throw tooManyAttributes();
48          }
49          super.setRefid( ref );
50      }
51  
52      public File getFile()
53      {
54          if ( isReference() )
55          {
56              return getRef().getFile();
57          }
58          return file;
59      }
60  
61      public void setFile( File file )
62      {
63          checkAttributesAllowed();
64          this.file = file;
65  
66          AntRepoSys.getInstance( getProject() ).setUserSettings( file );
67      }
68  
69      public File getGlobalFile()
70      {
71          if ( isReference() )
72          {
73              return getRef().getFile();
74          }
75          return globalFile;
76      }
77  
78      public void setGlobalFile( File globalFile )
79      {
80          checkAttributesAllowed();
81          this.globalFile = globalFile;
82  
83          AntRepoSys.getInstance( getProject() ).setGlobalSettings( globalFile );
84      }
85  
86  }