• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 org.json.JSONException;
19 import org.json.JSONObject;
20 
21 /**
22  * An {@link IItem} used to store the memory info output.
23  */
24 @SuppressWarnings("serial")
25 public class MemInfoItem extends GenericMapItem<Long> {
26 
27     /** Constant for JSON output */
28     public static final String LINES = "LINES";
29     /** Constant for JSON output */
30     public static final String TEXT = "TEXT";
31 
32     private String mText = null;
33 
34     /**
35      * Get the raw text of the mem info command.
36      */
getText()37     public String getText() {
38         return mText;
39     }
40 
41     /**
42      * Set the raw text of the mem info command.
43      */
setText(String text)44     public void setText(String text) {
45         mText = text;
46     }
47 
48     /**
49      * {@inheritDoc}
50      */
51     @Override
toJson()52     public JSONObject toJson() {
53         JSONObject object = new JSONObject();
54         try {
55             object.put(LINES, super.toJson());
56             object.put(TEXT, getText());
57         } catch (JSONException e) {
58             // Ignore
59         }
60         return object;
61     }
62 }
63