• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.loganalysis.item;
17 
18 import java.util.Arrays;
19 import java.util.HashSet;
20 import java.util.Set;
21 
22 /**
23  * An {@link IItem} used to store the output of the top command.
24  */
25 public class TopItem extends GenericItem {
26 
27     /** Constant for JSON output */
28     public static final String USER = "USER";
29     /** Constant for JSON output */
30     public static final String NICE = "NICE";
31     /** Constant for JSON output */
32     public static final String SYSTEM = "SYSTEM";
33     /** Constant for JSON output */
34     public static final String IDLE = "IDLE";
35     /** Constant for JSON output */
36     public static final String IOW = "IOW";
37     /** Constant for JSON output */
38     public static final String IRQ = "IRQ";
39     /** Constant for JSON output */
40     public static final String SIRQ = "SIRQ";
41     /** Constant for JSON output */
42     public static final String TOTAL = "TOTAL";
43     /** Constant for JSON output */
44     public static final String TEXT = "TEXT";
45 
46     private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList(
47             USER, NICE, SYSTEM, IDLE, IOW, IRQ, SIRQ, TOTAL, TEXT));
48 
49     /**
50      * The constructor for {@link TopItem}.
51      */
TopItem()52     public TopItem() {
53         super(ATTRIBUTES);
54 
55         for (String attribute : ATTRIBUTES) {
56             setAttribute(attribute, 0);
57         }
58     }
59 
60     /**
61      * Get the number of user ticks.
62      */
getUser()63     public int getUser() {
64         return (Integer) getAttribute(USER);
65     }
66 
67     /**
68      * Set the number of user ticks.
69      */
setUser(int user)70     public void setUser(int user) {
71         setAttribute(USER, user);
72     }
73 
74     /**
75      * Get the number of nice ticks.
76      */
getNice()77     public int getNice() {
78         return (Integer) getAttribute(NICE);
79     }
80 
81     /**
82      * Set the number of nice ticks.
83      */
setNice(int nice)84     public void setNice(int nice) {
85         setAttribute(NICE, nice);
86     }
87 
88     /**
89      * Get the number of system ticks.
90      */
getSystem()91     public int getSystem() {
92         return (Integer) getAttribute(SYSTEM);
93     }
94 
95     /**
96      * Set the number of system ticks.
97      */
setSystem(int system)98     public void setSystem(int system) {
99         setAttribute(SYSTEM, system);
100     }
101 
102     /**
103      * Get the number of idle ticks.
104      */
getIdle()105     public int getIdle() {
106         return (Integer) getAttribute(IDLE);
107     }
108 
109     /**
110      * Set the number of idle ticks.
111      */
setIdle(int idle)112     public void setIdle(int idle) {
113         setAttribute(IDLE, idle);
114     }
115 
116     /**
117      * Get the number of IOW ticks.
118      */
getIow()119     public int getIow() {
120         return (Integer) getAttribute(IOW);
121     }
122 
123     /**
124      * Set the number of IOW ticks.
125      */
setIow(int iow)126     public void setIow(int iow) {
127         setAttribute(IOW, iow);
128     }
129 
130     /**
131      * Get the number of IRQ ticks.
132      */
getIrq()133     public int getIrq() {
134         return (Integer) getAttribute(IRQ);
135     }
136 
137     /**
138      * Set the number of IRQ ticks.
139      */
setIrq(int irq)140     public void setIrq(int irq) {
141         setAttribute(IRQ, irq);
142     }
143 
144     /**
145      * Get the number of SIRQ ticks.
146      */
getSirq()147     public int getSirq() {
148         return (Integer) getAttribute(SIRQ);
149     }
150 
151     /**
152      * Set the number of SIRQ ticks.
153      */
setSirq(int sirq)154     public void setSirq(int sirq) {
155         setAttribute(SIRQ, sirq);
156     }
157 
158     /**
159      * Get the number of total ticks.
160      */
getTotal()161     public int getTotal() {
162         return (Integer) getAttribute(TOTAL);
163     }
164 
165     /**
166      * Set the number of total ticks.
167      */
setTotal(int total)168     public void setTotal(int total) {
169         setAttribute(TOTAL, total);
170     }
171 
172     /**
173      * Get the raw text of the top command.
174      */
getText()175     public String getText() {
176         return (String) getAttribute(TEXT);
177     }
178 
179     /**
180      * Set the raw text of the top command.
181      */
setText(String text)182     public void setText(String text) {
183         setAttribute(TEXT, text);
184     }
185 }
186