]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerMap.java
3 * Copyright 2004 The Ant-Contrib project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package net
.sf
.antcontrib
.cpptasks
;
20 import java
.io
.IOException
;
22 import org
.apache
.tools
.ant
.BuildException
;
23 import org
.apache
.tools
.ant
.types
.DataType
;
26 * Local to remote filename mapping (Experimental).
29 public final class DistributerMap
34 private String ifCond
;
39 private String unlessCond
;
42 * local directory name.
45 private File localName
;
48 * Canonical local file name.
50 private String canonicalPath
;
56 private String remoteName
;
59 * Separator (/ or \) character on remote system.
61 private char remoteSeparator
= File
.separatorChar
;
64 * hosts that for which this map is valid.
73 public DistributerMap() {
77 * Required by documentation generator.
79 public void execute() {
80 throw new org
.apache
.tools
.ant
.BuildException(
81 "Not an actual task, but looks like one for documentation purposes");
85 * Returns true if the if and unless conditions (if any) are
88 * @return true if this object is active.
90 public boolean isActive() {
91 return CUtil
.isActive(getProject(), ifCond
, unlessCond
);
95 * Sets the property name for the 'if' condition.
97 * This object will be ignored unless the property is defined.
99 * The value of the property is insignificant, but values that would imply
100 * misinterpretation ("false", "no") will throw an exception when
106 public void setIf(final String propName
) {
111 * Set the property name for the 'unless' condition.
113 * If named property is set, the define will be ignored.
115 * The value of the property is insignificant, but values that would imply
116 * misinterpretation ("false", "no") of the behavior will throw an
117 * exception when evaluated.
122 public void setUnless(final String propName
) {
123 unlessCond
= propName
;
127 * Gets local directory.
128 * @return local directory, may be null.
131 public File
getLocal() {
136 * Gets remote name for directory.
137 * @return remote name, may be null.
140 public String
getRemote() {
145 * Converts the local file name to the remote name for the same file.
148 * @param localFile local file
149 * @return remote name for local file, null if unknown.
151 public String
toRemote(final String host
, final File localFile
) {
152 if (remoteName
!= null
153 && (hosts
== null || hosts
.indexOf(host
) >= 0)) {
155 String canonical
= localFile
.getCanonicalPath();
156 if (canonical
.startsWith(canonicalPath
)) {
159 + canonical
.substring(canonicalPath
.length()).replace(File
.
160 separatorChar
, remoteSeparator
);
163 } catch (IOException ex
) {
171 * Sets local directory for base of mapping.
175 public void setLocal(final File value
) {
177 throw new NullPointerException("value");
179 if (value
.exists() && !value
.isDirectory()) {
180 throw new BuildException("local should be a directory");
184 canonicalPath
= localName
.getCanonicalPath();
185 } catch (IOException ex
) {
186 throw new BuildException(ex
);
191 * Sets remote name for directory.
192 * @param value remote name for directory
194 public void setRemote(final String value
) {
199 * Sets the separator character (/ or \) for the remote system.
200 * @param value separator character
202 public void setRemoteSeparator(final String value
) {
203 if (value
!= null && value
.length() != 1) {
204 throw new BuildException("remote separator must be a single character");
206 remoteSeparator
= value
.charAt(0);
210 * Sets hosts for which this mapping is valid.
214 public void setHosts(final String value
) {