|
| 1 | +/* |
| 2 | + * Copyright (c) 2015-2016, EMC Corporation. |
| 3 | + * Redistribution and use in source and binary forms, with or without modification, |
| 4 | + * are permitted provided that the following conditions are met: |
| 5 | + * |
| 6 | + * + Redistributions of source code must retain the above copyright notice, |
| 7 | + * this list of conditions and the following disclaimer. |
| 8 | + * + Redistributions in binary form must reproduce the above copyright |
| 9 | + * notice, this list of conditions and the following disclaimer in the |
| 10 | + * documentation and/or other materials provided with the distribution. |
| 11 | + * + The name of EMC Corporation may not be used to endorse or promote |
| 12 | + * products derived from this software without specific prior written |
| 13 | + * permission. |
| 14 | + * |
| 15 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 16 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 17 | + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 18 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 19 | + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 | + * POSSIBILITY OF SUCH DAMAGE. |
| 26 | + */ |
| 27 | +package com.emc.object.s3.bean; |
| 28 | + |
| 29 | +import javax.xml.bind.annotation.XmlElement; |
| 30 | +import javax.xml.bind.annotation.XmlElementWrapper; |
| 31 | +import javax.xml.bind.annotation.XmlTransient; |
| 32 | +import javax.xml.bind.annotation.XmlType; |
| 33 | +import java.util.ArrayList; |
| 34 | +import java.util.HashMap; |
| 35 | +import java.util.List; |
| 36 | +import java.util.Map; |
| 37 | + |
| 38 | +@XmlType(propOrder = {"type", "queryMetadataEntries"}) |
| 39 | +public class QueryMetadata { |
| 40 | + private QueryMetadataType type; |
| 41 | + private Map<String, String> mdMap = new HashMap<String, String>(); |
| 42 | + |
| 43 | + @XmlElement(name = "type", namespace = "") |
| 44 | + public QueryMetadataType getType() { |
| 45 | + return type; |
| 46 | + } |
| 47 | + |
| 48 | + public void setType(QueryMetadataType type) { |
| 49 | + this.type = type; |
| 50 | + } |
| 51 | + |
| 52 | + @XmlTransient |
| 53 | + public Map<String, String> getMdMap() { |
| 54 | + return mdMap; |
| 55 | + } |
| 56 | + |
| 57 | + public void setMdMap(Map<String, String> mdMap) { |
| 58 | + this.mdMap = mdMap; |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * @deprecated Use {@link #getMdMap()} instead. |
| 63 | + */ |
| 64 | + @XmlElementWrapper(name = "mdMap", namespace = "") |
| 65 | + @XmlElement(name = "entry", namespace = "") |
| 66 | + public List<QueryMetadataEntry> getQueryMetadataEntries() { |
| 67 | + if (mdMap == null) return null; |
| 68 | + List<QueryMetadataEntry> queryMetadataEntries = new ArrayList<QueryMetadataEntry>(); |
| 69 | + for (String key : mdMap.keySet()) { |
| 70 | + queryMetadataEntries.add(new QueryMetadataEntry(key, mdMap.get(key))); |
| 71 | + } |
| 72 | + return queryMetadataEntries; |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * @deprecated Use {@link #setMdMap(Map)} instead. |
| 77 | + */ |
| 78 | + public void setQueryMetadataEntries(List<QueryMetadataEntry> queryMetadataEntries) { |
| 79 | + mdMap = new HashMap<String, String>(); |
| 80 | + for (QueryMetadataEntry entry : queryMetadataEntries) { |
| 81 | + mdMap.put(entry.getKey(), entry.getValue()); |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + public static class QueryMetadataEntry { |
| 86 | + private String key; |
| 87 | + private String value; |
| 88 | + |
| 89 | + public QueryMetadataEntry() { |
| 90 | + } |
| 91 | + |
| 92 | + public QueryMetadataEntry(String key, String value) { |
| 93 | + this.key = key; |
| 94 | + this.value = value; |
| 95 | + } |
| 96 | + |
| 97 | + @XmlElement(name = "key", namespace = "") |
| 98 | + public String getKey() { |
| 99 | + return key; |
| 100 | + } |
| 101 | + |
| 102 | + public void setKey(String key) { |
| 103 | + this.key = key; |
| 104 | + } |
| 105 | + |
| 106 | + @XmlElement(name = "value", namespace = "") |
| 107 | + public String getValue() { |
| 108 | + return value; |
| 109 | + } |
| 110 | + |
| 111 | + public void setValue(String value) { |
| 112 | + this.value = value; |
| 113 | + } |
| 114 | + } |
| 115 | +} |
0 commit comments