From 48993448171d1dbd8694fb0e2709df0cfe1fd398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryszard=20Wi=C5=9Bniewski?= Date: Wed, 1 Sep 2010 22:30:24 +0200 Subject: [PATCH] ResConfig, ResResSpec: added possibility to overwrite stored ResResource. --- src/brut/androlib/res/data/ResConfig.java | 7 ++++++- src/brut/androlib/res/data/ResResSpec.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/brut/androlib/res/data/ResConfig.java b/src/brut/androlib/res/data/ResConfig.java index 04f8236e..736de274 100644 --- a/src/brut/androlib/res/data/ResConfig.java +++ b/src/brut/androlib/res/data/ResConfig.java @@ -56,8 +56,13 @@ public class ResConfig { public void addResource(ResResource res) throws AndrolibException { + addResource(res, false); + } + + public void addResource(ResResource res, boolean overwrite) + throws AndrolibException { ResResSpec spec = res.getResSpec(); - if (mResources.put(spec, res) != null) { + if (mResources.put(spec, res) != null && ! overwrite) { throw new AndrolibException(String.format( "Multiple resources: spec=%s, config=%s", spec, this)); } diff --git a/src/brut/androlib/res/data/ResResSpec.java b/src/brut/androlib/res/data/ResResSpec.java index 4b9de594..30545e7b 100644 --- a/src/brut/androlib/res/data/ResResSpec.java +++ b/src/brut/androlib/res/data/ResResSpec.java @@ -107,8 +107,13 @@ public class ResResSpec { public void addResource(ResResource res) throws AndrolibException { + addResource(res, false); + } + + public void addResource(ResResource res, boolean overwrite) + throws AndrolibException { ResConfigFlags flags = res.getConfig().getFlags(); - if (mResources.put(flags, res) != null) { + if (mResources.put(flags, res) != null && ! overwrite) { throw new AndrolibException(String.format( "Multiple resources: spec=%s, config=%s", this, flags)); }