This commit is contained in:
Robert Vokac 2024-12-20 18:10:02 +01:00
parent 5c1033bdb3
commit 0c825f6b5f
Signed by: robertvokac
GPG Key ID: FB9CE8E20AADA55F
17 changed files with 313 additions and 9 deletions

View File

@ -0,0 +1,22 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
/**
*
* @author robertvokac
*/
public class Default_ {
private Default_() {
//Not meant to be instantiated.
}
public static <T extends Struct<T>> T default_(T instance) {
instance.reset();
return instance;
}
}

View File

@ -0,0 +1,24 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @author robertvokac
* Simulates the C# key word namespace.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@AdditionalClassForDotNetSimulation
public @interface Namespace {
String name();
}

View File

@ -13,12 +13,12 @@ import java.lang.annotation.Target;
/**
*
* @author robertvokac
* Simulates the C# key word default.
* Simulates the C# key word ?.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.LOCAL_VARIABLE)
@Target(ElementType.PARAMETER)
@AdditionalClassForDotNetSimulation
public @interface Default {
public @interface Nullable {
String description() default "";
}

View File

@ -0,0 +1,24 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @author robertvokac
* Simulates the C# key word ref.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@AdditionalClassForDotNetSimulation
public @interface Ref {
String description() default "";
}

View File

@ -2,7 +2,7 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.System;
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;

View File

@ -0,0 +1,13 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.JDotNet.Microsoft.Devices.Sensors;
/**
*
* @author robertvokac
*/
public class AccelerometerFailedException extends SensorFailedException{
}

View File

@ -0,0 +1,15 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.JDotNet.Microsoft.Devices.Sensors;
import com.openeggbert.jdotnet.System.Exception_;
/**
*
* @author robertvokac
*/
public class SensorFailedException extends Exception_{
}

View File

@ -0,0 +1,60 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.System.Collections.Generic;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import lombok.NoArgsConstructor;
/**
*
* @author robertvokac
*/
@NoArgsConstructor
public class List_<T> implements Iterable<T> {
private final List<T> internalList = new ArrayList<>();
public List_ (List_<T> oldList) {
for (T item : oldList) {
Add(item);
}
}
public void Clear() {
internalList.clear();
}
public T ElementAt(int i) {
return internalList.get(i);
}
public T Add(T item) {
internalList.add(item);
return item;
}
public T YieldReturn(T item) {
return Add(item);
}
@Override
public Iterator<T> iterator() {
return internalList.iterator();
}
public Iterable<T> Reverse() {
List_<T> copy = new List_(this);
Collections.reverse(copy.internalList);
return copy.internalList;
}
public boolean Contains(T o) {
return internalList.contains(o);
}
}

View File

@ -9,6 +9,9 @@ package com.openeggbert.jdotnet.System.Diagnostics;
* @author robertvokac
*/
public class Debug {
public static void WriteLine(String msg) {
Write(msg + "\n");
}
public static void Write(String msg) {
//todo
}

View File

@ -9,5 +9,7 @@ package com.openeggbert.jdotnet.System;
* @author robertvokac
*/
public interface IDisposable {
void Dispose();
}

View File

@ -4,16 +4,68 @@
*/
package com.openeggbert.jdotnet.System;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.Getter;
/**
*
* @author robertvokac
*/
public class String_ {
private String_() {
protected String_() {
//Not meant to be instantiated.
}
@Getter
private String value;
public static boolean IsNullOrEmpty(String string) {
return string == null || string.isEmpty();
}
public static String Format(String template, Object... args) {
if (template == null || args == null) {
throw new IllegalArgumentException("Template and arguments must not be null.");
}
Pattern pattern = Pattern.compile("\\{(\\d+)}");
Matcher matcher = pattern.matcher(template);
StringBuffer result = new StringBuffer();
while (matcher.find()) {
String placeholder = matcher.group(1);
int index = Integer.parseInt(placeholder);
if (index < 0 || index >= args.length) {
throw new IllegalArgumentException("Placeholder index out of range: " + index);
}
matcher.appendReplacement(result, args[index].toString());
}
// Přidej zbývající část šablony
matcher.appendTail(result);
return result.toString();
}
public String_(char ch, int times) {
if(times < 0) {
throw new Exception_("times cannot be less than 0");
}
if(times == 0) {value = "";return;}
if(times == 1) {value = String.valueOf(ch); return;}
StringBuilder sb = new StringBuilder();
for(int i = 0;i< times;i++) {
sb.append(ch);
}
value = sb.toString();
}
@Override
public String toString() {
return getValue();
}
}

View File

@ -0,0 +1,14 @@
package com.openeggbert.jdotnet.System;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
/**
*
* @author robertvokac
*/
public class SystemException extends Exception_{
}

View File

@ -4,11 +4,32 @@
*/
package com.openeggbert.jdotnet.System;
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.Struct;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
/**
*
* @author robertvokac
*/
public class TimeSpan {
@AllArgsConstructor
@NoArgsConstructor
public class TimeSpan extends Struct<TimeSpan> {
public static TimeSpan FromTicks(long ticks) {return null;}
public static TimeSpan FromSeconds(double seconds) {return null;}
private long _ticks;
public long Ticks() {
return this._ticks;
}
@Override
public TimeSpan copy() {
return new TimeSpan(_ticks);
}
@Override
public TimeSpan reset() {
this._ticks = 0l;
return this;
}
}

View File

@ -0,0 +1,21 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.System;
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.Const;
/**
*
* @author robertvokac
*/
public class UInt32 {
protected UInt32() {
//Not meant to be instantiated.
}
public @Const static final long MaxValue = 0xFFFFFFFFL; // 32-bit unsigned maximum value
public @Const static final long MinValue = 0;
}

View File

@ -0,0 +1,14 @@
package com.openeggbert.jdotnet.System;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
/**
*
* @author robertvokac
*/
public class UnauthorizedAccessException extends SystemException {
}

View File

@ -2,12 +2,14 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.System.Collections.Generic;
package com.openeggbert.jdotnet.System;
/**
*
* @author robertvokac
*/
public class NewClass {
public class string extends String_ {
}

View File

@ -0,0 +1,17 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.openeggbert.jdotnet.System;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.Getter;
/**
*
* @author robertvokac
*/
public class uint extends UInt32 {
}