All Downloads are FREE. Search and download functionalities are using the official Maven repository.

system.net.IPAddress Maven / Gradle / Ivy

/*
 *  MIT License
 *
 *  Copyright (c) 2024 MASES s.r.l.
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in all
 *  copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 *  SOFTWARE.
 */

/**************************************************************************************
 * 
 *      This code was generated from a template using JCOReflector v. 1.15.0.0
 * 
 *      Manual changes to this file may cause unexpected behavior in your application.
 *      Manual changes to this file will be overwritten if the code is regenerated.
 * 
 *************************************************************************************/

package system.net;

import org.mases.jcobridge.*;
import org.mases.jcobridge.netreflection.*;
import java.util.ArrayList;

// Import section
import system.net.IPAddress;
import system.IFormatProvider;
import system.IFormatProviderImplementation;
import system.net.sockets.AddressFamily;
import system.IFormattable;
import system.IFormattableImplementation;


/**
 * The base .NET class managing System.Net.IPAddress, System.Net.Primitives, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
 * 

* * .NET documentation at https://docs.microsoft.com/en-us/dotnet/api/System.Net.IPAddress *

* * Powered by JCOBridge: more info at https://www.jcobridge.com * * @author MASES s.r.l https://masesgroup.com * @version 1.15.0.0 */ public class IPAddress extends NetObject implements system.IFormattable { /** * Fully assembly qualified name: System.Net.Primitives, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a */ public static final String assemblyFullName = "System.Net.Primitives, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; /** * Assembly name: System.Net.Primitives */ public static final String assemblyShortName = "System.Net.Primitives"; /** * Qualified class name: System.Net.IPAddress */ public static final String className = "System.Net.IPAddress"; static JCOBridge bridge = JCOBridgeInstance.getInstance(assemblyFullName); /** * The type managed from JCOBridge. See {@link JCType} */ public static JCType classType = createType(); static JCEnum enumInstance = null; JCObject classInstance = null; static JCType createType() { try { String classToCreate = className + ", " + (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName); if (JCOReflector.getDebug()) JCOReflector.writeLog("Creating %s", classToCreate); JCType typeCreated = bridge.GetType(classToCreate); if (JCOReflector.getDebug()) JCOReflector.writeLog("Created: %s", (typeCreated != null) ? typeCreated.toString() : "Returned null value"); return typeCreated; } catch (JCException e) { JCOReflector.writeLog(e); return null; } } void addReference(String ref) throws Throwable { try { bridge.AddReference(ref); } catch (JCNativeException jcne) { throw translateException(jcne); } } /** * Internal constructor. Use with caution */ public IPAddress(java.lang.Object instance) throws Throwable { super(instance); if (instance instanceof JCObject) { classInstance = (JCObject) instance; } else throw new Exception("Cannot manage object, it is not a JCObject"); } public String getJCOAssemblyName() { return assemblyFullName; } public String getJCOClassName() { return className; } public String getJCOObjectName() { return className + ", " + (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName); } public java.lang.Object getJCOInstance() { return classInstance; } public void setJCOInstance(JCObject instance) { classInstance = instance; super.setJCOInstance(classInstance); } public JCType getJCOType() { return classType; } /** * Try to cast the {@link IJCOBridgeReflected} instance into {@link IPAddress}, a cast assert is made to check if types are compatible. * @param from {@link IJCOBridgeReflected} instance to be casted * @return {@link IPAddress} instance * @throws java.lang.Throwable in case of error during cast operation */ public static IPAddress cast(IJCOBridgeReflected from) throws Throwable { NetType.AssertCast(classType, from); return new IPAddress(from.getJCOInstance()); } // Constructors section public IPAddress() throws Throwable { } public IPAddress(byte[] address, long scopeid) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.IndexOutOfRangeException, system.FormatException { try { // add reference to assemblyName.dll file addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName); setJCOInstance((JCObject)classType.NewObject(address, scopeid)); } catch (JCNativeException jcne) { throw translateException(jcne); } } public IPAddress(byte[] address) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.IndexOutOfRangeException { try { // add reference to assemblyName.dll file addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName); setJCOInstance((JCObject)classType.NewObject((java.lang.Object)address)); } catch (JCNativeException jcne) { throw translateException(jcne); } } public IPAddress(long newAddress) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.IndexOutOfRangeException, system.FormatException { try { // add reference to assemblyName.dll file addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName); setJCOInstance((JCObject)classType.NewObject(newAddress)); } catch (JCNativeException jcne) { throw translateException(jcne); } } // Methods section public static boolean IsLoopback(IPAddress address) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.ArgumentNullException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (boolean)classType.Invoke("IsLoopback", address == null ? null : address.getJCOInstance()); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static boolean TryParse(java.lang.String ipString, JCORefOut address) throws Throwable, system.ArgumentException, system.NotSupportedException, system.InvalidOperationException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.NullReferenceException, system.ArgumentNullException, system.OutOfMemoryException, system.FormatException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (boolean)classType.Invoke("TryParse", ipString, address.getJCRefOut()); } catch (JCNativeException jcne) { throw translateException(jcne); } } public byte[] GetAddressBytes() throws Throwable, system.ArgumentException, system.NotSupportedException, system.InvalidOperationException, system.ArgumentOutOfRangeException, system.ArrayTypeMismatchException, system.PlatformNotSupportedException { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { ArrayList resultingArrayList = new ArrayList(); JCObject resultingObjects = (JCObject)classInstance.Invoke("GetAddressBytes"); for (java.lang.Object resultingObject : resultingObjects) { resultingArrayList.add(resultingObject); } byte[] resultingArray = new byte[resultingArrayList.size()]; for(int indexGetAddressBytes = 0; indexGetAddressBytes < resultingArrayList.size(); indexGetAddressBytes++ ) { resultingArray[indexGetAddressBytes] = (byte)resultingArrayList.get(indexGetAddressBytes); } return resultingArray; } catch (JCNativeException jcne) { throw translateException(jcne); } } public static short HostToNetworkOrder(short host) throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (short)classType.Invoke("HostToNetworkOrder", host); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static short NetworkToHostOrder(short network) throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (short)classType.Invoke("NetworkToHostOrder", network); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static int HostToNetworkOrder(int host) throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (int)classType.Invoke("HostToNetworkOrder", host); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static int NetworkToHostOrder(int network) throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (int)classType.Invoke("NetworkToHostOrder", network); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static long HostToNetworkOrder(long host) throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (long)classType.Invoke("HostToNetworkOrder", host); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static long NetworkToHostOrder(long network) throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (long)classType.Invoke("NetworkToHostOrder", network); } catch (JCNativeException jcne) { throw translateException(jcne); } } public IPAddress MapToIPv4() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.IndexOutOfRangeException, system.FormatException { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { JCObject objMapToIPv4 = (JCObject)classInstance.Invoke("MapToIPv4"); return new IPAddress(objMapToIPv4); } catch (JCNativeException jcne) { throw translateException(jcne); } } public IPAddress MapToIPv6() throws Throwable { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { JCObject objMapToIPv6 = (JCObject)classInstance.Invoke("MapToIPv6"); return new IPAddress(objMapToIPv6); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static IPAddress Parse(java.lang.String ipString) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.ArgumentNullException, system.IndexOutOfRangeException, system.NullReferenceException, system.OutOfMemoryException, system.FormatException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { JCObject objParse = (JCObject)classType.Invoke("Parse", ipString); return new IPAddress(objParse); } catch (JCNativeException jcne) { throw translateException(jcne); } } /** * @deprecated Not for public use because the method is implemented in .NET with an explicit interface. * Use the static ToIFormattable method available in IFormattable to obtain an object with an invocable method */ @Deprecated public java.lang.String ToString(java.lang.String format, IFormatProvider formatProvider) throws Throwable { throw new UnsupportedOperationException("Not for public use because the method is implemented with an explicit interface. Use ToIFormattable to obtain the full interface."); } // Properties section public boolean getIsIPv4MappedToIPv6() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.IndexOutOfRangeException { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { return (boolean)classInstance.Get("IsIPv4MappedToIPv6"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public boolean getIsIPv6LinkLocal() throws Throwable { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { return (boolean)classInstance.Get("IsIPv6LinkLocal"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public boolean getIsIPv6Multicast() throws Throwable { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { return (boolean)classInstance.Get("IsIPv6Multicast"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public boolean getIsIPv6SiteLocal() throws Throwable { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { return (boolean)classInstance.Get("IsIPv6SiteLocal"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public boolean getIsIPv6Teredo() throws Throwable { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { return (boolean)classInstance.Get("IsIPv6Teredo"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public boolean getIsIPv6UniqueLocal() throws Throwable { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { return (boolean)classInstance.Get("IsIPv6UniqueLocal"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public long getAddress() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.FormatException, system.InvalidOperationException, system.net.sockets.SocketException { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { return (long)classInstance.Get("Address"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public void setAddress(long Address) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.FormatException, system.InvalidOperationException, system.net.sockets.SocketException { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { classInstance.Set("Address", Address); } catch (JCNativeException jcne) { throw translateException(jcne); } } public long getScopeId() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.FormatException, system.InvalidOperationException, system.net.sockets.SocketException { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { return (long)classInstance.Get("ScopeId"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public void setScopeId(long ScopeId) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.FormatException, system.InvalidOperationException, system.net.sockets.SocketException, system.ArgumentNullException, system.NotSupportedException { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { classInstance.Set("ScopeId", ScopeId); } catch (JCNativeException jcne) { throw translateException(jcne); } } public AddressFamily getAddressFamily() throws Throwable { if (classInstance == null) throw new UnsupportedOperationException("classInstance is null."); try { JCObject val = (JCObject)classInstance.Get("AddressFamily"); return new AddressFamily(val); } catch (JCNativeException jcne) { throw translateException(jcne); } } // Instance Events section }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy