libepg.epg.section.body.servicedescriptiontable.ServiceDescriptionTableRepeatingPart.java Source code

Java tutorial

Introduction

Here is the source code for libepg.epg.section.body.servicedescriptiontable.ServiceDescriptionTableRepeatingPart.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package libepg.epg.section.body.servicedescriptiontable;

import libepg.util.bytearray.ByteConverter;
import java.lang.invoke.MethodHandles;
import java.text.MessageFormat;
import java.util.Objects;
import org.apache.commons.logging.Log;
import libepg.epg.section.descriptor.DescriptorsLoop;
import epgtools.loggerfactory.LoggerFactory;
import libepg.util.bytearray.ByteDataBlock;

/**
 * ??
 *
 * @author normal
 */
public final class ServiceDescriptionTableRepeatingPart {

    /**
     * false?????????????
     */
    public static final boolean CLASS_LOG_OUTPUT_MODE = true;

    private static final Log LOG;

    static {
        final Class<?> myClass = MethodHandles.lookup().lookupClass();
        LOG = new LoggerFactory(myClass, ServiceDescriptionTableRepeatingPart.CLASS_LOG_OUTPUT_MODE).getLOG();
    }

    private final ByteDataBlock data;

    ServiceDescriptionTableRepeatingPart(byte[] data) {
        this.data = new ByteDataBlock(data);
    }

    public byte[] getData() {
        return data.getData();
    }

    //?
    /**
     * service_id():??16???<br>
     * ???????????????<br>
     * ??????(program_number)???<br>
     *
     * @return
     */
    public synchronized int getService_id() {
        byte[] t = new byte[2];
        System.arraycopy(this.data.getData(), 0, t, 0, t.length);
        return ByteConverter.bytesToInt(t);
    }

    /**
     * ??????? <br>
     * ??????ARIBSTD-B10?????????????? 3bit<br>
     *
     * @return
     */
    public synchronized int getReserved_future_use1() {
        int temp;
        temp = ByteConverter.byteToInt(this.data.getData()[2]);
        temp = temp >>> 5;
        return temp;
    }

    /**
     * EIT_user_defined_flags(EIT):??3???<br>
     * EIT????????????????? <br>
     * ??????111???<br>
     *
     * @return
     */
    public synchronized int getEIT_user_defined_flags() {
        int temp;
        temp = ByteConverter.byteToInt(this.data.getData()[2]);
        temp = temp >>> 2;
        temp = temp & 0x07;
        return temp;
    }

    /**
     * EIT_schedule_flag(EIT[]):??1???<br>
     * ???1????????EIT[]?????????<br>
     * (EIT[]?????????<br>
     * ???0?????????EIT[]????????????<br>
     *
     * @return
     */
    public synchronized int getEIT_schedule_flag() {
        int temp;
        temp = ByteConverter.byteToInt(this.data.getData()[2]);
        temp = temp >>> 1;
        temp = temp & 0x01;
        return temp;
    }

    /**
     * EIT_present_following_flag(EIT[?/]):??1???<br>
     * ???1????????EIT[?/]?????????<br>
     * (EIT[?/]?????????)<br>
     * ???0?????????EIT[?/]????????????<br>
     *
     * @return
     */
    public synchronized int getEIT_present_following_flag() {
        int temp;
        temp = ByteConverter.byteToInt(this.data.getData()[2]);
        temp = temp & 0x01;
        return temp;
    }

    /**
     * running_status():??3????<br>
     * 0__=_<br>
     * 1__=_?<br>
     * 2__=_??<br>
     * 3__=_?<br>
     * 4__=_<br>
     * 5-7=_??????<br>
     *
     * @return
     */
    public synchronized int getRunning_status() {
        int temp;
        temp = ByteConverter.byteToInt(this.data.getData()[3]);
        temp = temp >>> 5;
        return temp;
    }

    /**
     * free_CA_mode():??1???
     * ???0?????????????????????
     * 1??????????CA???????
     *
     * @return
     */
    public synchronized int getFree_CA_mode() {
        int temp;
        temp = ByteConverter.byteToInt(this.data.getData()[3]);
        temp = temp >>> 4;
        temp = temp & 0x01;
        return temp;
    }

    /**
     * descriptors_loop_length(?):???12??? ??????
     *
     * @return
     */
    public synchronized int getDescriptors_loop_length() {
        byte[] t = new byte[2];
        System.arraycopy(this.data.getData(), 3, t, 0, t.length);
        int it = ByteConverter.bytesToInt(t);
        it = it & 0x0FFF;
        return it;
    }

    /**
     * ???
     *
     * @return
     */
    public synchronized DescriptorsLoop getDescriptors_loop() {
        byte[] t = new byte[this.getDescriptors_loop_length()];
        if (t.length > 0) {
            System.arraycopy(this.data.getData(), 5, t, 0, t.length);
        }
        return new DescriptorsLoop(t);
    }

    private static final MessageFormat SDT_RP_DESC = new MessageFormat(
            "? = {0}\n" + " = {1}\n" + " = {2}\n"
                    + "EIT = {3}\n" + "EIT[] = {4}\n"
                    + "EIT[?/] = {5}\n" + " = {6}\n" + " = {7}\n"
                    + "? = {8}\n" + "? = {9}\n");

    @Override
    public String toString() {
        Object[] parameters = { this.data.toString(), Integer.toHexString(this.getService_id()),
                Integer.toHexString(this.getReserved_future_use1()),
                Integer.toHexString(this.getEIT_user_defined_flags()),
                Integer.toHexString(this.getEIT_schedule_flag()),
                Integer.toHexString(this.getEIT_present_following_flag()),
                Integer.toHexString(this.getRunning_status()), Integer.toHexString(this.getFree_CA_mode()),
                this.getDescriptors_loop_length(), this.getDescriptors_loop().toString() };
        return SDT_RP_DESC.format(parameters);
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 47 * hash + Objects.hashCode(this.data);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ServiceDescriptionTableRepeatingPart other = (ServiceDescriptionTableRepeatingPart) obj;
        if (!Objects.equals(this.data, other.data)) {
            return false;
        }
        return true;
    }

}