NotificationObject.java
001 /*
002  *
003  * Licensed to the Apache Software Foundation (ASF) under one
004  * or more contributor license agreements.  See the NOTICE file
005  * distributed with this work for additional information
006  * regarding copyright ownership.  The ASF licenses this file
007  * to you under the Apache License, Version 2.0 (the
008  * "License"); you may not use this file except in compliance
009  * with the License.  You may obtain a copy of the License at
010  
011  *   http://www.apache.org/licenses/LICENSE-2.0
012  
013  * Unless required by applicable law or agreed to in writing,
014  * software distributed under the License is distributed on an
015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016  * KIND, either express or implied.  See the License for the
017  * specific language governing permissions and limitations
018  * under the License.
019  *
020  */
021 package org.apache.qpid.management.ui.model;
022 
023 import java.text.SimpleDateFormat;
024 import java.util.Date;
025 import java.util.TimeZone;
026 
027 import javax.management.ObjectName;
028 
029 public class NotificationObject
030 {
031 
032     private long    _sequenceNo;
033     private Date    _timeStamp;
034     private String  _message;
035     private Object  _source;       
036     private String  _type;         // INFO, WARN, etc
037     private static final SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss dd/MM/yy z");
038     
039     public NotificationObject(long seqNo, Date timeStamp, String message, Object source, String type)
040     {
041         this._sequenceNo = seqNo;
042         this._message = message;
043         this._source  = source;
044         this._type    = type;
045         this._timeStamp = timeStamp;
046         dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
047     }
048     
049     public Object getSource()
050     {
051         return _source;
052     }
053     public void setSource(Object _source)
054     {
055         this._source = _source;
056     }
057     
058     public String getSourceName()
059     {
060         if (_source instanceof ObjectName)
061         {
062             return ((ObjectName)_source).getKeyProperty("name");
063         }
064         
065         return null;
066     }
067     
068     public String getMessage()
069     {
070         return _message;
071     }
072     public void setMessage(String _message)
073     {
074         this._message = _message;
075     }
076     public long getSequenceNo()
077     {
078         return _sequenceNo;
079     }
080     public void setSequenceNo(long no)
081     {
082         _sequenceNo = no;
083     }
084     public String getTimeStamp()
085     {
086         return dateFormat.format(_timeStamp);
087     }
088     public void setTimeStamp(Date stamp)
089     {
090         _timeStamp = stamp;
091     }
092     public String getType()
093     {
094         return _type;
095     }
096     public void setType(String _type)
097     {
098         this._type = _type;
099     }
100        
101 }