package pl.helion.j2mepp.lokalizator.ws.klient;

import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.microedition.xml.rpc.Operation;
import javax.microedition.xml.rpc.Type;
import javax.microedition.xml.rpc.ComplexType;
import javax.microedition.xml.rpc.Element;
import pl.helion.j2mepp.lokalizator.dto.Uzytkownik;

public class LokalizatorWSService_Stub implements LokalizatorWSService, javax.xml.rpc.Stub {

    private String[] _propertyNames;
    private Object[] _propertyValues;

    public LokalizatorWSService_Stub() {
        _propertyNames = new String[] { ENDPOINT_ADDRESS_PROPERTY };
        _propertyValues = new Object[] { "http://localhost:8080/LokalizatorWS/LokalizatorWS" };
    }

    public void _setProperty( String name, Object value ) {
        int size = _propertyNames.length;
        for (int i = 0; i < size; ++i) {
            if( _propertyNames[i].equals( name )) {
                _propertyValues[i] = value;
                return;
            }
        }
        String[] newPropNames = new String[size + 1];
        System.arraycopy(_propertyNames, 0, newPropNames, 0, size);
        _propertyNames = newPropNames;
        Object[] newPropValues = new Object[size + 1];
        System.arraycopy(_propertyValues, 0, newPropValues, 0, size);
        _propertyValues = newPropValues;

        _propertyNames[size] = name;
        _propertyValues[size] = value;
    }

    public Object _getProperty(String name) {
        for (int i = 0; i < _propertyNames.length; ++i) {
            if (_propertyNames[i].equals(name)) {
                return _propertyValues[i];
            }
        }
        if (ENDPOINT_ADDRESS_PROPERTY.equals(name) || USERNAME_PROPERTY.equals(name) || PASSWORD_PROPERTY.equals(name)) {
            return null;
        }
        if (SESSION_MAINTAIN_PROPERTY.equals(name)) {
            return new Boolean(false);
        }
        throw new JAXRPCException("Stub does not recognize property: " + name);
    }

    protected void _prepOperation(Operation op) {
        for (int i = 0; i < _propertyNames.length; ++i) {
            op.setProperty(_propertyNames[i], _propertyValues[i].toString());
        }
    }

    public boolean zarejestruj(String arg0, String arg1, String arg2, String arg3) throws java.rmi.RemoteException {
        Object inputObject[] = new Object[] {
            arg0,
            arg1,
            arg2,
            arg3
        };

        Operation op = Operation.newInstance( _qname_operation_zarejestruj, _type_zarejestruj, _type_zarejestrujResponse );
        _prepOperation( op );
        op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "" );
        Object resultObj;
        try {
            resultObj = op.invoke( inputObject );
        } catch( JAXRPCException e ) {
            Throwable cause = e.getLinkedCause();
            if( cause instanceof java.rmi.RemoteException ) {
                throw (java.rmi.RemoteException) cause;
            }
            throw e;
        }

        return ((Boolean )((Object[])resultObj)[0]).booleanValue();
    }

    public String zaloguj(String arg0, String arg1) throws java.rmi.RemoteException {
        Object inputObject[] = new Object[] {
            arg0,
            arg1
        };

        Operation op = Operation.newInstance( _qname_operation_zaloguj, _type_zaloguj, _type_zalogujResponse );
        _prepOperation( op );
        op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "" );
        Object resultObj;
        try {
            resultObj = op.invoke( inputObject );
        } catch( JAXRPCException e ) {
            Throwable cause = e.getLinkedCause();
            if( cause instanceof java.rmi.RemoteException ) {
                throw (java.rmi.RemoteException) cause;
            }
            throw e;
        }

        return (String )((Object[])resultObj)[0];
    }

    public Uzytkownik[] odswiez(String arg0, double arg1, double arg2) throws java.rmi.RemoteException {
        Object inputObject[] = new Object[] {
            arg0,
            new Double(arg1),
            new Double(arg2)
        };

        Operation op = Operation.newInstance( _qname_operation_odswiez, _type_odswiez, _type_odswiezResponse );
        _prepOperation( op );
        op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "" );
        Object resultObj;
        try {
            resultObj = op.invoke( inputObject );
        } catch( JAXRPCException e ) {
            Throwable cause = e.getLinkedCause();
            if( cause instanceof java.rmi.RemoteException ) {
                throw (java.rmi.RemoteException) cause;
            }
            throw e;
        }

        return uzytkownik_ArrayfromObject((Object[])((Object[]) resultObj)[0]);
    }

    public Uzytkownik znajdzUzytkownika(String arg0, String arg1) throws java.rmi.RemoteException {
        Object inputObject[] = new Object[] {
            arg0,
            arg1
        };

        Operation op = Operation.newInstance( _qname_operation_znajdzUzytkownika, _type_znajdzUzytkownika, _type_znajdzUzytkownikaResponse );
        _prepOperation( op );
        op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "" );
        Object resultObj;
        try {
            resultObj = op.invoke( inputObject );
        } catch( JAXRPCException e ) {
            Throwable cause = e.getLinkedCause();
            if( cause instanceof java.rmi.RemoteException ) {
                throw (java.rmi.RemoteException) cause;
            }
            throw e;
        }

        return uzytkownik_fromObject((Object[])((Object[]) resultObj)[0]);
    }

    public void wyloguj(String arg0) throws java.rmi.RemoteException {
        Object inputObject[] = new Object[] {
            arg0
        };

        Operation op = Operation.newInstance( _qname_operation_wyloguj, _type_wyloguj, _type_wylogujResponse );
        _prepOperation( op );
        op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "" );
        Object resultObj;
        try {
            resultObj = op.invoke( inputObject );
        } catch( JAXRPCException e ) {
            Throwable cause = e.getLinkedCause();
            if( cause instanceof java.rmi.RemoteException ) {
                throw (java.rmi.RemoteException) cause;
            }
            throw e;
        }

    }

    public boolean dodajUzytkownika(String arg0, String arg1) throws java.rmi.RemoteException {
        Object inputObject[] = new Object[] {
            arg0,
            arg1
        };

        Operation op = Operation.newInstance( _qname_operation_dodajUzytkownika, _type_dodajUzytkownika, _type_dodajUzytkownikaResponse );
        _prepOperation( op );
        op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "" );
        Object resultObj;
        try {
            resultObj = op.invoke( inputObject );
        } catch( JAXRPCException e ) {
            Throwable cause = e.getLinkedCause();
            if( cause instanceof java.rmi.RemoteException ) {
                throw (java.rmi.RemoteException) cause;
            }
            throw e;
        }

        return ((Boolean )((Object[])resultObj)[0]).booleanValue();
    }

    private static Uzytkownik uzytkownik_fromObject( Object obj[] ) {
        if(obj == null) return null;
        Uzytkownik result = new Uzytkownik();
        result.setDlugosc(((Double )obj[0]).doubleValue());
        result.setHaslo((String )obj[1]);
        result.setID((Integer )obj[2]);
        result.setImie((String )obj[3]);
        result.setLogin((String )obj[4]);
        result.setLokalizacja((String )obj[5]);
        result.setNazwisko((String )obj[6]);
        result.setSzerokosc(((Double )obj[7]).doubleValue());
        return result;
    }

    private static Uzytkownik[] uzytkownik_ArrayfromObject( Object obj[] ) {
        if(obj == null) return null;
        Uzytkownik result[] = new Uzytkownik[obj.length];
        for( int i = 0; i < obj.length; i++ ) {
            result[i] = new Uzytkownik();
            Object[] oo = (Object[]) obj[i];
            result[i].setDlugosc(((Double )oo[0]).doubleValue());
            result[i].setHaslo((String )oo[1]);
            result[i].setID((Integer )oo[2]);
            result[i].setImie((String )oo[3]);
            result[i].setLogin((String )oo[4]);
            result[i].setLokalizacja((String )oo[5]);
            result[i].setNazwisko((String )oo[6]);
            result[i].setSzerokosc(((Double )oo[7]).doubleValue());
        }
        return result;
    }

    protected static final QName _qname_operation_znajdzUzytkownika = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "znajdzUzytkownika" );
    protected static final QName _qname_operation_dodajUzytkownika = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "dodajUzytkownika" );
    protected static final QName _qname_operation_wyloguj = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "wyloguj" );
    protected static final QName _qname_operation_zaloguj = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "zaloguj" );
    protected static final QName _qname_operation_zarejestruj = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "zarejestruj" );
    protected static final QName _qname_operation_odswiez = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "odswiez" );
    protected static final QName _qname_znajdzUzytkownika = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "znajdzUzytkownika" );
    protected static final QName _qname_wyloguj = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "wyloguj" );
    protected static final QName _qname_dodajUzytkownika = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "dodajUzytkownika" );
    protected static final QName _qname_zalogujResponse = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "zalogujResponse" );
    protected static final QName _qname_zarejestruj = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "zarejestruj" );
    protected static final QName _qname_zaloguj = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "zaloguj" );
    protected static final QName _qname_odswiez = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "odswiez" );
    protected static final QName _qname_wylogujResponse = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "wylogujResponse" );
    protected static final QName _qname_dodajUzytkownikaResponse = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "dodajUzytkownikaResponse" );
    protected static final QName _qname_odswiezResponse = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "odswiezResponse" );
    protected static final QName _qname_znajdzUzytkownikaResponse = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "znajdzUzytkownikaResponse" );
    protected static final QName _qname_zarejestrujResponse = new QName( "http://ws.lokalizator.j2mepp.helion.pl/", "zarejestrujResponse" );
    protected static final Element _type_dodajUzytkownikaResponse;
    protected static final Element _type_zaloguj;
    protected static final Element _type_dodajUzytkownika;
    protected static final Element _type_zarejestruj;
    protected static final Element _type_znajdzUzytkownika;
    protected static final Element _type_wylogujResponse;
    protected static final Element _type_odswiez;
    protected static final Element _type_zalogujResponse;
    protected static final Element _type_odswiezResponse;
    protected static final Element _type_wyloguj;
    protected static final Element _type_znajdzUzytkownikaResponse;
    protected static final Element _type_zarejestrujResponse;

    static {
        _type_znajdzUzytkownika = new Element( _qname_znajdzUzytkownika, _complexType( new Element[] {
            new Element( new QName( "", "arg0" ), Type.STRING, 0, 1, false ),
            new Element( new QName( "", "arg1" ), Type.STRING, 0, 1, false )}), 1, 1, false );
        _type_dodajUzytkownika = new Element( _qname_dodajUzytkownika, _complexType( new Element[] {
            new Element( new QName( "", "arg0" ), Type.STRING, 0, 1, false ),
            new Element( new QName( "", "arg1" ), Type.STRING, 0, 1, false )}), 1, 1, false );
        _type_wyloguj = new Element( _qname_wyloguj, _complexType( new Element[] {
            new Element( new QName( "", "arg0" ), Type.STRING, 0, 1, false )}), 1, 1, false );
        _type_zalogujResponse = new Element( _qname_zalogujResponse, _complexType( new Element[] {
            new Element( new QName( "", "return" ), Type.STRING, 0, 1, false )}), 1, 1, false );
        _type_zaloguj = new Element( _qname_zaloguj, _complexType( new Element[] {
            new Element( new QName( "", "arg0" ), Type.STRING, 0, 1, false ),
            new Element( new QName( "", "arg1" ), Type.STRING, 0, 1, false )}), 1, 1, false );
        _type_zarejestruj = new Element( _qname_zarejestruj, _complexType( new Element[] {
            new Element( new QName( "", "arg0" ), Type.STRING, 0, 1, false ),
            new Element( new QName( "", "arg1" ), Type.STRING, 0, 1, false ),
            new Element( new QName( "", "arg2" ), Type.STRING, 0, 1, false ),
            new Element( new QName( "", "arg3" ), Type.STRING, 0, 1, false )}), 1, 1, false );
        _type_odswiez = new Element( _qname_odswiez, _complexType( new Element[] {
            new Element( new QName( "", "arg0" ), Type.STRING, 0, 1, false ),
            new Element( new QName( "", "arg1" ), Type.DOUBLE ),
            new Element( new QName( "", "arg2" ), Type.DOUBLE )}), 1, 1, false );
        _type_dodajUzytkownikaResponse = new Element( _qname_dodajUzytkownikaResponse, _complexType( new Element[] {
            new Element( new QName( "", "return" ), Type.BOOLEAN )}), 1, 1, false );
        _type_wylogujResponse = new Element( _qname_wylogujResponse, _complexType( new Element[] {
        }), 1, 1, false );
        _type_znajdzUzytkownikaResponse = new Element( _qname_znajdzUzytkownikaResponse, _complexType( new Element[] {
            new Element( new QName( "", "return" ), _complexType( new Element[] {
                new Element( new QName( "", "dlugosc" ), Type.DOUBLE ),
                new Element( new QName( "", "haslo" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "ID" ), Type.INT, 0, 1, false ),
                new Element( new QName( "", "imie" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "login" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "lokalizacja" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "nazwisko" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "szerokosc" ), Type.DOUBLE )}))}), 1, 1, false );
        _type_odswiezResponse = new Element( _qname_odswiezResponse, _complexType( new Element[] {
            new Element( new QName( "", "return" ), _complexType( new Element[] {
                new Element( new QName( "", "dlugosc" ), Type.DOUBLE ),
                new Element( new QName( "", "haslo" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "ID" ), Type.INT, 0, 1, false ),
                new Element( new QName( "", "imie" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "login" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "lokalizacja" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "nazwisko" ), Type.STRING, 0, 1, false ),
                new Element( new QName( "", "szerokosc" ), Type.DOUBLE )}), 0, Element.UNBOUNDED, true )}), 1, 1, false );
        _type_zarejestrujResponse = new Element( _qname_zarejestrujResponse, _complexType( new Element[] {
            new Element( new QName( "", "return" ), Type.BOOLEAN )}), 1, 1, false );
    }

    private static ComplexType _complexType( Element[] elements ) {
        ComplexType result = new ComplexType();
        result.elements = elements;
        return result;
    }
}
