Host.java Source code

Java tutorial

Introduction

Here is the source code for Host.java

Source

/* 
************************************************************************
    
# RESTful API for Zabbix based on Java.
#
#  Copyright 2014 Yahya Al-Hazmi, TU Berlin.
# Authors: Mingyuan Wu and Yahya Al-Hazmi
# Licensed under the Apache License, Version 2.0 (the "License"); 
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0 
#       
# Unless required by applicable law or agreed to in writing, software 
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License
#
# This API allows you to request monitoring information from Zabbix-Server 
# through Zabbix-API
    
 ************************************************************************
    
 This defines the structure of the class HostController.java.
     
 ************************************************************************
*/

import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.JSONValue;
import org.json.simple.parser.ParseException;
import org.json.simple.parser.JSONParser;

public class Host {
    private JSONArray list = new JSONArray();
    private String status;

    public Host(String status) {
        this.list = null;
        this.status = status;
    }

    public Host(JSONArray list) {
        this.status = "ok";
        for (int i = 0; i < list.size(); i++) {
            JSONObject obj = (JSONObject) list.get(i);
            this.list.add(obj);
        }
    }

    public JSONArray getHostList() {
        return list;
    }
}