| 1 |
/* |
| 2 |
* Copyright (C) 2010 Ryszard Wiśniewski <[email protected]> |
| 3 |
* Copyright (C) 2010 Connor Tumbleson <[email protected]> |
| 4 |
* |
| 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 |
| 8 |
* |
| 9 |
* https://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
* |
| 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. |
| 16 |
*/ |
| 17 |
package brut.androlib.res.data; |
| 18 |
|
| 19 |
import java.util.LinkedHashSet; |
| 20 |
import java.util.Objects; |
| 21 |
import java.util.Set; |
| 22 |
|
| 23 |
public class ResValuesFile { |
| 24 |
private final ResPackage mPackage; |
| 25 |
private final ResTypeSpec mType; |
| 26 |
private final ResType mConfig; |
| 27 |
private final Set<ResResource> mResources = new LinkedHashSet<>(); |
| 28 |
|
| 29 |
public ResValuesFile(ResPackage pkg, ResTypeSpec type, ResType config) { |
| 30 |
this.mPackage = pkg; |
| 31 |
this.mType = type; |
| 32 |
this.mConfig = config; |
| 33 |
} |
| 34 |
|
| 35 |
public String getPath() { |
| 36 |
return "values" + mConfig.getFlags().getQualifiers() + "/" |
| 37 |
+ mType.getName() + (mType.getName().endsWith("s") ? "" : "s") |
| 38 |
+ ".xml"; |
| 39 |
} |
| 40 |
|
| 41 |
public Set<ResResource> listResources() { |
| 42 |
return mResources; |
| 43 |
} |
| 44 |
|
| 45 |
public ResTypeSpec getType() { |
| 46 |
return mType; |
| 47 |
} |
| 48 |
|
| 49 |
public boolean isSynthesized(ResResource res) { |
| 50 |
return mPackage.isSynthesized(res.getResSpec().getId()); |
| 51 |
} |
| 52 |
|
| 53 |
public void addResource(ResResource res) { |
| 54 |
mResources.add(res); |
| 55 |
} |
| 56 |
|
| 57 |
@Override |
| 58 |
public boolean equals(Object obj) { |
| 59 |
if (obj == null) { |
| 60 |
return false; |
| 61 |
} |
| 62 |
if (getClass() != obj.getClass()) { |
| 63 |
return false; |
| 64 |
} |
| 65 |
final ResValuesFile other = (ResValuesFile) obj; |
| 66 |
if (!Objects.equals(this.mType, other.mType)) { |
| 67 |
return false; |
| 68 |
} |
| 69 |
return Objects.equals(this.mConfig, other.mConfig); |
| 70 |
} |
| 71 |
|
| 72 |
@Override |
| 73 |
public int hashCode() { |
| 74 |
int hash = 17; |
| 75 |
hash = 31 * hash + (this.mType != null ? this.mType.hashCode() : 0); |
| 76 |
hash = 31 * hash + (this.mConfig != null ? this.mConfig.hashCode() : 0); |
| 77 |
return hash; |
| 78 |
} |
| 79 |
} |