Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: src/com/dom_distiller/client/sax/AttributesImpl.java

Issue 296113004: Start using computed style instead of default tag actions. (Closed) Base URL: https://code.google.com/p/dom-distiller/@master
Patch Set: Fixed nit. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package com.dom_distiller.client.sax; 5 package com.dom_distiller.client.sax;
6 6
7 import java.util.ArrayList; 7 import java.util.ArrayList;
8 import java.util.HashMap; 8 import java.util.HashMap;
9 import java.util.List; 9 import java.util.List;
10 import java.util.Map; 10 import java.util.Map;
11 11
12 public class AttributesImpl implements Attributes { 12 public class AttributesImpl implements Attributes {
13 private List<AttributeData> attributes; 13 private List<AttributeData> attributes;
14 private Map<String, Integer> attributesMap; 14 private Map<String, Integer> attributesMap;
15 15
16 public AttributesImpl() { 16 public AttributesImpl() {
17 attributes = new ArrayList<AttributeData>(); 17 attributes = new ArrayList<AttributeData>();
18 attributesMap = new HashMap<String, Integer>(); 18 attributesMap = new HashMap<String, Integer>();
19 } 19 }
20 20
21 public int getIndex(String key) { 21 @Override
22 return attributesMap.get(key); 22 public String getValue(String key) {
23 } 23 return getValue(getIndex(key));
24 }
24 25
25 public String getValue(String key) { 26 @Override
26 return getValue(getIndex(key)); 27 public int getIndex(String key) {
27 } 28 return attributesMap.get(key);
29 }
28 30
29 public String getURI(int index) { 31 @Override
30 return attributes.get(index).uri; 32 public String getName(int index) {
31 } 33 return attributes.get(index).name;
34 }
32 35
33 public String getLocalName(int index) { 36 @Override
34 return attributes.get(index).localName; 37 public String getValue(int index) {
35 } 38 return attributes.get(index).value;
39 }
36 40
37 public String getQName(int index) { 41 @Override
38 return attributes.get(index).qName; 42 public int getLength() {
39 } 43 return attributes.size();
44 }
40 45
41 public String getType(int index) { 46 public void addAttribute(String name, String value) {
42 return attributes.get(index).type; 47 attributesMap.put(name, attributes.size());
43 } 48 AttributeData data = new AttributeData(name, value);
49 attributes.add(data);
50 }
44 51
45 public String getValue(int index) { 52 private static class AttributeData {
46 return attributes.get(index).value; 53 private final String name;
47 } 54 private final String value;
48 55
49 public int getLength() { 56 private AttributeData(String name, String value) {
50 return attributes.size(); 57 this.name = name;
51 } 58 this.value = value;
52 59 }
53 public void addAttribute(String uri, String localName, String qName, String ty pe, String value) { 60 }
54 attributesMap.put(qName, attributes.size());
55 AttributeData data = new AttributeData(uri, localName, qName, type, value) ;
56 attributes.add(data);
57 }
58
59 private static class AttributeData {
60 String uri;
61 String localName;
62 String qName;
63 String type;
64 String value;
65
66 AttributeData(String uri, String localName, String qName, String type, Str ing value) {
67 this.uri = uri;
68 this.localName = localName;
69 this.qName = qName;
70 this.type = type;
71 this.value = value;
72 }
73 }
74 } 61 }
OLDNEW
« no previous file with comments | « src/com/dom_distiller/client/sax/Attributes.java ('k') | src/com/dom_distiller/client/sax/ContentHandler.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698