Home | History | Annotate | Download | only in item
      1 /*
      2  * Copyright (C) 2012 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 com.android.loganalysis.parser.LogcatParser;
     19 
     20 import java.util.Arrays;
     21 import java.util.HashSet;
     22 import java.util.Set;
     23 
     24 /**
     25  * An {@link IItem} used to store Java crash info.
     26  */
     27 public class JavaCrashItem extends MiscLogcatItem {
     28 
     29     /** Constant for JSON output */
     30     public static final String EXCEPTION = "EXCEPTION";
     31     /** Constant for JSON output */
     32     public static final String MESSAGE = "MESSAGE";
     33 
     34     private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList(
     35             EXCEPTION, MESSAGE));
     36 
     37     /**
     38      * The constructor for {@link JavaCrashItem}.
     39      */
     40     public JavaCrashItem() {
     41         super(ATTRIBUTES);
     42         setCategory(LogcatParser.JAVA_CRASH);
     43     }
     44 
     45     /**
     46      * Get the exception for the Java crash.
     47      */
     48     public String getException() {
     49         return (String) getAttribute(EXCEPTION);
     50     }
     51 
     52     /**
     53      * Get the exception for the Java crash.
     54      */
     55     public void setException(String exception) {
     56         setAttribute(EXCEPTION, exception);
     57     }
     58 
     59     /**
     60      * Get the message for the Java crash.
     61      */
     62     public String getMessage() {
     63         return (String) getAttribute(MESSAGE);
     64     }
     65 
     66     /**
     67      * Set the message for the Java crash.
     68      */
     69     public void setMessage(String message) {
     70         setAttribute(MESSAGE, message);
     71     }
     72 }
     73