repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
|---|---|---|---|---|---|---|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/items/TransportRodItem.java
|
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
|
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import static com.latenighters.runicarcana.util.Util.checkHeadspace;
|
package com.latenighters.runicarcana.common.items;
public class TransportRodItem extends Item {
public static final float teleRange = 128.0f;
public static final int maxBlocksSearched = 5;
public static boolean didAltTeleport = false;
public TransportRodItem() {
super(new Properties()
.maxStackSize(1)
|
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
// Path: src/main/java/com/latenighters/runicarcana/common/items/TransportRodItem.java
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import static com.latenighters.runicarcana.util.Util.checkHeadspace;
package com.latenighters.runicarcana.common.items;
public class TransportRodItem extends Item {
public static final float teleRange = 128.0f;
public static final int maxBlocksSearched = 5;
public static boolean didAltTeleport = false;
public TransportRodItem() {
super(new Properties()
.maxStackSize(1)
|
.group(ModSetup.ITEM_GROUP)
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/items/TransportRodItem.java
|
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
|
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import static com.latenighters.runicarcana.util.Util.checkHeadspace;
|
package com.latenighters.runicarcana.common.items;
public class TransportRodItem extends Item {
public static final float teleRange = 128.0f;
public static final int maxBlocksSearched = 5;
public static boolean didAltTeleport = false;
public TransportRodItem() {
super(new Properties()
.maxStackSize(1)
.group(ModSetup.ITEM_GROUP)
);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
|
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
// Path: src/main/java/com/latenighters/runicarcana/common/items/TransportRodItem.java
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import static com.latenighters.runicarcana.util.Util.checkHeadspace;
package com.latenighters.runicarcana.common.items;
public class TransportRodItem extends Item {
public static final float teleRange = 128.0f;
public static final int maxBlocksSearched = 5;
public static boolean didAltTeleport = false;
public TransportRodItem() {
super(new Properties()
.maxStackSize(1)
.group(ModSetup.ITEM_GROUP)
);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
|
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.transport_rod.1"));
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/items/TransportRodItem.java
|
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
|
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import static com.latenighters.runicarcana.util.Util.checkHeadspace;
|
super(new Properties()
.maxStackSize(1)
.group(ModSetup.ITEM_GROUP)
);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.transport_rod.1"));
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.transport_rod.2", (int) teleRange, maxBlocksSearched));
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.transport_rod.3"));
tooltip.add(Util.loreStyle("lore.runicarcana.transport_rod"));
}
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
if (!playerIn.isSteppingCarefully() && !didAltTeleport){
Vec3d lookVec = playerIn.getLookVec();
Vec3d start = new Vec3d(playerIn.getPosX(), playerIn.getPosY() + playerIn.getEyeHeight(), playerIn.getPosZ());
Vec3d end = start.add(lookVec.x * teleRange, lookVec.y * teleRange, lookVec.z * teleRange);
BlockRayTraceResult raytrace = worldIn.rayTraceBlocks(
new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, playerIn)
);
BlockPos pos = raytrace.getPos();
for (int i=0; i < maxBlocksSearched; i++){
// Check two blocks to insure no suffocation.
BlockPos adjustedPos = new BlockPos(pos.getX(), pos.getY() + i, pos.getZ());
|
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
// Path: src/main/java/com/latenighters/runicarcana/common/items/TransportRodItem.java
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import static com.latenighters.runicarcana.util.Util.checkHeadspace;
super(new Properties()
.maxStackSize(1)
.group(ModSetup.ITEM_GROUP)
);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.transport_rod.1"));
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.transport_rod.2", (int) teleRange, maxBlocksSearched));
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.transport_rod.3"));
tooltip.add(Util.loreStyle("lore.runicarcana.transport_rod"));
}
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
if (!playerIn.isSteppingCarefully() && !didAltTeleport){
Vec3d lookVec = playerIn.getLookVec();
Vec3d start = new Vec3d(playerIn.getPosX(), playerIn.getPosY() + playerIn.getEyeHeight(), playerIn.getPosZ());
Vec3d end = start.add(lookVec.x * teleRange, lookVec.y * teleRange, lookVec.z * teleRange);
BlockRayTraceResult raytrace = worldIn.rayTraceBlocks(
new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, playerIn)
);
BlockPos pos = raytrace.getPos();
for (int i=0; i < maxBlocksSearched; i++){
// Check two blocks to insure no suffocation.
BlockPos adjustedPos = new BlockPos(pos.getX(), pos.getY() + i, pos.getZ());
|
if (checkHeadspace(worldIn, adjustedPos)) {
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/symbols/DebugSymbol.java
|
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/categories/SymbolCategory.java
// public class SymbolCategory {
//
// public static SymbolCategory DEFAULT = new SymbolCategory(Symbols.DEBUG, MODID+".symbol.category.default");
//
// private Symbol displaySymbol;
// private final String unlocalizedName;
//
// public static void generateCategories()
// {
// //TODO figure out why static initialization isn't working
// DEFAULT.setDisplaySymbol(Symbols.EXPULSION);
// }
//
// public SymbolCategory(Symbol displaySymbol, String unlocalizedName) {
// this.displaySymbol = displaySymbol;
// this.unlocalizedName = unlocalizedName;
// }
//
// public Symbol getDisplaySymbol() {
// return displaySymbol;
// }
//
// public void setDisplaySymbol(Symbol displaySymbol) {
// this.displaySymbol = displaySymbol;
// }
//
// public String getUnlocalizedName() {
// return unlocalizedName;
// }
// }
|
import com.google.common.collect.Lists;
import com.latenighters.runicarcana.common.symbols.backend.*;
import com.latenighters.runicarcana.common.symbols.categories.SymbolCategory;
import net.minecraft.entity.item.FireworkRocketEntity;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import java.util.ArrayList;
import java.util.List;
|
package com.latenighters.runicarcana.common.symbols;
public class DebugSymbol extends Symbol {
public DebugSymbol() {
|
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/categories/SymbolCategory.java
// public class SymbolCategory {
//
// public static SymbolCategory DEFAULT = new SymbolCategory(Symbols.DEBUG, MODID+".symbol.category.default");
//
// private Symbol displaySymbol;
// private final String unlocalizedName;
//
// public static void generateCategories()
// {
// //TODO figure out why static initialization isn't working
// DEFAULT.setDisplaySymbol(Symbols.EXPULSION);
// }
//
// public SymbolCategory(Symbol displaySymbol, String unlocalizedName) {
// this.displaySymbol = displaySymbol;
// this.unlocalizedName = unlocalizedName;
// }
//
// public Symbol getDisplaySymbol() {
// return displaySymbol;
// }
//
// public void setDisplaySymbol(Symbol displaySymbol) {
// this.displaySymbol = displaySymbol;
// }
//
// public String getUnlocalizedName() {
// return unlocalizedName;
// }
// }
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/DebugSymbol.java
import com.google.common.collect.Lists;
import com.latenighters.runicarcana.common.symbols.backend.*;
import com.latenighters.runicarcana.common.symbols.categories.SymbolCategory;
import net.minecraft.entity.item.FireworkRocketEntity;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import java.util.ArrayList;
import java.util.List;
package com.latenighters.runicarcana.common.symbols;
public class DebugSymbol extends Symbol {
public DebugSymbol() {
|
super("symbol_debug", SymbolTextures.DEBUG, SymbolCategory.DEFAULT);
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/symbols/backend/SymbolRegistryHandler.java
|
// Path: src/main/java/com/latenighters/runicarcana/RunicArcana.java
// public static final String MODID = "runicarcana";
|
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryInternal;
import net.minecraftforge.registries.RegistryBuilder;
import net.minecraftforge.registries.RegistryManager;
import org.jline.utils.Log;
import javax.annotation.Nullable;
import static com.latenighters.runicarcana.RunicArcana.MODID;
|
package com.latenighters.runicarcana.common.symbols.backend;
public class SymbolRegistryHandler {
public static final IForgeRegistry<Symbol> SYMBOLS = RegistryManager.ACTIVE.getRegistry(Symbol.class);
|
// Path: src/main/java/com/latenighters/runicarcana/RunicArcana.java
// public static final String MODID = "runicarcana";
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/backend/SymbolRegistryHandler.java
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryInternal;
import net.minecraftforge.registries.RegistryBuilder;
import net.minecraftforge.registries.RegistryManager;
import org.jline.utils.Log;
import javax.annotation.Nullable;
import static com.latenighters.runicarcana.RunicArcana.MODID;
package com.latenighters.runicarcana.common.symbols.backend;
public class SymbolRegistryHandler {
public static final IForgeRegistry<Symbol> SYMBOLS = RegistryManager.ACTIVE.getRegistry(Symbol.class);
|
public static final ResourceLocation SYMBOLS_RL = new ResourceLocation(MODID, "symbols");
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/items/armor/PrincipicLeggingsItem.java
|
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
|
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.List;
|
package com.latenighters.runicarcana.common.items.armor;
public class PrincipicLeggingsItem extends AbstractPrincipicArmor {
public PrincipicLeggingsItem() {
super(EquipmentSlotType.LEGS);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
if(isEnabled(stack))
|
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
// Path: src/main/java/com/latenighters/runicarcana/common/items/armor/PrincipicLeggingsItem.java
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.List;
package com.latenighters.runicarcana.common.items.armor;
public class PrincipicLeggingsItem extends AbstractPrincipicArmor {
public PrincipicLeggingsItem() {
super(EquipmentSlotType.LEGS);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
if(isEnabled(stack))
|
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.principic_leggings.effect_enabled"));
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/items/DebugItem.java
|
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
|
import com.latenighters.runicarcana.common.setup.ModSetup;
import net.minecraft.entity.item.FireworkRocketEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
|
package com.latenighters.runicarcana.common.items;
public class DebugItem extends Item {
public DebugItem() {
|
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
// Path: src/main/java/com/latenighters/runicarcana/common/items/DebugItem.java
import com.latenighters.runicarcana.common.setup.ModSetup;
import net.minecraft.entity.item.FireworkRocketEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
package com.latenighters.runicarcana.common.items;
public class DebugItem extends Item {
public DebugItem() {
|
super(new Properties().group(ModSetup.ITEM_GROUP).maxStackSize(1));
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/symbols/InsertionSymbol.java
|
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/categories/SymbolCategory.java
// public class SymbolCategory {
//
// public static SymbolCategory DEFAULT = new SymbolCategory(Symbols.DEBUG, MODID+".symbol.category.default");
//
// private Symbol displaySymbol;
// private final String unlocalizedName;
//
// public static void generateCategories()
// {
// //TODO figure out why static initialization isn't working
// DEFAULT.setDisplaySymbol(Symbols.EXPULSION);
// }
//
// public SymbolCategory(Symbol displaySymbol, String unlocalizedName) {
// this.displaySymbol = displaySymbol;
// this.unlocalizedName = unlocalizedName;
// }
//
// public Symbol getDisplaySymbol() {
// return displaySymbol;
// }
//
// public void setDisplaySymbol(Symbol displaySymbol) {
// this.displaySymbol = displaySymbol;
// }
//
// public String getUnlocalizedName() {
// return unlocalizedName;
// }
// }
|
import com.latenighters.runicarcana.common.symbols.backend.*;
import com.latenighters.runicarcana.common.symbols.categories.SymbolCategory;
import net.minecraft.world.chunk.Chunk;
import java.util.ArrayList;
import java.util.List;
|
package com.latenighters.runicarcana.common.symbols;
public class InsertionSymbol extends Symbol {
public InsertionSymbol() {
|
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/categories/SymbolCategory.java
// public class SymbolCategory {
//
// public static SymbolCategory DEFAULT = new SymbolCategory(Symbols.DEBUG, MODID+".symbol.category.default");
//
// private Symbol displaySymbol;
// private final String unlocalizedName;
//
// public static void generateCategories()
// {
// //TODO figure out why static initialization isn't working
// DEFAULT.setDisplaySymbol(Symbols.EXPULSION);
// }
//
// public SymbolCategory(Symbol displaySymbol, String unlocalizedName) {
// this.displaySymbol = displaySymbol;
// this.unlocalizedName = unlocalizedName;
// }
//
// public Symbol getDisplaySymbol() {
// return displaySymbol;
// }
//
// public void setDisplaySymbol(Symbol displaySymbol) {
// this.displaySymbol = displaySymbol;
// }
//
// public String getUnlocalizedName() {
// return unlocalizedName;
// }
// }
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/InsertionSymbol.java
import com.latenighters.runicarcana.common.symbols.backend.*;
import com.latenighters.runicarcana.common.symbols.categories.SymbolCategory;
import net.minecraft.world.chunk.Chunk;
import java.util.ArrayList;
import java.util.List;
package com.latenighters.runicarcana.common.symbols;
public class InsertionSymbol extends Symbol {
public InsertionSymbol() {
|
super("symbol_insertion", SymbolTextures.INSERT, SymbolCategory.DEFAULT);
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/items/trinkets/EliminationRingItem.java
|
// Path: src/main/java/com/latenighters/runicarcana/capabilities/BasicCurioProvider.java
// public class BasicCurioProvider implements ICapabilityProvider {
//
// final LazyOptional<ICurio> capability;
//
// public BasicCurioProvider(ICurio curio) {
//
// this.capability = LazyOptional.of(() -> curio);
// }
//
// @SuppressWarnings("ConstantConditions")
// @Nonnull
// @Override
// public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
//
// return CuriosCapability.ITEM.orEmpty(cap, capability);
// }
// }
//
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
|
import com.latenighters.runicarcana.capabilities.BasicCurioProvider;
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.monster.IMob;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import top.theillusivec4.curios.api.capability.ICurio;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
|
package com.latenighters.runicarcana.common.items.trinkets;
public class EliminationRingItem extends Item {
private static final int range = 10;
public EliminationRingItem() {
super(new Properties()
.maxStackSize(1)
|
// Path: src/main/java/com/latenighters/runicarcana/capabilities/BasicCurioProvider.java
// public class BasicCurioProvider implements ICapabilityProvider {
//
// final LazyOptional<ICurio> capability;
//
// public BasicCurioProvider(ICurio curio) {
//
// this.capability = LazyOptional.of(() -> curio);
// }
//
// @SuppressWarnings("ConstantConditions")
// @Nonnull
// @Override
// public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
//
// return CuriosCapability.ITEM.orEmpty(cap, capability);
// }
// }
//
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
// Path: src/main/java/com/latenighters/runicarcana/common/items/trinkets/EliminationRingItem.java
import com.latenighters.runicarcana.capabilities.BasicCurioProvider;
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.monster.IMob;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import top.theillusivec4.curios.api.capability.ICurio;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
package com.latenighters.runicarcana.common.items.trinkets;
public class EliminationRingItem extends Item {
private static final int range = 10;
public EliminationRingItem() {
super(new Properties()
.maxStackSize(1)
|
.group(ModSetup.ITEM_GROUP)
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/items/trinkets/EliminationRingItem.java
|
// Path: src/main/java/com/latenighters/runicarcana/capabilities/BasicCurioProvider.java
// public class BasicCurioProvider implements ICapabilityProvider {
//
// final LazyOptional<ICurio> capability;
//
// public BasicCurioProvider(ICurio curio) {
//
// this.capability = LazyOptional.of(() -> curio);
// }
//
// @SuppressWarnings("ConstantConditions")
// @Nonnull
// @Override
// public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
//
// return CuriosCapability.ITEM.orEmpty(cap, capability);
// }
// }
//
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
|
import com.latenighters.runicarcana.capabilities.BasicCurioProvider;
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.monster.IMob;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import top.theillusivec4.curios.api.capability.ICurio;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
|
package com.latenighters.runicarcana.common.items.trinkets;
public class EliminationRingItem extends Item {
private static final int range = 10;
public EliminationRingItem() {
super(new Properties()
.maxStackSize(1)
.group(ModSetup.ITEM_GROUP)
);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
|
// Path: src/main/java/com/latenighters/runicarcana/capabilities/BasicCurioProvider.java
// public class BasicCurioProvider implements ICapabilityProvider {
//
// final LazyOptional<ICurio> capability;
//
// public BasicCurioProvider(ICurio curio) {
//
// this.capability = LazyOptional.of(() -> curio);
// }
//
// @SuppressWarnings("ConstantConditions")
// @Nonnull
// @Override
// public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
//
// return CuriosCapability.ITEM.orEmpty(cap, capability);
// }
// }
//
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
// Path: src/main/java/com/latenighters/runicarcana/common/items/trinkets/EliminationRingItem.java
import com.latenighters.runicarcana.capabilities.BasicCurioProvider;
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.monster.IMob;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import top.theillusivec4.curios.api.capability.ICurio;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
package com.latenighters.runicarcana.common.items.trinkets;
public class EliminationRingItem extends Item {
private static final int range = 10;
public EliminationRingItem() {
super(new Properties()
.maxStackSize(1)
.group(ModSetup.ITEM_GROUP)
);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
|
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.elimination_ring", range));
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/items/trinkets/EliminationRingItem.java
|
// Path: src/main/java/com/latenighters/runicarcana/capabilities/BasicCurioProvider.java
// public class BasicCurioProvider implements ICapabilityProvider {
//
// final LazyOptional<ICurio> capability;
//
// public BasicCurioProvider(ICurio curio) {
//
// this.capability = LazyOptional.of(() -> curio);
// }
//
// @SuppressWarnings("ConstantConditions")
// @Nonnull
// @Override
// public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
//
// return CuriosCapability.ITEM.orEmpty(cap, capability);
// }
// }
//
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
|
import com.latenighters.runicarcana.capabilities.BasicCurioProvider;
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.monster.IMob;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import top.theillusivec4.curios.api.capability.ICurio;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
|
package com.latenighters.runicarcana.common.items.trinkets;
public class EliminationRingItem extends Item {
private static final int range = 10;
public EliminationRingItem() {
super(new Properties()
.maxStackSize(1)
.group(ModSetup.ITEM_GROUP)
);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.elimination_ring", range));
tooltip.add(Util.loreStyle("lore.runicarcana.elimination_ring"));
}
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT unused) {
|
// Path: src/main/java/com/latenighters/runicarcana/capabilities/BasicCurioProvider.java
// public class BasicCurioProvider implements ICapabilityProvider {
//
// final LazyOptional<ICurio> capability;
//
// public BasicCurioProvider(ICurio curio) {
//
// this.capability = LazyOptional.of(() -> curio);
// }
//
// @SuppressWarnings("ConstantConditions")
// @Nonnull
// @Override
// public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
//
// return CuriosCapability.ITEM.orEmpty(cap, capability);
// }
// }
//
// Path: src/main/java/com/latenighters/runicarcana/common/setup/ModSetup.java
// public class ModSetup {
//
// public static final ItemGroup ITEM_GROUP = new ItemGroup(RunicArcana.MODID) {
// @Override
// public ItemStack createIcon() {
// return new ItemStack(Registration.CHALK.get());
// }
// };
// }
//
// Path: src/main/java/com/latenighters/runicarcana/util/Util.java
// public class Util {
//
// public static ITextComponent loreStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.DARK_PURPLE).applyTextStyle(TextFormatting.ITALIC);
// }
//
// public static ITextComponent loreStyle(String key, Object...args){
// return loreStyle(new TranslationTextComponent(key, args));
// }
//
// public static ITextComponent tooltipStyle(ITextComponent textComponent){
// return textComponent.applyTextStyle(TextFormatting.GRAY);
// }
//
// public static ITextComponent tooltipStyle(String key, Object... args){
// return tooltipStyle(new TranslationTextComponent(key, args));
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z, Float yaw, Float pitch) {
// entity.setPositionAndUpdate(x, y, z);
// entity.setPositionAndRotation(x, y, z, yaw, pitch);
// }
//
// public static void setPositionAndRotationAndUpdate(Entity entity, Double x, Double y, Double z){
// setPositionAndRotationAndUpdate(entity, x, y, z, entity.rotationYaw, entity.rotationPitch);
// }
//
// public static boolean checkHeadspace(World world, BlockPos pos){
// return world.isAirBlock(pos) && world.isAirBlock(pos.up());
// }
//
// public static void spawnParticleGroup(World world, BasicParticleType type, LivingEntity entity) {
// final Random rand = new Random();
// if (world.isRemote) {
// for (int i = 0; i < 30; ++i) {
// double d0 = rand.nextGaussian() * 0.02D;
// double d1 = rand.nextGaussian() * 0.02D;
// double d2 = rand.nextGaussian() * 0.02D;
// world.addParticle(
// type,
// entity.getPosX() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d0 * 10.0D,
// entity.getPosY() + (double) (rand.nextFloat() * entity.getHeight()) - d1 * 10.0D,
// entity.getPosZ() + (double) (rand.nextFloat() * entity.getWidth() * 2.0F) - (double) entity.getWidth() - d2 * 10.0D, d0, d1, d2
// );
// }
//
// }
// }
//
// }
// Path: src/main/java/com/latenighters/runicarcana/common/items/trinkets/EliminationRingItem.java
import com.latenighters.runicarcana.capabilities.BasicCurioProvider;
import com.latenighters.runicarcana.common.setup.ModSetup;
import com.latenighters.runicarcana.util.Util;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.monster.IMob;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import top.theillusivec4.curios.api.capability.ICurio;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
package com.latenighters.runicarcana.common.items.trinkets;
public class EliminationRingItem extends Item {
private static final int range = 10;
public EliminationRingItem() {
super(new Properties()
.maxStackSize(1)
.group(ModSetup.ITEM_GROUP)
);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
tooltip.add(Util.tooltipStyle("tooltip.runicarcana.elimination_ring", range));
tooltip.add(Util.loreStyle("lore.runicarcana.elimination_ring"));
}
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT unused) {
|
return new BasicCurioProvider(new ICurio() {
|
Drazuam/RunicArcana
|
src/main/java/com/latenighters/runicarcana/common/symbols/categories/SymbolCategory.java
|
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/Symbols.java
// public class Symbols {
//
// @ObjectHolder("runicarcana:symbol_debug")
// public static final Symbol DEBUG = null;
//
// @ObjectHolder("runicarcana:symbol_expulsion")
// public static final Symbol EXPULSION = null;
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/backend/Symbol.java
// public abstract class Symbol extends net.minecraftforge.registries.ForgeRegistryEntry<Symbol> {
//
// protected String name;
// protected ResourceLocation texture;
// protected int id = -1;
// protected final SymbolCategory category;
//
// protected List<IFunctional> functions = new ArrayList<IFunctional>();
// protected List<HashableTuple<String,DataType>> inputs = new ArrayList<HashableTuple<String,DataType>>();
// protected List<IFunctional> outputs = new ArrayList<IFunctional>();
// protected List<HashableTuple<HashableTuple<String, DataType>, IFunctional>> triggers = new ArrayList<HashableTuple<HashableTuple<String, DataType>, IFunctional>>();
//
// public Symbol(String name, ResourceLocation texture, SymbolCategory category) {
// this.name = name;
// this.texture = texture;
// this.category = category;
// this.setRegistryName(new ResourceLocation(MODID, this.name));
//
// this.registerFunctions();
//
// //roll up the functions into the functional object fields
// for (IFunctional function : functions)
// {
// //synchronize the inputs from all the functions
// for(HashableTuple<String,DataType> input : inputs) {
// //check to see if inputs already has the same DataType and String registered
// if(function.getRequiredInputs()==null)return;
// function.getRequiredInputs().removeIf(finput ->
// {
// if (function.getRequiredInputs().contains(finput)) return false;
// if (input.getA().equals(finput.getA()) && input.getB().type.equals(finput.getB().type)) {
// //if we do, remove the input from the function and replace it with the already registered input
// function.getRequiredInputs().add(input);
// return true;
// }
// return false;
// });
// }
//
// //add each input into the object inputs
// if(function.getRequiredInputs()!=null)
// function.getRequiredInputs().forEach(finput->{
// if(!inputs.contains(finput))
// inputs.add(finput);
// });
// }
//
// //repeat for outputs
// for (IFunctional function : outputs)
// {
// //synchronize the inputs from all the functions
// for(HashableTuple<String,DataType> input : inputs) {
// //check to see if inputs already has the same DataType and String registered
// if(function.getRequiredInputs()==null)return;
// function.getRequiredInputs().removeIf(finput ->
// {
// if (function.getRequiredInputs().contains(finput)) return false;
// if (input.getA().equals(finput.getA()) && input.getB().type.equals(finput.getB().type)) {
// //if we do, remove the input from the function and replace it with the already registered input
// function.getRequiredInputs().add(input);
// return true;
// }
// return false;
// });
// }
//
// //add each input into the object inputs
// if(function.getRequiredInputs()!=null)
// function.getRequiredInputs().forEach(finput->{
// if(!inputs.contains(finput))
// inputs.add(finput);
// });
// }
// }
//
// public Symbol(String name)
// {
// this(name, SymbolTextures.DEBUG, SymbolCategory.DEFAULT);
// }
//
// public String getName()
// {
// return name;
// }
//
// public ResourceLocation getTexture() {
// return texture;
// }
//
// //we really shouldn't be using this
// public void onTick(DrawnSymbol symbol, World world, Chunk chunk, BlockPos drawnOn, Direction blockFace) {
//
// }
//
// protected abstract void registerFunctions();
//
// public List<IFunctional> getFunctions() {
// return functions;
// }
//
// public List<HashableTuple<String,DataType>> getInputs(){
// return inputs;
// }
//
// public List<IFunctional> getOutputs() {
// return outputs;
// }
//
// public List<HashableTuple<HashableTuple<String, DataType>, IFunctional>> getTriggers()
// {
// return triggers;
// }
//
// public static class DummySymbol extends Symbol{
// public DummySymbol(String name) {
// super(name);
// }
//
// @Override
// protected void registerFunctions() {
//
// }
// }
//
// public SymbolCategory getCategory()
// {
// return category;
// }
//
// public int getId() {
// return id;
// }
//
// //put DrawnSymbol data into contents of packet buffer
// public void encode(final DrawnSymbol symbol, final PacketBuffer buf)
// {
// buf.writeInt(symbol.blockFace.getIndex());
// buf.writeInt(symbol.drawnOn.getX());
// buf.writeInt(symbol.drawnOn.getY());
// buf.writeInt(symbol.drawnOn.getZ());
// }
//
// //take contents of packet buffer and put into DrawnSymbol
// public void decode(final DrawnSymbol symbol, final PacketBuffer buf)
// {
// symbol.blockFace = Direction.byIndex(buf.readInt());
// symbol.drawnOn = new BlockPos(buf.readInt(),buf.readInt(),buf.readInt());
// }
//
//
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/RunicArcana.java
// public static final String MODID = "runicarcana";
|
import com.latenighters.runicarcana.common.symbols.Symbols;
import com.latenighters.runicarcana.common.symbols.backend.Symbol;
import static com.latenighters.runicarcana.RunicArcana.MODID;
|
package com.latenighters.runicarcana.common.symbols.categories;
public class SymbolCategory {
public static SymbolCategory DEFAULT = new SymbolCategory(Symbols.DEBUG, MODID+".symbol.category.default");
|
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/Symbols.java
// public class Symbols {
//
// @ObjectHolder("runicarcana:symbol_debug")
// public static final Symbol DEBUG = null;
//
// @ObjectHolder("runicarcana:symbol_expulsion")
// public static final Symbol EXPULSION = null;
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/backend/Symbol.java
// public abstract class Symbol extends net.minecraftforge.registries.ForgeRegistryEntry<Symbol> {
//
// protected String name;
// protected ResourceLocation texture;
// protected int id = -1;
// protected final SymbolCategory category;
//
// protected List<IFunctional> functions = new ArrayList<IFunctional>();
// protected List<HashableTuple<String,DataType>> inputs = new ArrayList<HashableTuple<String,DataType>>();
// protected List<IFunctional> outputs = new ArrayList<IFunctional>();
// protected List<HashableTuple<HashableTuple<String, DataType>, IFunctional>> triggers = new ArrayList<HashableTuple<HashableTuple<String, DataType>, IFunctional>>();
//
// public Symbol(String name, ResourceLocation texture, SymbolCategory category) {
// this.name = name;
// this.texture = texture;
// this.category = category;
// this.setRegistryName(new ResourceLocation(MODID, this.name));
//
// this.registerFunctions();
//
// //roll up the functions into the functional object fields
// for (IFunctional function : functions)
// {
// //synchronize the inputs from all the functions
// for(HashableTuple<String,DataType> input : inputs) {
// //check to see if inputs already has the same DataType and String registered
// if(function.getRequiredInputs()==null)return;
// function.getRequiredInputs().removeIf(finput ->
// {
// if (function.getRequiredInputs().contains(finput)) return false;
// if (input.getA().equals(finput.getA()) && input.getB().type.equals(finput.getB().type)) {
// //if we do, remove the input from the function and replace it with the already registered input
// function.getRequiredInputs().add(input);
// return true;
// }
// return false;
// });
// }
//
// //add each input into the object inputs
// if(function.getRequiredInputs()!=null)
// function.getRequiredInputs().forEach(finput->{
// if(!inputs.contains(finput))
// inputs.add(finput);
// });
// }
//
// //repeat for outputs
// for (IFunctional function : outputs)
// {
// //synchronize the inputs from all the functions
// for(HashableTuple<String,DataType> input : inputs) {
// //check to see if inputs already has the same DataType and String registered
// if(function.getRequiredInputs()==null)return;
// function.getRequiredInputs().removeIf(finput ->
// {
// if (function.getRequiredInputs().contains(finput)) return false;
// if (input.getA().equals(finput.getA()) && input.getB().type.equals(finput.getB().type)) {
// //if we do, remove the input from the function and replace it with the already registered input
// function.getRequiredInputs().add(input);
// return true;
// }
// return false;
// });
// }
//
// //add each input into the object inputs
// if(function.getRequiredInputs()!=null)
// function.getRequiredInputs().forEach(finput->{
// if(!inputs.contains(finput))
// inputs.add(finput);
// });
// }
// }
//
// public Symbol(String name)
// {
// this(name, SymbolTextures.DEBUG, SymbolCategory.DEFAULT);
// }
//
// public String getName()
// {
// return name;
// }
//
// public ResourceLocation getTexture() {
// return texture;
// }
//
// //we really shouldn't be using this
// public void onTick(DrawnSymbol symbol, World world, Chunk chunk, BlockPos drawnOn, Direction blockFace) {
//
// }
//
// protected abstract void registerFunctions();
//
// public List<IFunctional> getFunctions() {
// return functions;
// }
//
// public List<HashableTuple<String,DataType>> getInputs(){
// return inputs;
// }
//
// public List<IFunctional> getOutputs() {
// return outputs;
// }
//
// public List<HashableTuple<HashableTuple<String, DataType>, IFunctional>> getTriggers()
// {
// return triggers;
// }
//
// public static class DummySymbol extends Symbol{
// public DummySymbol(String name) {
// super(name);
// }
//
// @Override
// protected void registerFunctions() {
//
// }
// }
//
// public SymbolCategory getCategory()
// {
// return category;
// }
//
// public int getId() {
// return id;
// }
//
// //put DrawnSymbol data into contents of packet buffer
// public void encode(final DrawnSymbol symbol, final PacketBuffer buf)
// {
// buf.writeInt(symbol.blockFace.getIndex());
// buf.writeInt(symbol.drawnOn.getX());
// buf.writeInt(symbol.drawnOn.getY());
// buf.writeInt(symbol.drawnOn.getZ());
// }
//
// //take contents of packet buffer and put into DrawnSymbol
// public void decode(final DrawnSymbol symbol, final PacketBuffer buf)
// {
// symbol.blockFace = Direction.byIndex(buf.readInt());
// symbol.drawnOn = new BlockPos(buf.readInt(),buf.readInt(),buf.readInt());
// }
//
//
//
// }
//
// Path: src/main/java/com/latenighters/runicarcana/RunicArcana.java
// public static final String MODID = "runicarcana";
// Path: src/main/java/com/latenighters/runicarcana/common/symbols/categories/SymbolCategory.java
import com.latenighters.runicarcana.common.symbols.Symbols;
import com.latenighters.runicarcana.common.symbols.backend.Symbol;
import static com.latenighters.runicarcana.RunicArcana.MODID;
package com.latenighters.runicarcana.common.symbols.categories;
public class SymbolCategory {
public static SymbolCategory DEFAULT = new SymbolCategory(Symbols.DEBUG, MODID+".symbol.category.default");
|
private Symbol displaySymbol;
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/msg/MsgReader.java
|
// Path: src/us/pfrommer/insteon/msg/Msg.java
// public enum Direction {
// TO_MODEM("TO_MODEM"),
// FROM_MODEM("FROM_MODEM");
//
// private static HashMap<String, Direction> s_map = new HashMap<String, Direction>();
//
// private String m_directionString;
//
// static {
// try {
// s_map.put(TO_MODEM.getDirectionString(), TO_MODEM);
// s_map.put(FROM_MODEM.getDirectionString(), FROM_MODEM);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// Direction(String dirString) {
// m_directionString = dirString;
// }
// public String getDirectionString() {
// return m_directionString;
// }
// public static Direction s_getDirectionFromString(String dir) {
// return s_map.get(dir);
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
|
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.msg.Msg.Direction;
import us.pfrommer.insteon.utils.Utils;
|
package us.pfrommer.insteon.msg;
/**
* This class takes data coming from the serial port and turns it
* into an message. For that, it has to figure out the length of the
* message from the header, and read enough bytes until it hits the
* message boundary. The code is tricky, partly because the Insteon protocol is.
* Most of the time the command code (second byte) is enough to determine the length
* of the incoming message, but sometimes one has to look deeper into the message
* to determine if it is a standard or extended message (their lengths differ).
*
* @author Bernd Pfrommer
* @author Daniel Pfrommer
* @since 1.5.0
*/
public class MsgReader {
private static final Logger logger = LoggerFactory.getLogger(MsgReader.class);
// no idea what the max msg length could be, but
// I doubt it'll ever be larger than 4k
private final static int MAX_MSG_LEN = 4096;
private byte[] m_buf = new byte[MAX_MSG_LEN];
private int m_end = 0; // offset of end of buffer
|
// Path: src/us/pfrommer/insteon/msg/Msg.java
// public enum Direction {
// TO_MODEM("TO_MODEM"),
// FROM_MODEM("FROM_MODEM");
//
// private static HashMap<String, Direction> s_map = new HashMap<String, Direction>();
//
// private String m_directionString;
//
// static {
// try {
// s_map.put(TO_MODEM.getDirectionString(), TO_MODEM);
// s_map.put(FROM_MODEM.getDirectionString(), FROM_MODEM);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// Direction(String dirString) {
// m_directionString = dirString;
// }
// public String getDirectionString() {
// return m_directionString;
// }
// public static Direction s_getDirectionFromString(String dir) {
// return s_map.get(dir);
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
// Path: src/us/pfrommer/insteon/msg/MsgReader.java
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.msg.Msg.Direction;
import us.pfrommer.insteon.utils.Utils;
package us.pfrommer.insteon.msg;
/**
* This class takes data coming from the serial port and turns it
* into an message. For that, it has to figure out the length of the
* message from the header, and read enough bytes until it hits the
* message boundary. The code is tricky, partly because the Insteon protocol is.
* Most of the time the command code (second byte) is enough to determine the length
* of the incoming message, but sometimes one has to look deeper into the message
* to determine if it is a standard or extended message (their lengths differ).
*
* @author Bernd Pfrommer
* @author Daniel Pfrommer
* @since 1.5.0
*/
public class MsgReader {
private static final Logger logger = LoggerFactory.getLogger(MsgReader.class);
// no idea what the max msg length could be, but
// I doubt it'll ever be larger than 4k
private final static int MAX_MSG_LEN = 4096;
private byte[] m_buf = new byte[MAX_MSG_LEN];
private int m_end = 0; // offset of end of buffer
|
private Direction m_direction = Direction.FROM_MODEM;
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/msg/InsteonAddress.java
|
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
|
import us.pfrommer.insteon.utils.Utils;
|
}
public InsteonAddress(InsteonAddress a) {
highByte = a.highByte;
middleByte = a.middleByte;
lowByte = a.lowByte;
x10 = a.x10;
}
public InsteonAddress(byte high, byte middle, byte low) {
highByte = high;
middleByte = middle;
lowByte = low;
x10 = false;
}
/**
* Constructor
* @param address string must have format of e.g. '2a.3c.40' or (for X10) 'H.UU'
*/
public InsteonAddress(String address) throws IllegalArgumentException {
if (X10.s_isValidAddress(address)) {
highByte = 0;
middleByte = 0;
lowByte = X10.s_addressToByte(address);
x10 = true;
} else {
String[] parts = address.split("\\.");
if (parts.length != 3)
throw new IllegalArgumentException("Address string must have 3 bytes, has: " + parts.length);
|
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
// Path: src/us/pfrommer/insteon/msg/InsteonAddress.java
import us.pfrommer.insteon.utils.Utils;
}
public InsteonAddress(InsteonAddress a) {
highByte = a.highByte;
middleByte = a.middleByte;
lowByte = a.lowByte;
x10 = a.x10;
}
public InsteonAddress(byte high, byte middle, byte low) {
highByte = high;
middleByte = middle;
lowByte = low;
x10 = false;
}
/**
* Constructor
* @param address string must have format of e.g. '2a.3c.40' or (for X10) 'H.UU'
*/
public InsteonAddress(String address) throws IllegalArgumentException {
if (X10.s_isValidAddress(address)) {
highByte = 0;
middleByte = 0;
lowByte = X10.s_addressToByte(address);
x10 = true;
} else {
String[] parts = address.split("\\.");
if (parts.length != 3)
throw new IllegalArgumentException("Address string must have 3 bytes, has: " + parts.length);
|
highByte = (byte) Utils.fromHexString(parts[0]);
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/terminal/console/gui/FancyConsoleArea.java
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
|
import java.awt.Color;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PipedReader;
import java.io.PipedWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTextPane;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
|
package us.pfrommer.insteon.terminal.console.gui;
//A no-longer-used class which
//shows both the input and the output in the same text pane
public class FancyConsoleArea extends JTextPane implements Console, KeyListener {
private static final long serialVersionUID = 1L;
//A list sorted from most recent to least recent command
private ArrayList<String> m_history = new ArrayList<String>();
private int m_historyIndex = -1;
private ConsoleStream m_in;
private ConsolePrintStream m_out;
private ConsolePrintStream m_err;
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
// Path: src/us/pfrommer/insteon/terminal/console/gui/FancyConsoleArea.java
import java.awt.Color;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PipedReader;
import java.io.PipedWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTextPane;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
package us.pfrommer.insteon.terminal.console.gui;
//A no-longer-used class which
//shows both the input and the output in the same text pane
public class FancyConsoleArea extends JTextPane implements Console, KeyListener {
private static final long serialVersionUID = 1L;
//A list sorted from most recent to least recent command
private ArrayList<String> m_history = new ArrayList<String>();
private int m_historyIndex = -1;
private ConsoleStream m_in;
private ConsolePrintStream m_out;
private ConsolePrintStream m_err;
|
private HashSet<ConsoleListener> m_listeners = new HashSet<ConsoleListener>();
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/terminal/console/terminal/JLineTerminal.java
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
|
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import jline.ConsoleReader;
import jline.Terminal;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
|
public PrintStream out() {
return System.out;
}
@Override
public PrintStream err() {
return System.err;
}
@Override
public String readLine() throws IOException {
return m_reader.readLine();
}
@Override
public String readLine(String prompt) throws IOException {
return m_reader.readLine(prompt);
}
@Override
public void clear() {
}
@Override
public void reset() {
}
@Override
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
// Path: src/us/pfrommer/insteon/terminal/console/terminal/JLineTerminal.java
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import jline.ConsoleReader;
import jline.Terminal;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
public PrintStream out() {
return System.out;
}
@Override
public PrintStream err() {
return System.err;
}
@Override
public String readLine() throws IOException {
return m_reader.readLine();
}
@Override
public String readLine(String prompt) throws IOException {
return m_reader.readLine(prompt);
}
@Override
public void clear() {
}
@Override
public void reset() {
}
@Override
|
public void addConsoleListener(ConsoleListener l) {
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/terminal/Configurator.java
|
// Path: src/us/pfrommer/insteon/utils/ResourceLocator.java
// public interface ResourceLocator {
// public InputStream getResource(String resource);
//
// public class ClasspathResourceLocator implements ResourceLocator {
// public InputStream getResource(String resource) {
// InputStream in = ResourceLocator.class.getClassLoader().getResourceAsStream(resource);
// if (in == null) throw new RuntimeException("Resource " + resource + " not found");
// return in;
// }
// }
// public class FolderResourceLocator implements ResourceLocator {
// private File m_file;
// public FolderResourceLocator(File file) {
// m_file = file;
// }
// public InputStream getResource(String resource) {
// try {
// return new FileInputStream(new File(m_file, resource));
// } catch (FileNotFoundException e) {
// throw new RuntimeException(e);
// }
// }
// }
// }
|
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.utils.ResourceLocator;
|
package us.pfrommer.insteon.terminal;
// Responsible for managing insteon-terminal files
public class Configurator {
private static final Logger logger = LoggerFactory.getLogger(Configurator.class);
private String[] m_pythonPath = null;
public Configurator() {
}
|
// Path: src/us/pfrommer/insteon/utils/ResourceLocator.java
// public interface ResourceLocator {
// public InputStream getResource(String resource);
//
// public class ClasspathResourceLocator implements ResourceLocator {
// public InputStream getResource(String resource) {
// InputStream in = ResourceLocator.class.getClassLoader().getResourceAsStream(resource);
// if (in == null) throw new RuntimeException("Resource " + resource + " not found");
// return in;
// }
// }
// public class FolderResourceLocator implements ResourceLocator {
// private File m_file;
// public FolderResourceLocator(File file) {
// m_file = file;
// }
// public InputStream getResource(String resource) {
// try {
// return new FileInputStream(new File(m_file, resource));
// } catch (FileNotFoundException e) {
// throw new RuntimeException(e);
// }
// }
// }
// }
// Path: src/us/pfrommer/insteon/terminal/Configurator.java
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.utils.ResourceLocator;
package us.pfrommer.insteon.terminal;
// Responsible for managing insteon-terminal files
public class Configurator {
private static final Logger logger = LoggerFactory.getLogger(Configurator.class);
private String[] m_pythonPath = null;
public Configurator() {
}
|
public void loadConfig(ResourceLocator locator) {
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/terminal/console/gui/GUI.java
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// private String[] m_history;
// private int m_count = 0;
// private int m_last = -1;
//
// public History(int size) {
// m_history = new String[size];
// }
//
// public int length() { return m_count; }
//
// //Previous is from 0-histoy.length -1
// //0 is the last thing entered
// // and history.length - 1 is the first thing entered
// public String get(int previous) {
// if (m_last < 0) return null;
// if (previous >= m_count) return null;
//
// int idx = Math.min(m_last, Math.max(0, m_last - previous));
//
// while (idx < 0) {
// idx += m_history.length;
// }
//
// return m_history[idx];
// }
//
// public void add(String s) {
// String l = get(0);
// if (l != null && l.equals(s)) return; //Don't store duplicate entries
//
// int idx = m_last + 1;
// if (idx >= m_history.length) {
// idx -= m_history.length;
// }
// m_history[idx] = s;
//
// m_last = idx;
//
// m_count = Math.max(m_history.length, m_count++);
// }
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
// public interface InputListener {
// public void onInput(String input, String text);
// }
|
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
import us.pfrommer.insteon.terminal.console.History;
import us.pfrommer.insteon.terminal.console.gui.InputArea.InputListener;
|
package us.pfrommer.insteon.terminal.console.gui;
public class GUI implements Console {
private JFrame m_frame;
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// private String[] m_history;
// private int m_count = 0;
// private int m_last = -1;
//
// public History(int size) {
// m_history = new String[size];
// }
//
// public int length() { return m_count; }
//
// //Previous is from 0-histoy.length -1
// //0 is the last thing entered
// // and history.length - 1 is the first thing entered
// public String get(int previous) {
// if (m_last < 0) return null;
// if (previous >= m_count) return null;
//
// int idx = Math.min(m_last, Math.max(0, m_last - previous));
//
// while (idx < 0) {
// idx += m_history.length;
// }
//
// return m_history[idx];
// }
//
// public void add(String s) {
// String l = get(0);
// if (l != null && l.equals(s)) return; //Don't store duplicate entries
//
// int idx = m_last + 1;
// if (idx >= m_history.length) {
// idx -= m_history.length;
// }
// m_history[idx] = s;
//
// m_last = idx;
//
// m_count = Math.max(m_history.length, m_count++);
// }
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
// public interface InputListener {
// public void onInput(String input, String text);
// }
// Path: src/us/pfrommer/insteon/terminal/console/gui/GUI.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
import us.pfrommer.insteon.terminal.console.History;
import us.pfrommer.insteon.terminal.console.gui.InputArea.InputListener;
package us.pfrommer.insteon.terminal.console.gui;
public class GUI implements Console {
private JFrame m_frame;
|
private History m_history = new History(100);
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/terminal/console/gui/GUI.java
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// private String[] m_history;
// private int m_count = 0;
// private int m_last = -1;
//
// public History(int size) {
// m_history = new String[size];
// }
//
// public int length() { return m_count; }
//
// //Previous is from 0-histoy.length -1
// //0 is the last thing entered
// // and history.length - 1 is the first thing entered
// public String get(int previous) {
// if (m_last < 0) return null;
// if (previous >= m_count) return null;
//
// int idx = Math.min(m_last, Math.max(0, m_last - previous));
//
// while (idx < 0) {
// idx += m_history.length;
// }
//
// return m_history[idx];
// }
//
// public void add(String s) {
// String l = get(0);
// if (l != null && l.equals(s)) return; //Don't store duplicate entries
//
// int idx = m_last + 1;
// if (idx >= m_history.length) {
// idx -= m_history.length;
// }
// m_history[idx] = s;
//
// m_last = idx;
//
// m_count = Math.max(m_history.length, m_count++);
// }
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
// public interface InputListener {
// public void onInput(String input, String text);
// }
|
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
import us.pfrommer.insteon.terminal.console.History;
import us.pfrommer.insteon.terminal.console.gui.InputArea.InputListener;
|
Font f = new Font(Font.MONOSPACED, Font.PLAIN, 14);
m_output = new OutputArea(f);
m_output.setEditable(false);
m_output.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
m_input.requestFocus();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
});
m_out = m_output.createOutput(Color.BLACK);
m_err = m_output.createOutput(Color.RED);
m_input = new InputArea(f, m_history);
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// private String[] m_history;
// private int m_count = 0;
// private int m_last = -1;
//
// public History(int size) {
// m_history = new String[size];
// }
//
// public int length() { return m_count; }
//
// //Previous is from 0-histoy.length -1
// //0 is the last thing entered
// // and history.length - 1 is the first thing entered
// public String get(int previous) {
// if (m_last < 0) return null;
// if (previous >= m_count) return null;
//
// int idx = Math.min(m_last, Math.max(0, m_last - previous));
//
// while (idx < 0) {
// idx += m_history.length;
// }
//
// return m_history[idx];
// }
//
// public void add(String s) {
// String l = get(0);
// if (l != null && l.equals(s)) return; //Don't store duplicate entries
//
// int idx = m_last + 1;
// if (idx >= m_history.length) {
// idx -= m_history.length;
// }
// m_history[idx] = s;
//
// m_last = idx;
//
// m_count = Math.max(m_history.length, m_count++);
// }
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
// public interface InputListener {
// public void onInput(String input, String text);
// }
// Path: src/us/pfrommer/insteon/terminal/console/gui/GUI.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
import us.pfrommer.insteon.terminal.console.History;
import us.pfrommer.insteon.terminal.console.gui.InputArea.InputListener;
Font f = new Font(Font.MONOSPACED, Font.PLAIN, 14);
m_output = new OutputArea(f);
m_output.setEditable(false);
m_output.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
m_input.requestFocus();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
});
m_out = m_output.createOutput(Color.BLACK);
m_err = m_output.createOutput(Color.RED);
m_input = new InputArea(f, m_history);
|
m_input.addInputListener(new InputListener() {
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/terminal/console/gui/GUI.java
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// private String[] m_history;
// private int m_count = 0;
// private int m_last = -1;
//
// public History(int size) {
// m_history = new String[size];
// }
//
// public int length() { return m_count; }
//
// //Previous is from 0-histoy.length -1
// //0 is the last thing entered
// // and history.length - 1 is the first thing entered
// public String get(int previous) {
// if (m_last < 0) return null;
// if (previous >= m_count) return null;
//
// int idx = Math.min(m_last, Math.max(0, m_last - previous));
//
// while (idx < 0) {
// idx += m_history.length;
// }
//
// return m_history[idx];
// }
//
// public void add(String s) {
// String l = get(0);
// if (l != null && l.equals(s)) return; //Don't store duplicate entries
//
// int idx = m_last + 1;
// if (idx >= m_history.length) {
// idx -= m_history.length;
// }
// m_history[idx] = s;
//
// m_last = idx;
//
// m_count = Math.max(m_history.length, m_count++);
// }
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
// public interface InputListener {
// public void onInput(String input, String text);
// }
|
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
import us.pfrommer.insteon.terminal.console.History;
import us.pfrommer.insteon.terminal.console.gui.InputArea.InputListener;
|
@Override
public void windowActivated(WindowEvent e) {}
@Override
public void windowDeactivated(WindowEvent e) {}
});
frame.setTitle("Insteon Terminal");
frame.setSize(500, 500);
m_frame = frame;
}
public void setVisible(boolean visible) {
m_frame.setVisible(visible);
}
@Override
public String readLine() throws IOException {
return m_input.readLine();
}
@Override
public String readLine(String prompt) throws IOException {
return m_input.readLine(prompt);
}
@Override
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// // callback for terminating the current running command
// public void terminate();
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// private String[] m_history;
// private int m_count = 0;
// private int m_last = -1;
//
// public History(int size) {
// m_history = new String[size];
// }
//
// public int length() { return m_count; }
//
// //Previous is from 0-histoy.length -1
// //0 is the last thing entered
// // and history.length - 1 is the first thing entered
// public String get(int previous) {
// if (m_last < 0) return null;
// if (previous >= m_count) return null;
//
// int idx = Math.min(m_last, Math.max(0, m_last - previous));
//
// while (idx < 0) {
// idx += m_history.length;
// }
//
// return m_history[idx];
// }
//
// public void add(String s) {
// String l = get(0);
// if (l != null && l.equals(s)) return; //Don't store duplicate entries
//
// int idx = m_last + 1;
// if (idx >= m_history.length) {
// idx -= m_history.length;
// }
// m_history[idx] = s;
//
// m_last = idx;
//
// m_count = Math.max(m_history.length, m_count++);
// }
// }
//
// Path: src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
// public interface InputListener {
// public void onInput(String input, String text);
// }
// Path: src/us/pfrommer/insteon/terminal/console/gui/GUI.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
import us.pfrommer.insteon.terminal.console.History;
import us.pfrommer.insteon.terminal.console.gui.InputArea.InputListener;
@Override
public void windowActivated(WindowEvent e) {}
@Override
public void windowDeactivated(WindowEvent e) {}
});
frame.setTitle("Insteon Terminal");
frame.setSize(500, 500);
m_frame = frame;
}
public void setVisible(boolean visible) {
m_frame.setVisible(visible);
}
@Override
public String readLine() throws IOException {
return m_input.readLine();
}
@Override
public String readLine(String prompt) throws IOException {
return m_input.readLine(prompt);
}
@Override
|
public void addConsoleListener(ConsoleListener l) {
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/terminal/InsteonTerminal.java
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
|
import java.io.File;
import java.io.PrintStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.python.core.Py;
import org.python.core.PyFunction;
import org.python.core.PyStringMap;
import org.python.util.PythonInterpreter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.terminal.console.Console;
|
package us.pfrommer.insteon.terminal;
public class InsteonTerminal {
private static Logger logger = LoggerFactory.getLogger(InsteonTerminal.class);
private PythonInterpreter m_interpreter = null;
|
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// public String readLine() throws IOException;
// public String readLine(String prompt) throws IOException;
//
// public void addConsoleListener(ConsoleListener l);
// public void removeConsoleListener(ConsoleListener l);
//
// public Reader in();
// public PrintStream out();
// public PrintStream err();
//
// public void clear();
// public void reset();
// }
// Path: src/us/pfrommer/insteon/terminal/InsteonTerminal.java
import java.io.File;
import java.io.PrintStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.python.core.Py;
import org.python.core.PyFunction;
import org.python.core.PyStringMap;
import org.python.util.PythonInterpreter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.terminal.console.Console;
package us.pfrommer.insteon.terminal;
public class InsteonTerminal {
private static Logger logger = LoggerFactory.getLogger(InsteonTerminal.class);
private PythonInterpreter m_interpreter = null;
|
private Console m_console = null;
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/msg/Field.java
|
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
|
import us.pfrommer.insteon.utils.Utils;
|
public Field(String name, DataType type, int off) {
m_name = name;
m_type = type;
m_offset = off;
}
private void check(int arrayLen, DataType t) throws FieldException {
checkSpace(arrayLen);
checkType(t);
}
private void checkSpace(int arrayLen) throws FieldException {
if (m_offset + m_type.getSize() > arrayLen) {
throw new FieldException("field write beyond end of msg");
}
}
private void checkType(DataType t) throws FieldException {
if (m_type != t) {
throw new FieldException("field write type mismatch!");
}
}
public String toString() {
return getName() + " Type: " + getType() + " Offset " + getOffset();
}
public String toString(byte[] array) {
String s = m_name + ":";
try {
switch (m_type) {
|
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
// Path: src/us/pfrommer/insteon/msg/Field.java
import us.pfrommer.insteon.utils.Utils;
public Field(String name, DataType type, int off) {
m_name = name;
m_type = type;
m_offset = off;
}
private void check(int arrayLen, DataType t) throws FieldException {
checkSpace(arrayLen);
checkType(t);
}
private void checkSpace(int arrayLen) throws FieldException {
if (m_offset + m_type.getSize() > arrayLen) {
throw new FieldException("field write beyond end of msg");
}
}
private void checkType(DataType t) throws FieldException {
if (m_type != t) {
throw new FieldException("field write type mismatch!");
}
}
public String toString() {
return getName() + " Type: " + getType() + " Offset " + getOffset();
}
public String toString(byte[] array) {
String s = m_name + ":";
try {
switch (m_type) {
|
case BYTE: s += Utils.toHexByte(getByte(array)); break;
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
|
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// private String[] m_history;
// private int m_count = 0;
// private int m_last = -1;
//
// public History(int size) {
// m_history = new String[size];
// }
//
// public int length() { return m_count; }
//
// //Previous is from 0-histoy.length -1
// //0 is the last thing entered
// // and history.length - 1 is the first thing entered
// public String get(int previous) {
// if (m_last < 0) return null;
// if (previous >= m_count) return null;
//
// int idx = Math.min(m_last, Math.max(0, m_last - previous));
//
// while (idx < 0) {
// idx += m_history.length;
// }
//
// return m_history[idx];
// }
//
// public void add(String s) {
// String l = get(0);
// if (l != null && l.equals(s)) return; //Don't store duplicate entries
//
// int idx = m_last + 1;
// if (idx >= m_history.length) {
// idx -= m_history.length;
// }
// m_history[idx] = s;
//
// m_last = idx;
//
// m_count = Math.max(m_history.length, m_count++);
// }
// }
|
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.io.PipedReader;
import java.io.PipedWriter;
import java.io.Reader;
import java.util.Scanner;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.InputMap;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.DocumentFilter;
import javax.swing.text.PlainDocument;
import javax.swing.text.SimpleAttributeSet;
import us.pfrommer.insteon.terminal.console.History;
|
package us.pfrommer.insteon.terminal.console.gui;
public class InputArea extends JTextField {
private static final long serialVersionUID = 1L;
private InputAreaReader m_reader = null;
private Scanner m_scanner = null;
|
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// private String[] m_history;
// private int m_count = 0;
// private int m_last = -1;
//
// public History(int size) {
// m_history = new String[size];
// }
//
// public int length() { return m_count; }
//
// //Previous is from 0-histoy.length -1
// //0 is the last thing entered
// // and history.length - 1 is the first thing entered
// public String get(int previous) {
// if (m_last < 0) return null;
// if (previous >= m_count) return null;
//
// int idx = Math.min(m_last, Math.max(0, m_last - previous));
//
// while (idx < 0) {
// idx += m_history.length;
// }
//
// return m_history[idx];
// }
//
// public void add(String s) {
// String l = get(0);
// if (l != null && l.equals(s)) return; //Don't store duplicate entries
//
// int idx = m_last + 1;
// if (idx >= m_history.length) {
// idx -= m_history.length;
// }
// m_history[idx] = s;
//
// m_last = idx;
//
// m_count = Math.max(m_history.length, m_count++);
// }
// }
// Path: src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.io.PipedReader;
import java.io.PipedWriter;
import java.io.Reader;
import java.util.Scanner;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.InputMap;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.DocumentFilter;
import javax.swing.text.PlainDocument;
import javax.swing.text.SimpleAttributeSet;
import us.pfrommer.insteon.terminal.console.History;
package us.pfrommer.insteon.terminal.console.gui;
public class InputArea extends JTextField {
private static final long serialVersionUID = 1L;
private InputAreaReader m_reader = null;
private Scanner m_scanner = null;
|
private History m_history = null;
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/msg/hub/InsteonHub.java
|
// Path: src/us/pfrommer/insteon/utils/ByteArrayIO.java
// public class ByteArrayIO {
// public static final int DEFAULT_SIZE = 2048;
//
// private byte m_buf[]; // the actual buffer
// private int m_count; // number of valid bytes
// private int m_index = 0; // current read index
//
// /**
// * Constructor for ByteArrayIO with dynamic size
// * @param size initial size, but will grow dynamically
// */
// public ByteArrayIO(int size) {
// m_buf = new byte[size];
// }
//
// /**
// * Uses a default size of 2048
// */
// public ByteArrayIO() {
// this(DEFAULT_SIZE);
// }
//
// /**
// * Number of unread bytes
// * @return number of bytes not yet read
// */
// public synchronized int remaining() {
// return m_count - m_index;
// }
//
// /**
// * Blocking read of a single byte
// * @return byte read
// */
// public synchronized byte get() throws InterruptedException {
// while (remaining() < 1) {
// try {
// wait();
// } catch (InterruptedException e) {
// throw e;
// }
// }
// return m_buf[m_index++];
// }
// /**
// * Blocking read of multiple bytes
// * @param bytes destination array for bytes read
// * @param off offset into dest array
// * @param len max number of bytes to read into dest array
// * @return number of bytes actually read
// */
// public synchronized int get(byte[] bytes, int off, int len) throws InterruptedException {
// while (remaining() < 1) {
// try {
// wait();
// } catch (InterruptedException e) {
// throw e;
// }
// }
// int b = Math.min(len, remaining());
// System.arraycopy(m_buf, m_index, bytes, off, b);
// m_index += b;
// return b;
// }
// /**
// * Adds bytes to the byte buffer
// * @param b byte array with new bytes
// * @param off starting offset into buffer
// * @param len number of bytes to add
// */
// private synchronized void add(byte b[], int off, int len) {
// if ((off < 0) || (off > b.length) || (len < 0) ||
// ((off + len) > b.length) || ((off + len) < 0)) {
// throw new IndexOutOfBoundsException();
// } else if (len == 0) {
// return;
// }
// int nCount = m_count + len;
// if (nCount > m_buf.length) {
// // dynamically grow the array
// m_buf = Arrays.copyOf(m_buf, Math.max(m_buf.length << 1, nCount));
// }
// // append new data to end of buffer
// System.arraycopy(b, off, m_buf, m_count, len);
// m_count = nCount;
// notifyAll();
// }
// /**
// * Adds bytes to the byte buffer
// * @param b the new bytes to be added
// */
// public void add(byte[] b) {
// add(b, 0, b.length);
// }
//
// /**
// * Shrink the buffer to smallest size possible
// */
// public synchronized void compact() {
// if (m_index == 0) return;
// byte[] newBuf = new byte[remaining()];
// System.arraycopy(m_buf, m_index, newBuf, 0, newBuf.length);
// m_index = 0;
// m_count = newBuf.length;
// m_buf = newBuf;
// }
// }
|
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import us.pfrommer.insteon.utils.ByteArrayIO;
|
throw new IOException("Bad authentication...access forbidden");
return EntityUtils.toString(res.getEntity());
}
public void run() {
while(!Thread.currentThread().isInterrupted()) {
try {
poll();
} catch (IOException e) {
e.printStackTrace();
}
try {
Thread.sleep(m_pollTime);
} catch (InterruptedException e) {
break;
}
}
}
public static byte[] s_hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
public class HubInputStream extends InputStream {
|
// Path: src/us/pfrommer/insteon/utils/ByteArrayIO.java
// public class ByteArrayIO {
// public static final int DEFAULT_SIZE = 2048;
//
// private byte m_buf[]; // the actual buffer
// private int m_count; // number of valid bytes
// private int m_index = 0; // current read index
//
// /**
// * Constructor for ByteArrayIO with dynamic size
// * @param size initial size, but will grow dynamically
// */
// public ByteArrayIO(int size) {
// m_buf = new byte[size];
// }
//
// /**
// * Uses a default size of 2048
// */
// public ByteArrayIO() {
// this(DEFAULT_SIZE);
// }
//
// /**
// * Number of unread bytes
// * @return number of bytes not yet read
// */
// public synchronized int remaining() {
// return m_count - m_index;
// }
//
// /**
// * Blocking read of a single byte
// * @return byte read
// */
// public synchronized byte get() throws InterruptedException {
// while (remaining() < 1) {
// try {
// wait();
// } catch (InterruptedException e) {
// throw e;
// }
// }
// return m_buf[m_index++];
// }
// /**
// * Blocking read of multiple bytes
// * @param bytes destination array for bytes read
// * @param off offset into dest array
// * @param len max number of bytes to read into dest array
// * @return number of bytes actually read
// */
// public synchronized int get(byte[] bytes, int off, int len) throws InterruptedException {
// while (remaining() < 1) {
// try {
// wait();
// } catch (InterruptedException e) {
// throw e;
// }
// }
// int b = Math.min(len, remaining());
// System.arraycopy(m_buf, m_index, bytes, off, b);
// m_index += b;
// return b;
// }
// /**
// * Adds bytes to the byte buffer
// * @param b byte array with new bytes
// * @param off starting offset into buffer
// * @param len number of bytes to add
// */
// private synchronized void add(byte b[], int off, int len) {
// if ((off < 0) || (off > b.length) || (len < 0) ||
// ((off + len) > b.length) || ((off + len) < 0)) {
// throw new IndexOutOfBoundsException();
// } else if (len == 0) {
// return;
// }
// int nCount = m_count + len;
// if (nCount > m_buf.length) {
// // dynamically grow the array
// m_buf = Arrays.copyOf(m_buf, Math.max(m_buf.length << 1, nCount));
// }
// // append new data to end of buffer
// System.arraycopy(b, off, m_buf, m_count, len);
// m_count = nCount;
// notifyAll();
// }
// /**
// * Adds bytes to the byte buffer
// * @param b the new bytes to be added
// */
// public void add(byte[] b) {
// add(b, 0, b.length);
// }
//
// /**
// * Shrink the buffer to smallest size possible
// */
// public synchronized void compact() {
// if (m_index == 0) return;
// byte[] newBuf = new byte[remaining()];
// System.arraycopy(m_buf, m_index, newBuf, 0, newBuf.length);
// m_index = 0;
// m_count = newBuf.length;
// m_buf = newBuf;
// }
// }
// Path: src/us/pfrommer/insteon/msg/hub/InsteonHub.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import us.pfrommer.insteon.utils.ByteArrayIO;
throw new IOException("Bad authentication...access forbidden");
return EntityUtils.toString(res.getEntity());
}
public void run() {
while(!Thread.currentThread().isInterrupted()) {
try {
poll();
} catch (IOException e) {
e.printStackTrace();
}
try {
Thread.sleep(m_pollTime);
} catch (InterruptedException e) {
break;
}
}
}
public static byte[] s_hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
public class HubInputStream extends InputStream {
|
private ByteArrayIO m_buffer = new ByteArrayIO(1024);
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/msg/XMLMessageReader.java
|
// Path: src/us/pfrommer/insteon/utils/Pair.java
// public class Pair<K, V> {
// private K m_key;
// private V m_value;
//
// /**
// * Constructs a new <code>Pair</code> with a given key/value
// *
// * @param key the key
// * @param value the value
// */
// public Pair(K key, V value) {
// setKey(key);
// setValue(value);
// }
//
// public K getKey() { return m_key; }
// public V getValue() { return m_value; }
//
// public void setKey(K key) { m_key = key; }
// public void setValue(V value) { m_value = value; }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
|
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import us.pfrommer.insteon.utils.Pair;
import us.pfrommer.insteon.utils.Utils.DataTypeParser;
import us.pfrommer.insteon.utils.Utils.ParsingException;
|
package us.pfrommer.insteon.msg;
/**
* Reads the Msg definitions from an XML file
*
* @author Daniel Pfrommer
* @since 1.5.0
*/
public class XMLMessageReader {
/**
* Reads the message definitions from an xml file
* @param input input stream from which to read
* @return what was read from file: the map between clear text string and Msg objects
* @throws IOException couldn't read file etc
* @throws ParsingException something wrong with the file format
* @throws FieldException something wrong with the field definition
*/
public static HashMap<String, Msg> s_readMessageDefinitions(InputStream input)
|
// Path: src/us/pfrommer/insteon/utils/Pair.java
// public class Pair<K, V> {
// private K m_key;
// private V m_value;
//
// /**
// * Constructs a new <code>Pair</code> with a given key/value
// *
// * @param key the key
// * @param value the value
// */
// public Pair(K key, V value) {
// setKey(key);
// setValue(value);
// }
//
// public K getKey() { return m_key; }
// public V getValue() { return m_value; }
//
// public void setKey(K key) { m_key = key; }
// public void setValue(V value) { m_value = value; }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// Path: src/us/pfrommer/insteon/msg/XMLMessageReader.java
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import us.pfrommer.insteon.utils.Pair;
import us.pfrommer.insteon.utils.Utils.DataTypeParser;
import us.pfrommer.insteon.utils.Utils.ParsingException;
package us.pfrommer.insteon.msg;
/**
* Reads the Msg definitions from an XML file
*
* @author Daniel Pfrommer
* @since 1.5.0
*/
public class XMLMessageReader {
/**
* Reads the message definitions from an xml file
* @param input input stream from which to read
* @return what was read from file: the map between clear text string and Msg objects
* @throws IOException couldn't read file etc
* @throws ParsingException something wrong with the file format
* @throws FieldException something wrong with the field definition
*/
public static HashMap<String, Msg> s_readMessageDefinitions(InputStream input)
|
throws IOException, ParsingException, FieldException {
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/msg/XMLMessageReader.java
|
// Path: src/us/pfrommer/insteon/utils/Pair.java
// public class Pair<K, V> {
// private K m_key;
// private V m_value;
//
// /**
// * Constructs a new <code>Pair</code> with a given key/value
// *
// * @param key the key
// * @param value the value
// */
// public Pair(K key, V value) {
// setKey(key);
// setValue(value);
// }
//
// public K getKey() { return m_key; }
// public V getValue() { return m_value; }
//
// public void setKey(K key) { m_key = key; }
// public void setValue(V value) { m_value = value; }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
|
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import us.pfrommer.insteon.utils.Pair;
import us.pfrommer.insteon.utils.Utils.DataTypeParser;
import us.pfrommer.insteon.utils.Utils.ParsingException;
|
package us.pfrommer.insteon.msg;
/**
* Reads the Msg definitions from an XML file
*
* @author Daniel Pfrommer
* @since 1.5.0
*/
public class XMLMessageReader {
/**
* Reads the message definitions from an xml file
* @param input input stream from which to read
* @return what was read from file: the map between clear text string and Msg objects
* @throws IOException couldn't read file etc
* @throws ParsingException something wrong with the file format
* @throws FieldException something wrong with the field definition
*/
public static HashMap<String, Msg> s_readMessageDefinitions(InputStream input)
throws IOException, ParsingException, FieldException {
HashMap<String, Msg> messageMap = new HashMap<String, Msg>();
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
//Parse it!
Document doc = dBuilder.parse(input);
doc.getDocumentElement().normalize();
Node root = doc.getDocumentElement();
NodeList nodes = root.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equals("msg")) {
|
// Path: src/us/pfrommer/insteon/utils/Pair.java
// public class Pair<K, V> {
// private K m_key;
// private V m_value;
//
// /**
// * Constructs a new <code>Pair</code> with a given key/value
// *
// * @param key the key
// * @param value the value
// */
// public Pair(K key, V value) {
// setKey(key);
// setValue(value);
// }
//
// public K getKey() { return m_key; }
// public V getValue() { return m_value; }
//
// public void setKey(K key) { m_key = key; }
// public void setValue(V value) { m_value = value; }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// Path: src/us/pfrommer/insteon/msg/XMLMessageReader.java
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import us.pfrommer.insteon.utils.Pair;
import us.pfrommer.insteon.utils.Utils.DataTypeParser;
import us.pfrommer.insteon.utils.Utils.ParsingException;
package us.pfrommer.insteon.msg;
/**
* Reads the Msg definitions from an XML file
*
* @author Daniel Pfrommer
* @since 1.5.0
*/
public class XMLMessageReader {
/**
* Reads the message definitions from an xml file
* @param input input stream from which to read
* @return what was read from file: the map between clear text string and Msg objects
* @throws IOException couldn't read file etc
* @throws ParsingException something wrong with the file format
* @throws FieldException something wrong with the field definition
*/
public static HashMap<String, Msg> s_readMessageDefinitions(InputStream input)
throws IOException, ParsingException, FieldException {
HashMap<String, Msg> messageMap = new HashMap<String, Msg>();
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
//Parse it!
Document doc = dBuilder.parse(input);
doc.getDocumentElement().normalize();
Node root = doc.getDocumentElement();
NodeList nodes = root.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equals("msg")) {
|
Pair<String, Msg> msgDef = s_readMessageDefinition((Element) node);
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/msg/XMLMessageReader.java
|
// Path: src/us/pfrommer/insteon/utils/Pair.java
// public class Pair<K, V> {
// private K m_key;
// private V m_value;
//
// /**
// * Constructs a new <code>Pair</code> with a given key/value
// *
// * @param key the key
// * @param value the value
// */
// public Pair(K key, V value) {
// setKey(key);
// setValue(value);
// }
//
// public K getKey() { return m_key; }
// public V getValue() { return m_value; }
//
// public void setKey(K key) { m_key = key; }
// public void setValue(V value) { m_value = value; }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
|
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import us.pfrommer.insteon.utils.Pair;
import us.pfrommer.insteon.utils.Utils.DataTypeParser;
import us.pfrommer.insteon.utils.Utils.ParsingException;
|
private static int s_readHeaderElement(Element header, LinkedHashMap<Field, Object> fields)
throws ParsingException {
int offset = 0;
int headerLen = Integer.parseInt(header.getAttribute("length"));
NodeList nodes = header.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Pair<Field, Object> definition = s_readField((Element) node, offset);
if (definition != null) {
offset += definition.getKey().getType().getSize();
fields.put(definition.getKey(), definition.getValue());
}
}
}
if (headerLen != offset) {
throw new ParsingException("Actual header length " + offset + " differs from given length " + headerLen + "!");
}
return headerLen;
}
private static Pair<Field, Object> s_readField(Element field, int offset) {
DataType dType = DataType.s_getDataType(field.getTagName());
//Will return blank if no name attribute
String name = field.getAttribute("name");
Field f = new Field(name, dType, offset);
//Now we have field, only need value
String sVal = field.getTextContent();
|
// Path: src/us/pfrommer/insteon/utils/Pair.java
// public class Pair<K, V> {
// private K m_key;
// private V m_value;
//
// /**
// * Constructs a new <code>Pair</code> with a given key/value
// *
// * @param key the key
// * @param value the value
// */
// public Pair(K key, V value) {
// setKey(key);
// setValue(value);
// }
//
// public K getKey() { return m_key; }
// public V getValue() { return m_value; }
//
// public void setKey(K key) { m_key = key; }
// public void setValue(V value) { m_value = value; }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// Path: src/us/pfrommer/insteon/msg/XMLMessageReader.java
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import us.pfrommer.insteon.utils.Pair;
import us.pfrommer.insteon.utils.Utils.DataTypeParser;
import us.pfrommer.insteon.utils.Utils.ParsingException;
private static int s_readHeaderElement(Element header, LinkedHashMap<Field, Object> fields)
throws ParsingException {
int offset = 0;
int headerLen = Integer.parseInt(header.getAttribute("length"));
NodeList nodes = header.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Pair<Field, Object> definition = s_readField((Element) node, offset);
if (definition != null) {
offset += definition.getKey().getType().getSize();
fields.put(definition.getKey(), definition.getValue());
}
}
}
if (headerLen != offset) {
throw new ParsingException("Actual header length " + offset + " differs from given length " + headerLen + "!");
}
return headerLen;
}
private static Pair<Field, Object> s_readField(Element field, int offset) {
DataType dType = DataType.s_getDataType(field.getTagName());
//Will return blank if no name attribute
String name = field.getAttribute("name");
Field f = new Field(name, dType, offset);
//Now we have field, only need value
String sVal = field.getTextContent();
|
Object val = DataTypeParser.s_parseDataType(dType, sVal);
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/msg/Msg.java
|
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
|
import java.io.IOException;
import java.io.InputStream;
import java.util.Comparator;
import java.util.HashMap;
import java.util.TreeSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.utils.Utils;
import us.pfrommer.insteon.utils.Utils.ParsingException;
|
/**
* Copy constructor, needed to make a copy of the templates when
* generating messages from them.
* @param m the message to make a copy of
*/
public Msg(Msg m) {
m_headerLength = m.m_headerLength;
m_data = m.m_data.clone();
// the message definition usually doesn't change, but just to be sure...
m_definition = new MsgDefinition(m.m_definition);
m_direction = m.m_direction;
}
static {
// Use xml msg loader to load configs
try {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("msg_definitions.xml");
if (stream != null) {
HashMap<String, Msg> msgs = XMLMessageReader.s_readMessageDefinitions(stream);
s_msgMap.putAll(msgs);
} else {
logger.error("could not get message definition resource!");
}
s_buildHeaderMap();
s_buildLengthMap();
} catch (IOException e) {
logger.error("i/o error parsing xml insteon message definitions", e);
|
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// Path: src/us/pfrommer/insteon/msg/Msg.java
import java.io.IOException;
import java.io.InputStream;
import java.util.Comparator;
import java.util.HashMap;
import java.util.TreeSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.utils.Utils;
import us.pfrommer.insteon.utils.Utils.ParsingException;
/**
* Copy constructor, needed to make a copy of the templates when
* generating messages from them.
* @param m the message to make a copy of
*/
public Msg(Msg m) {
m_headerLength = m.m_headerLength;
m_data = m.m_data.clone();
// the message definition usually doesn't change, but just to be sure...
m_definition = new MsgDefinition(m.m_definition);
m_direction = m.m_direction;
}
static {
// Use xml msg loader to load configs
try {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("msg_definitions.xml");
if (stream != null) {
HashMap<String, Msg> msgs = XMLMessageReader.s_readMessageDefinitions(stream);
s_msgMap.putAll(msgs);
} else {
logger.error("could not get message definition resource!");
}
s_buildHeaderMap();
s_buildLengthMap();
} catch (IOException e) {
logger.error("i/o error parsing xml insteon message definitions", e);
|
} catch (ParsingException e) {
|
pfrommerd/insteon-terminal
|
src/us/pfrommer/insteon/msg/Msg.java
|
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
|
import java.io.IOException;
import java.io.InputStream;
import java.util.Comparator;
import java.util.HashMap;
import java.util.TreeSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.utils.Utils;
import us.pfrommer.insteon.utils.Utils.ParsingException;
|
}
/**
* Will fetch address from field
* @param field the filed name to fetch
* @return the address
*/
public InsteonAddress getAddress(String field) throws FieldException {
if (m_definition == null) throw new FieldException("no msg definition!");
return (m_definition.getField(field).getAddress(m_data));
}
/**
* Fetch 3-byte (24bit) from message
* @param key1 the key of the msb
* @param key2 the key of the second msb
* @param key3 the key of the lsb
* @return the integer
*/
public int getInt24(String key1, String key2, String key3) throws FieldException {
if (m_definition == null) throw new FieldException("no msg definition!");
int i = (m_definition.getField(key1).getByte(m_data) << 16) &
(m_definition.getField(key2).getByte(m_data) << 8) &
m_definition.getField(key3).getByte(m_data);
return i;
}
public String toHexString() {
if (m_data != null) {
|
// Path: src/us/pfrommer/insteon/utils/Utils.java
// public class Utils {
// public static String readFile(File f) throws IOException {
// return read(new FileInputStream(f));
// }
// public static String read(InputStream in) throws IOException {
// BufferedReader r = new BufferedReader(new InputStreamReader(in));
// StringBuilder b = new StringBuilder();
//
// String line = null;
// while((line = r.readLine()) != null) {
// b.append(line);
// b.append('\n');
// }
//
// return b.toString();
// }
//
//
// public static String toHex(int b) {
// String result = String.format("%02X", b & 0xFF);
// return result;
// }
// public static String toHex(byte b) {
// String result = String.format("%02X", b);
// return result;
// }
//
// public static String toHex(byte[] b) {
// return toHex(b, 0, b.length);
// }
//
// public static String toHex(byte[] b, int off, int len) {
// return toHex(b, off, len, "");
// }
//
// public static String toHex(byte[] b, int off, int len, String separator) {
// StringBuilder result = new StringBuilder();
// for (int i = 0; i < b.length && i < len; i++) {
// result.append(toHex(b[i]));
// if (i != b.length - 1) result.append(separator);
// }
// return result.toString();
// }
//
// public static int fromHexString(String string) {
// return Integer.parseInt(string, 16);
// }
//
// public static int from0xHexString(String string) {
// String hex = string.substring(2);
// return fromHexString(hex);
// }
//
// public static String toHexByte(byte b) {
// return String.format("0x%02X", b & 0xFF);
// }
//
// public static String toHexByte(int b) {
// return String.format("0x%02X", b);
// }
//
// public static class DataTypeParser {
// public static Object s_parseDataType(DataType type, String val) {
// switch(type) {
// case BYTE: return s_parseByte(val);
// case INT: return s_parseInt(val);
// case FLOAT: return s_parseFloat(val);
// case ADDRESS: return s_parseAddress(val);
// default : throw new IllegalArgumentException("Data Type not implemented in Field Value Parser!");
// }
// }
//
// public static byte s_parseByte(String val) {
// if (val != null && !val.trim().equals("")) {
// return (byte) Utils.from0xHexString(val.trim());
// } else return 0x00;
// }
// public static int s_parseInt(String val) {
// if (val != null && !val.trim().equals("")) {
// return Integer.parseInt(val);
// } else return 0x00;
// }
// public static float s_parseFloat(String val) {
// if (val != null && !val.trim().equals("")) {
// return Float.parseFloat(val.trim());
// } else return 0;
// }
// public static InsteonAddress s_parseAddress(String val) {
// if (val != null && !val.trim().equals("")) {
// return InsteonAddress.s_parseAddress(val.trim());
// } else return new InsteonAddress();
// }
// }
// /**
// * Exception to indicate various xml parsing errors.
// */
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// }
//
// Path: src/us/pfrommer/insteon/utils/Utils.java
// @SuppressWarnings("serial")
// public static class ParsingException extends Exception {
// public ParsingException(String msg) {
// super(msg);
// }
// public ParsingException(String msg, Throwable cause) {
// super(msg, cause);
// }
// }
// Path: src/us/pfrommer/insteon/msg/Msg.java
import java.io.IOException;
import java.io.InputStream;
import java.util.Comparator;
import java.util.HashMap;
import java.util.TreeSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.pfrommer.insteon.utils.Utils;
import us.pfrommer.insteon.utils.Utils.ParsingException;
}
/**
* Will fetch address from field
* @param field the filed name to fetch
* @return the address
*/
public InsteonAddress getAddress(String field) throws FieldException {
if (m_definition == null) throw new FieldException("no msg definition!");
return (m_definition.getField(field).getAddress(m_data));
}
/**
* Fetch 3-byte (24bit) from message
* @param key1 the key of the msb
* @param key2 the key of the second msb
* @param key3 the key of the lsb
* @return the integer
*/
public int getInt24(String key1, String key2, String key3) throws FieldException {
if (m_definition == null) throw new FieldException("no msg definition!");
int i = (m_definition.getField(key1).getByte(m_data) << 16) &
(m_definition.getField(key2).getByte(m_data) << 8) &
m_definition.getField(key3).getByte(m_data);
return i;
}
public String toHexString() {
if (m_data != null) {
|
return Utils.toHex(m_data);
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/location/GeohashGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/StringGenerator.java
// @Facade(accessor = "string")
// public class StringGenerator extends Generator<String> {
//
// protected CharacterGenerator charGen;
// protected int min;
// protected int max;
// protected int length;
//
// public StringGenerator() {
// this.min = 1;
// this.max = 6;
// this.length = 0;
// this.charGen = new CharacterGenerator();
// }
//
// /**
// * Set the pool of characters to choose from
// *
// * @param pool The pool of characters to choose from
// * @return The same generator
// */
// public StringGenerator pool(String pool) {
// charGen.pool(pool);
// return this;
// }
//
// /**
// * Return only symbols
// *
// * @return The same generator
// */
// public StringGenerator symbols() {
// charGen.symbols();
// return this;
// }
//
// /**
// * Return only alphabet characters
// *
// * @return The same generator
// */
// public StringGenerator alpha() {
// charGen.alpha();
// return this;
// }
// /**
// * Add digits to the pool of elements this generator
// * will return
// * @return The same generator
// */
// public StringGenerator addDigits() {
// charGen.addDigits();
// return this;
// }
//
// /**
// * Add letters to the pool of elements this generator
// * will return
// * @return The same generator
// */
// public StringGenerator addAlpha() {
// charGen.addAlpha();
// return this;
// }
//
// /**
// * Add symbols to the pool of elements this generator
// * will return
// * @return The same generator
// */
// public StringGenerator addSymbols() {
// charGen.addSymbols();
// return this;
// }
//
// /**
// * Add a charset to the pool
// * @param charset The charset to add
// * @return The same generator
// */
// public StringGenerator addCharset(CHARSET charset) {
// charGen.addCharset(charset);
// return this;
// }
//
// /**
// * Set the casing of the letters (in case alpha() is used)
// *
// * @param casing Casing of the letters
// * @return The same generator
// */
// public StringGenerator casing(CharacterGenerator.Casing casing) {
// charGen.casing(casing);
// return this;
// }
//
// /**
// * Return only digits
// *
// * @return The same generator
// */
// public StringGenerator digits() {
// charGen.digit();
// return this;
// }
//
// /**
// * Set the casing of the letters (in case alpha() is used)
// *
// * "upper" is uppercase, "lower" is lowercase
// *
// * @param casing Casing of the letters. Use "upper" or "lower"
// * @return The same generator
// */
// public StringGenerator casing(String casing) {
// charGen.casing(casing);
// return this;
// }
//
// /**
// * Set the range of the length of the string between minimum of
// * min and maximum of max
// *
// * @param min Minimum string length (inclusive)
// * @param max Maximum string length (inclusive)
// * @return The same generator
// */
// public StringGenerator range(int min, int max) {
// this.min = min;
// this.max = max;
// return this;
// }
//
// /**
// * Set the length of the string
// *
// * @param length The length of the string
// * @return The same generator
// */
// public StringGenerator length(int length) {
// this.length = length;
// return this;
// }
//
// @Override
// public String gen() {
// StringBuilder builder = new StringBuilder(8);
// int length;
// if (this.length > 0) {
// length = this.length;
// } else {
// length = new NaturalGenerator().min(min).max(max).gen();
// }
//
// while (length > 0) {
// builder.append(charGen.gen());
// length--;
// }
// return builder.toString();
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.StringGenerator;
|
package me.xdrop.jrand.generators.location;
@Facade(accessor = "geohash")
public class GeohashGenerator extends Generator<String> {
protected int length;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/StringGenerator.java
// @Facade(accessor = "string")
// public class StringGenerator extends Generator<String> {
//
// protected CharacterGenerator charGen;
// protected int min;
// protected int max;
// protected int length;
//
// public StringGenerator() {
// this.min = 1;
// this.max = 6;
// this.length = 0;
// this.charGen = new CharacterGenerator();
// }
//
// /**
// * Set the pool of characters to choose from
// *
// * @param pool The pool of characters to choose from
// * @return The same generator
// */
// public StringGenerator pool(String pool) {
// charGen.pool(pool);
// return this;
// }
//
// /**
// * Return only symbols
// *
// * @return The same generator
// */
// public StringGenerator symbols() {
// charGen.symbols();
// return this;
// }
//
// /**
// * Return only alphabet characters
// *
// * @return The same generator
// */
// public StringGenerator alpha() {
// charGen.alpha();
// return this;
// }
// /**
// * Add digits to the pool of elements this generator
// * will return
// * @return The same generator
// */
// public StringGenerator addDigits() {
// charGen.addDigits();
// return this;
// }
//
// /**
// * Add letters to the pool of elements this generator
// * will return
// * @return The same generator
// */
// public StringGenerator addAlpha() {
// charGen.addAlpha();
// return this;
// }
//
// /**
// * Add symbols to the pool of elements this generator
// * will return
// * @return The same generator
// */
// public StringGenerator addSymbols() {
// charGen.addSymbols();
// return this;
// }
//
// /**
// * Add a charset to the pool
// * @param charset The charset to add
// * @return The same generator
// */
// public StringGenerator addCharset(CHARSET charset) {
// charGen.addCharset(charset);
// return this;
// }
//
// /**
// * Set the casing of the letters (in case alpha() is used)
// *
// * @param casing Casing of the letters
// * @return The same generator
// */
// public StringGenerator casing(CharacterGenerator.Casing casing) {
// charGen.casing(casing);
// return this;
// }
//
// /**
// * Return only digits
// *
// * @return The same generator
// */
// public StringGenerator digits() {
// charGen.digit();
// return this;
// }
//
// /**
// * Set the casing of the letters (in case alpha() is used)
// *
// * "upper" is uppercase, "lower" is lowercase
// *
// * @param casing Casing of the letters. Use "upper" or "lower"
// * @return The same generator
// */
// public StringGenerator casing(String casing) {
// charGen.casing(casing);
// return this;
// }
//
// /**
// * Set the range of the length of the string between minimum of
// * min and maximum of max
// *
// * @param min Minimum string length (inclusive)
// * @param max Maximum string length (inclusive)
// * @return The same generator
// */
// public StringGenerator range(int min, int max) {
// this.min = min;
// this.max = max;
// return this;
// }
//
// /**
// * Set the length of the string
// *
// * @param length The length of the string
// * @return The same generator
// */
// public StringGenerator length(int length) {
// this.length = length;
// return this;
// }
//
// @Override
// public String gen() {
// StringBuilder builder = new StringBuilder(8);
// int length;
// if (this.length > 0) {
// length = this.length;
// } else {
// length = new NaturalGenerator().min(min).max(max).gen();
// }
//
// while (length > 0) {
// builder.append(charGen.gen());
// length--;
// }
// return builder.toString();
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/location/GeohashGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.StringGenerator;
package me.xdrop.jrand.generators.location;
@Facade(accessor = "geohash")
public class GeohashGenerator extends Generator<String> {
protected int length;
|
protected StringGenerator string;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/time/MinuteGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
package me.xdrop.jrand.generators.time;
@Facade(accessor = "minute")
public class MinuteGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/time/MinuteGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
package me.xdrop.jrand.generators.time;
@Facade(accessor = "minute")
public class MinuteGenerator extends Generator<String> {
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/basics/StringGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/basics/enums/CHARSET.java
// public enum CHARSET {
//
// CHARS_LOWER(alphaLowerPoolChar),
// CHARS_UPPER(alphaUpperPoolChar),
// NUMBERS(numericPoolChar),
// SYMBOLS(symbolsPoolChar);
//
// char[] charset;
//
// CHARSET(char[] set) {
// this.charset = set;
// }
//
// public char[] getCharset(){
// return this.charset;
// }
//
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.basics.enums.CHARSET;
|
public StringGenerator addDigits() {
charGen.addDigits();
return this;
}
/**
* Add letters to the pool of elements this generator
* will return
* @return The same generator
*/
public StringGenerator addAlpha() {
charGen.addAlpha();
return this;
}
/**
* Add symbols to the pool of elements this generator
* will return
* @return The same generator
*/
public StringGenerator addSymbols() {
charGen.addSymbols();
return this;
}
/**
* Add a charset to the pool
* @param charset The charset to add
* @return The same generator
*/
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/basics/enums/CHARSET.java
// public enum CHARSET {
//
// CHARS_LOWER(alphaLowerPoolChar),
// CHARS_UPPER(alphaUpperPoolChar),
// NUMBERS(numericPoolChar),
// SYMBOLS(symbolsPoolChar);
//
// char[] charset;
//
// CHARSET(char[] set) {
// this.charset = set;
// }
//
// public char[] getCharset(){
// return this.charset;
// }
//
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/StringGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.basics.enums.CHARSET;
public StringGenerator addDigits() {
charGen.addDigits();
return this;
}
/**
* Add letters to the pool of elements this generator
* will return
* @return The same generator
*/
public StringGenerator addAlpha() {
charGen.addAlpha();
return this;
}
/**
* Add symbols to the pool of elements this generator
* will return
* @return The same generator
*/
public StringGenerator addSymbols() {
charGen.addSymbols();
return this;
}
/**
* Add a charset to the pool
* @param charset The charset to add
* @return The same generator
*/
|
public StringGenerator addCharset(CHARSET charset) {
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/model/money/CardType.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/money/IINRange.java
// public class IINRange {
//
// public int getBegin() {
// return begin;
// }
//
// public int getEnd() {
// return end;
// }
//
// private int begin;
// private int end;
//
// private IINRange(int begin, int end) {
// this.begin = begin;
// this.end = end;
// }
//
// static IINRange from(int begin, int end) {
// return new IINRange(begin, end);
// }
//
// static IINRange from(int begin) {
// return new IINRange(begin, -1);
// }
//
// public String toString(){
// if (end == -1){
// return "" + begin;
// } else {
// return begin + "-" + end;
// }
// }
//
// }
|
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.model.money.IINRange;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
|
}
public List<IINRange> getIinRange() {
return iinRange;
}
public int[] getLengths() {
return lengths;
}
public String getSymbol() {
return symbol;
}
public String getFullname() {
return fullname;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(64);
sb.append(getFullname());
sb.append(" [").append(getSymbol()).append("] ");
sb.append("Prefixes: ");
List<String> prefixes = new ArrayList<>();
for (IINRange range : getIinRange()){
prefixes.add(range.toString());
}
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/money/IINRange.java
// public class IINRange {
//
// public int getBegin() {
// return begin;
// }
//
// public int getEnd() {
// return end;
// }
//
// private int begin;
// private int end;
//
// private IINRange(int begin, int end) {
// this.begin = begin;
// this.end = end;
// }
//
// static IINRange from(int begin, int end) {
// return new IINRange(begin, end);
// }
//
// static IINRange from(int begin) {
// return new IINRange(begin, -1);
// }
//
// public String toString(){
// if (end == -1){
// return "" + begin;
// } else {
// return begin + "-" + end;
// }
// }
//
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/money/CardType.java
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.model.money.IINRange;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
}
public List<IINRange> getIinRange() {
return iinRange;
}
public int[] getLengths() {
return lengths;
}
public String getSymbol() {
return symbol;
}
public String getFullname() {
return fullname;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(64);
sb.append(getFullname());
sb.append(" [").append(getSymbol()).append("] ");
sb.append("Prefixes: ");
List<String> prefixes = new ArrayList<>();
for (IINRange range : getIinRange()){
prefixes.add(range.toString());
}
|
String join = CharUtils.join(prefixes, ",");
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/location/LatitudeGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
|
package me.xdrop.jrand.generators.location;
@Facade(accessor = "latitude")
public class LatitudeGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/location/LatitudeGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
package me.xdrop.jrand.generators.location;
@Facade(accessor = "latitude")
public class LatitudeGenerator extends Generator<String> {
|
protected Range<Double> range;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/location/LatitudeGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
|
package me.xdrop.jrand.generators.location;
@Facade(accessor = "latitude")
public class LatitudeGenerator extends Generator<String> {
protected Range<Double> range;
protected int decimals;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/location/LatitudeGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
package me.xdrop.jrand.generators.location;
@Facade(accessor = "latitude")
public class LatitudeGenerator extends Generator<String> {
protected Range<Double> range;
protected int decimals;
|
protected DecimalGenerator decimal;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/money/CVVGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
package me.xdrop.jrand.generators.money;
@Facade(accessor = "cvv")
public class CVVGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/money/CVVGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
package me.xdrop.jrand.generators.money;
@Facade(accessor = "cvv")
public class CVVGenerator extends Generator<String> {
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/time/HourGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.annotation.PropertyFlag;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
package me.xdrop.jrand.generators.time;
@Facade(accessor = "hour")
public class HourGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/time/HourGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.annotation.PropertyFlag;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
package me.xdrop.jrand.generators.time;
@Facade(accessor = "hour")
public class HourGenerator extends Generator<String> {
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/text/ParagraphGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
package me.xdrop.jrand.generators.text;
@Facade(accessor = "paragraph")
public class ParagraphGenerator extends Generator<String> {
protected int minSentences;
protected int maxSentences;
protected String joining;
protected SentenceGenerator sentGen;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/text/ParagraphGenerator.java
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
package me.xdrop.jrand.generators.text;
@Facade(accessor = "paragraph")
public class ParagraphGenerator extends Generator<String> {
protected int minSentences;
protected int maxSentences;
protected String joining;
protected SentenceGenerator sentGen;
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/text/ParagraphGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
/**
* Set the minimum/maximum words in a sentence
*
* @param min Minimum number of words
* @param max Maximum number of words
* @return The same generator
*/
public ParagraphGenerator wordsPerSentence(int min, int max) {
sentGen.words(min, max);
return this;
}
/**
* Set the paragraph joining string
* @param joining The joining string
* @return The same generator
*/
public ParagraphGenerator joining(String joining) {
this.joining = joining;
return this;
}
@Override
public String gen(){
int sentences;
if (maxSentences == -1){
sentences = minSentences;
} else {
sentences = nat.range(minSentences, maxSentences).gen();
}
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/text/ParagraphGenerator.java
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
/**
* Set the minimum/maximum words in a sentence
*
* @param min Minimum number of words
* @param max Maximum number of words
* @return The same generator
*/
public ParagraphGenerator wordsPerSentence(int min, int max) {
sentGen.words(min, max);
return this;
}
/**
* Set the paragraph joining string
* @param joining The joining string
* @return The same generator
*/
public ParagraphGenerator joining(String joining) {
this.joining = joining;
return this;
}
@Override
public String gen(){
int sentences;
if (maxSentences == -1){
sentences = minSentences;
} else {
sentences = nat.range(minSentences, maxSentences).gen();
}
|
return CharUtils.join(sentGen.genMany(sentences), joining);
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/money/IssueDateGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
|
package me.xdrop.jrand.generators.money;
@Facade(accessor = "issueDate")
public class IssueDateGenerator extends Generator<String> {
protected boolean longVersion;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/money/IssueDateGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
package me.xdrop.jrand.generators.money;
@Facade(accessor = "issueDate")
public class IssueDateGenerator extends Generator<String> {
protected boolean longVersion;
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/location/AreaCodeGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.annotation.PropertyFlag;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
package me.xdrop.jrand.generators.location;
@Facade(accessor = "areacode")
public class AreaCodeGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/location/AreaCodeGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.annotation.PropertyFlag;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
package me.xdrop.jrand.generators.location;
@Facade(accessor = "areacode")
public class AreaCodeGenerator extends Generator<String> {
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/location/LongitudeGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
|
package me.xdrop.jrand.generators.location;
@Facade(accessor = "longitude")
public class LongitudeGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/location/LongitudeGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
package me.xdrop.jrand.generators.location;
@Facade(accessor = "longitude")
public class LongitudeGenerator extends Generator<String> {
|
protected Range<Double> range;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/location/LongitudeGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
|
package me.xdrop.jrand.generators.location;
@Facade(accessor = "longitude")
public class LongitudeGenerator extends Generator<String> {
protected Range<Double> range;
protected int decimals;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/location/LongitudeGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
package me.xdrop.jrand.generators.location;
@Facade(accessor = "longitude")
public class LongitudeGenerator extends Generator<String> {
protected Range<Double> range;
protected int decimals;
|
protected DecimalGenerator decimal;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/location/DepthGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
|
package me.xdrop.jrand.generators.location;
@Facade(accessor = "depth")
public class DepthGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/location/DepthGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
package me.xdrop.jrand.generators.location;
@Facade(accessor = "depth")
public class DepthGenerator extends Generator<String> {
|
protected DecimalGenerator decimal;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/location/DepthGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
|
package me.xdrop.jrand.generators.location;
@Facade(accessor = "depth")
public class DepthGenerator extends Generator<String> {
protected DecimalGenerator decimal;
protected int noDecimals;
public DepthGenerator() {
this.noDecimals = 5;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/location/DepthGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
import me.xdrop.jrand.model.Range;
package me.xdrop.jrand.generators.location;
@Facade(accessor = "depth")
public class DepthGenerator extends Generator<String> {
protected DecimalGenerator decimal;
protected int noDecimals;
public DepthGenerator() {
this.noDecimals = 5;
|
this.decimal = new DecimalGenerator().range(Range.from(-10994.0, 0.0)).digits(noDecimals);
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.Range;
import java.math.BigDecimal;
|
package me.xdrop.jrand.generators.basics;
@Facade(accessor = "decimal")
public class DecimalGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.Range;
import java.math.BigDecimal;
package me.xdrop.jrand.generators.basics;
@Facade(accessor = "decimal")
public class DecimalGenerator extends Generator<String> {
|
protected Range<Double> range;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/location/AltitudeGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
|
package me.xdrop.jrand.generators.location;
@Facade(accessor = "altitude")
public class AltitudeGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DecimalGenerator.java
// @Facade(accessor = "decimal")
// public class DecimalGenerator extends Generator<String> {
//
// protected Range<Double> range;
// protected int digits;
// protected boolean roundUp;
// protected DoubleGenerator dbl;
//
// public DecimalGenerator() {
// this.roundUp = true;
// this.dbl = new DoubleGenerator();
// this.range = Range.from(100.0);
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public DecimalGenerator min(double min) {
// dbl.min(min);
// return this;
// }
//
// /**
// * Sets the maximum value (inclusive)
// *
// * @param max The maximum value
// * @return The same generator
// */
// public DecimalGenerator max(double max) {
// dbl.max(max);
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public DecimalGenerator range(double min, double max) {
// dbl.range(min, max);
// return this;
// }
//
// /**
// * Set a min/max range
// * @param range The range
// * @return The same generator
// */
// public DecimalGenerator range(Range<Double> range) {
// dbl.range(range);
// return this;
// }
//
// /**
// * Sets the number of digits to return
// *
// * @param digits Number of digits
// * @return The same generator
// */
// public DecimalGenerator digits(int digits) {
// this.digits = digits;
// return this;
// }
//
// /**
// * Set whether to round up or down
// *
// * @param roundUp True for round up, false for round down
// * @return The same generator
// */
// public DecimalGenerator roundUp(boolean roundUp) {
// this.roundUp = roundUp;
// return this;
// }
//
// /**
// * Generate a {@link BigDecimal} as opposed to a String
// *
// * @return Return the value as BigDecimal
// */
// public BigDecimal genAsDecimal() {
// double rand = dbl.gen();
// BigDecimal decimal;
// if (digits != 0) {
// if (roundUp) {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_UP);
// } else {
// decimal = BigDecimal.valueOf(rand).setScale(digits, BigDecimal.ROUND_DOWN);
// }
// } else {
// decimal = BigDecimal.valueOf(rand);
// }
//
// return decimal;
// }
//
// @Override
// public String gen() {
// return genAsDecimal().toString();
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/location/AltitudeGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.DecimalGenerator;
package me.xdrop.jrand.generators.location;
@Facade(accessor = "altitude")
public class AltitudeGenerator extends Generator<String> {
|
protected DecimalGenerator decimal;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/text/WordGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
package me.xdrop.jrand.generators.text;
@Facade(accessor = "word")
public class WordGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/text/WordGenerator.java
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
package me.xdrop.jrand.generators.text;
@Facade(accessor = "word")
public class WordGenerator extends Generator<String> {
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/text/WordGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
public WordGenerator capitalize(boolean enable) {
this.capitalize = enable;
return this;
}
@Override
public String gen() {
StringBuilder sbr = new StringBuilder(8);
String result;
if (length > 0) {
while (sbr.length() < length) {
sbr.append(syl.gen());
}
result = sbr.substring(0, length);
} else {
int syllables;
if (syllablesMax == -1) {
syllables = syllablesMin;
} else {
syllables = nat.range(syllablesMin, syllablesMax).gen();
}
for (int i = 0; i < syllables; i++) {
sbr.append(syl.gen());
}
result = sbr.toString();
}
if (capitalize) {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/CharUtils.java
// public class CharUtils {
//
// public static String capitalize(String in) {
// if (in.length() > 1) {
// return in.substring(0, 1).toUpperCase() + in.substring(1);
// } else {
// return in.toUpperCase();
// }
// }
//
// public static String join(List<String> in, String sep) {
// int size = in.size();
// StringBuilder sbr = new StringBuilder(size * 2);
//
// for (int i = 1; i <= size; i++) {
// sbr.append(in.get(i - 1));
// if (i != size){
// sbr.append(sep);
// }
// }
//
// return sbr.toString();
//
// }
//
// public static String join(List<String> in, String sep, String fin) {
// return join(in, sep) + fin;
// }
//
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/text/WordGenerator.java
import me.xdrop.jrand.CharUtils;
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
public WordGenerator capitalize(boolean enable) {
this.capitalize = enable;
return this;
}
@Override
public String gen() {
StringBuilder sbr = new StringBuilder(8);
String result;
if (length > 0) {
while (sbr.length() < length) {
sbr.append(syl.gen());
}
result = sbr.substring(0, length);
} else {
int syllables;
if (syllablesMax == -1) {
syllables = syllablesMin;
} else {
syllables = nat.range(syllablesMin, syllablesMax).gen();
}
for (int i = 0; i < syllables; i++) {
sbr.append(syl.gen());
}
result = sbr.toString();
}
if (capitalize) {
|
return CharUtils.capitalize(result);
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/person/GenderGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/BoolGenerator.java
// @Facade(accessor = "bool")
// public class BoolGenerator extends Generator<Boolean> {
//
// protected int likelihood;
//
// public BoolGenerator() {
// this.likelihood = 50;
// }
//
// /**
// * Sets the likelihood of generating a true value
// *
// * @param likelihood The likelihood as int between 0 and 100
// * @return The same generator
// */
// public BoolGenerator likelihood(int likelihood) {
// this.likelihood = likelihood;
// return this;
// }
//
// @Override
// public Boolean gen() {
// float rand = random().randFloat();
// return rand <= ((float) likelihood / 100);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Gender.java
// public enum Gender {
// MALE,
// FEMALE,
// NEUTRAL
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.BoolGenerator;
import me.xdrop.jrand.model.person.Gender;
|
package me.xdrop.jrand.generators.person;
@Facade(accessor = "gender")
public class GenderGenerator extends Generator<String> {
protected String male;
protected String female;
protected boolean full;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/BoolGenerator.java
// @Facade(accessor = "bool")
// public class BoolGenerator extends Generator<Boolean> {
//
// protected int likelihood;
//
// public BoolGenerator() {
// this.likelihood = 50;
// }
//
// /**
// * Sets the likelihood of generating a true value
// *
// * @param likelihood The likelihood as int between 0 and 100
// * @return The same generator
// */
// public BoolGenerator likelihood(int likelihood) {
// this.likelihood = likelihood;
// return this;
// }
//
// @Override
// public Boolean gen() {
// float rand = random().randFloat();
// return rand <= ((float) likelihood / 100);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Gender.java
// public enum Gender {
// MALE,
// FEMALE,
// NEUTRAL
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/person/GenderGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.BoolGenerator;
import me.xdrop.jrand.model.person.Gender;
package me.xdrop.jrand.generators.person;
@Facade(accessor = "gender")
public class GenderGenerator extends Generator<String> {
protected String male;
protected String female;
protected boolean full;
|
protected BoolGenerator bool;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/person/GenderGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/BoolGenerator.java
// @Facade(accessor = "bool")
// public class BoolGenerator extends Generator<Boolean> {
//
// protected int likelihood;
//
// public BoolGenerator() {
// this.likelihood = 50;
// }
//
// /**
// * Sets the likelihood of generating a true value
// *
// * @param likelihood The likelihood as int between 0 and 100
// * @return The same generator
// */
// public BoolGenerator likelihood(int likelihood) {
// this.likelihood = likelihood;
// return this;
// }
//
// @Override
// public Boolean gen() {
// float rand = random().randFloat();
// return rand <= ((float) likelihood / 100);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Gender.java
// public enum Gender {
// MALE,
// FEMALE,
// NEUTRAL
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.BoolGenerator;
import me.xdrop.jrand.model.person.Gender;
|
package me.xdrop.jrand.generators.person;
@Facade(accessor = "gender")
public class GenderGenerator extends Generator<String> {
protected String male;
protected String female;
protected boolean full;
protected BoolGenerator bool;
public GenderGenerator() {
this.bool = new BoolGenerator();
}
/**
* Specify custom strings to be returned
* @param male The male string to return
* @param female The female string to return
* @return The same generator
*/
public GenderGenerator format(String male, String female) {
this.male = male;
this.female = female;
return this;
}
/**
* Return "Male" and "Female" instead of "M" and "F"
* @return The same generator
*/
public GenderGenerator full() {
return full(true);
}
/**
* Return "Male" and "Female" instead of "M" and "F"
* @param enabled True for full,
* False for short
* @return The same generator
*/
public GenderGenerator full(boolean enabled) {
this.full = enabled;
return this;
}
/**
* The likelihood to return male
* @param likelihood An integer out of 100,
* where 100 is 100% chance of
* male.
* @return The same generator
*/
public GenderGenerator likelihood(int likelihood) {
bool.likelihood(likelihood);
return this;
}
/**
* Generate as a {@link Gender} object
* @return The gender object
*/
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/BoolGenerator.java
// @Facade(accessor = "bool")
// public class BoolGenerator extends Generator<Boolean> {
//
// protected int likelihood;
//
// public BoolGenerator() {
// this.likelihood = 50;
// }
//
// /**
// * Sets the likelihood of generating a true value
// *
// * @param likelihood The likelihood as int between 0 and 100
// * @return The same generator
// */
// public BoolGenerator likelihood(int likelihood) {
// this.likelihood = likelihood;
// return this;
// }
//
// @Override
// public Boolean gen() {
// float rand = random().randFloat();
// return rand <= ((float) likelihood / 100);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Gender.java
// public enum Gender {
// MALE,
// FEMALE,
// NEUTRAL
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/person/GenderGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.BoolGenerator;
import me.xdrop.jrand.model.person.Gender;
package me.xdrop.jrand.generators.person;
@Facade(accessor = "gender")
public class GenderGenerator extends Generator<String> {
protected String male;
protected String female;
protected boolean full;
protected BoolGenerator bool;
public GenderGenerator() {
this.bool = new BoolGenerator();
}
/**
* Specify custom strings to be returned
* @param male The male string to return
* @param female The female string to return
* @return The same generator
*/
public GenderGenerator format(String male, String female) {
this.male = male;
this.female = female;
return this;
}
/**
* Return "Male" and "Female" instead of "M" and "F"
* @return The same generator
*/
public GenderGenerator full() {
return full(true);
}
/**
* Return "Male" and "Female" instead of "M" and "F"
* @param enabled True for full,
* False for short
* @return The same generator
*/
public GenderGenerator full(boolean enabled) {
this.full = enabled;
return this;
}
/**
* The likelihood to return male
* @param likelihood An integer out of 100,
* where 100 is 100% chance of
* male.
* @return The same generator
*/
public GenderGenerator likelihood(int likelihood) {
bool.likelihood(likelihood);
return this;
}
/**
* Generate as a {@link Gender} object
* @return The gender object
*/
|
public Gender genAsGender() {
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/person/NameGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Gender.java
// public enum Gender {
// MALE,
// FEMALE,
// NEUTRAL
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.person.Gender;
|
package me.xdrop.jrand.generators.person;
@Facade(accessor = "name")
public class NameGenerator extends Generator<String> {
protected LastnameGenerator last;
protected FirstnameGenerator first;
protected PrefixGenerator prefix;
protected boolean reverseOrder;
protected boolean withMiddleName;
protected boolean withPrefix;
protected boolean asCardName;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Gender.java
// public enum Gender {
// MALE,
// FEMALE,
// NEUTRAL
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/person/NameGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.person.Gender;
package me.xdrop.jrand.generators.person;
@Facade(accessor = "name")
public class NameGenerator extends Generator<String> {
protected LastnameGenerator last;
protected FirstnameGenerator first;
protected PrefixGenerator prefix;
protected boolean reverseOrder;
protected boolean withMiddleName;
protected boolean withPrefix;
protected boolean asCardName;
|
protected Gender gender;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/time/MillisecondGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
package me.xdrop.jrand.generators.time;
@Facade(accessor = "millisecond")
public class MillisecondGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/time/MillisecondGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
package me.xdrop.jrand.generators.time;
@Facade(accessor = "millisecond")
public class MillisecondGenerator extends Generator<String> {
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/time/SecondGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
|
package me.xdrop.jrand.generators.time;
@Facade(accessor = "second")
public class SecondGenerator extends Generator<String> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/time/SecondGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
package me.xdrop.jrand.generators.time;
@Facade(accessor = "second")
public class SecondGenerator extends Generator<String> {
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/person/AgeGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PersonType.java
// public enum PersonType {
// CHILD(1, 12),
// TEEN(13,17),
// ADULT(18, 40),
// SENIOR(41, 120),
// GENERIC(1, 120);
//
// private int min;
//
// private int max;
// PersonType(int min, int max) {
// this.min = min;
// this.max = max;
// }
//
// public int getMin() {
// return min;
// }
//
// public int getMax() {
// return max;
// }
//
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
import me.xdrop.jrand.model.person.PersonType;
|
package me.xdrop.jrand.generators.person;
@Facade(accessor = "age")
public class AgeGenerator extends Generator<Integer> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PersonType.java
// public enum PersonType {
// CHILD(1, 12),
// TEEN(13,17),
// ADULT(18, 40),
// SENIOR(41, 120),
// GENERIC(1, 120);
//
// private int min;
//
// private int max;
// PersonType(int min, int max) {
// this.min = min;
// this.max = max;
// }
//
// public int getMin() {
// return min;
// }
//
// public int getMax() {
// return max;
// }
//
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/person/AgeGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
import me.xdrop.jrand.model.person.PersonType;
package me.xdrop.jrand.generators.person;
@Facade(accessor = "age")
public class AgeGenerator extends Generator<Integer> {
|
protected PersonType personType;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/person/AgeGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PersonType.java
// public enum PersonType {
// CHILD(1, 12),
// TEEN(13,17),
// ADULT(18, 40),
// SENIOR(41, 120),
// GENERIC(1, 120);
//
// private int min;
//
// private int max;
// PersonType(int min, int max) {
// this.min = min;
// this.max = max;
// }
//
// public int getMin() {
// return min;
// }
//
// public int getMax() {
// return max;
// }
//
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
import me.xdrop.jrand.model.person.PersonType;
|
package me.xdrop.jrand.generators.person;
@Facade(accessor = "age")
public class AgeGenerator extends Generator<Integer> {
protected PersonType personType;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PersonType.java
// public enum PersonType {
// CHILD(1, 12),
// TEEN(13,17),
// ADULT(18, 40),
// SENIOR(41, 120),
// GENERIC(1, 120);
//
// private int min;
//
// private int max;
// PersonType(int min, int max) {
// this.min = min;
// this.max = max;
// }
//
// public int getMin() {
// return min;
// }
//
// public int getMax() {
// return max;
// }
//
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/person/AgeGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
import me.xdrop.jrand.model.person.PersonType;
package me.xdrop.jrand.generators.person;
@Facade(accessor = "age")
public class AgeGenerator extends Generator<Integer> {
protected PersonType personType;
|
protected NaturalGenerator natGen;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/data/AssetDescriptor.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
|
import me.xdrop.jrand.Tuple;
import java.util.*;
|
package me.xdrop.jrand.data;
public class AssetDescriptor<T> {
private final String fileName;
private final AssetMapper<T> mapper;
private final IndexMapper<T> aliasIndexMapper;
private final IndexMapper<T> groupingIndexMapper;
public AssetDescriptor(String fileName, AssetMapper<T> mapper, IndexMapper<T> aliasIndexMapper, IndexMapper<T> groupingIndexMapper) {
this.fileName = fileName;
this.mapper = mapper;
this.aliasIndexMapper = aliasIndexMapper;
this.groupingIndexMapper = groupingIndexMapper;
}
public AssetDescriptor(String fileName, AssetMapper<T> mapper, IndexMapper<T> aliasIndexMapper) {
this.fileName = fileName;
this.mapper = mapper;
this.aliasIndexMapper = aliasIndexMapper;
this.groupingIndexMapper = null;
}
public AssetDescriptor(String fileName, AssetMapper<T> mapper) {
this.fileName = fileName;
this.mapper = mapper;
this.aliasIndexMapper = null;
this.groupingIndexMapper = null;
}
private Map<String, T> createAliasIndex(Asset<T> asset) {
Map<String,T> aliasIndex = new HashMap<>();
for (T t : asset.getItems()) {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/AssetDescriptor.java
import me.xdrop.jrand.Tuple;
import java.util.*;
package me.xdrop.jrand.data;
public class AssetDescriptor<T> {
private final String fileName;
private final AssetMapper<T> mapper;
private final IndexMapper<T> aliasIndexMapper;
private final IndexMapper<T> groupingIndexMapper;
public AssetDescriptor(String fileName, AssetMapper<T> mapper, IndexMapper<T> aliasIndexMapper, IndexMapper<T> groupingIndexMapper) {
this.fileName = fileName;
this.mapper = mapper;
this.aliasIndexMapper = aliasIndexMapper;
this.groupingIndexMapper = groupingIndexMapper;
}
public AssetDescriptor(String fileName, AssetMapper<T> mapper, IndexMapper<T> aliasIndexMapper) {
this.fileName = fileName;
this.mapper = mapper;
this.aliasIndexMapper = aliasIndexMapper;
this.groupingIndexMapper = null;
}
public AssetDescriptor(String fileName, AssetMapper<T> mapper) {
this.fileName = fileName;
this.mapper = mapper;
this.aliasIndexMapper = null;
this.groupingIndexMapper = null;
}
private Map<String, T> createAliasIndex(Asset<T> asset) {
Map<String,T> aliasIndex = new HashMap<>();
for (T t : asset.getItems()) {
|
Tuple<String, T> alias = Objects.requireNonNull(aliasIndexMapper).indexedMap(t);
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.Range;
import java.util.ArrayList;
import java.util.List;
|
package me.xdrop.jrand.generators.basics;
@Facade(accessor = "natural")
public class NaturalGenerator extends Generator<Integer> {
protected int min;
protected int max;
public NaturalGenerator() {
this.max = Integer.MAX_VALUE - 1;
this.min = 0;
}
/**
* Set the minimum value (inclusive)
*
* @param min The minimum value
* @return The same generator
*/
public NaturalGenerator min(int min) {
this.min = min;
return this;
}
/**
* Set the maximum value to return (inclusive)
*
* @param max The maximum value to return (inclusive)
* @return The same generator
*/
public NaturalGenerator max(int max) {
this.max = max;
return this;
}
/**
* Set a min/max range
*
* @param min Minimum value to be returned (inclusive)
* @param max Maximum value to be returned (inclusive)
* @return The same generator
*/
public NaturalGenerator range(int min, int max) {
min(min);
max(max);
return this;
}
/**
* Set a range starting from 0
*
* @param max Maximum value to be returned (inclusive)
* @return The same generator
*/
public NaturalGenerator range(int max) {
min(0);
max(max - 1);
return this;
}
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.Range;
import java.util.ArrayList;
import java.util.List;
package me.xdrop.jrand.generators.basics;
@Facade(accessor = "natural")
public class NaturalGenerator extends Generator<Integer> {
protected int min;
protected int max;
public NaturalGenerator() {
this.max = Integer.MAX_VALUE - 1;
this.min = 0;
}
/**
* Set the minimum value (inclusive)
*
* @param min The minimum value
* @return The same generator
*/
public NaturalGenerator min(int min) {
this.min = min;
return this;
}
/**
* Set the maximum value to return (inclusive)
*
* @param max The maximum value to return (inclusive)
* @return The same generator
*/
public NaturalGenerator max(int max) {
this.max = max;
return this;
}
/**
* Set a min/max range
*
* @param min Minimum value to be returned (inclusive)
* @param max Maximum value to be returned (inclusive)
* @return The same generator
*/
public NaturalGenerator range(int min, int max) {
min(min);
max(max);
return this;
}
/**
* Set a range starting from 0
*
* @param max Maximum value to be returned (inclusive)
* @return The same generator
*/
public NaturalGenerator range(int max) {
min(0);
max(max - 1);
return this;
}
|
public NaturalGenerator range(Range<Integer> rangeOption) {
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/person/BirthdayGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PersonType.java
// public enum PersonType {
// CHILD(1, 12),
// TEEN(13,17),
// ADULT(18, 40),
// SENIOR(41, 120),
// GENERIC(1, 120);
//
// private int min;
//
// private int max;
// PersonType(int min, int max) {
// this.min = min;
// this.max = max;
// }
//
// public int getMin() {
// return min;
// }
//
// public int getMax() {
// return max;
// }
//
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.person.PersonType;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.Period;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.util.Date;
|
package me.xdrop.jrand.generators.person;
@Facade(accessor = "birthday")
public class BirthdayGenerator extends Generator<Date> {
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PersonType.java
// public enum PersonType {
// CHILD(1, 12),
// TEEN(13,17),
// ADULT(18, 40),
// SENIOR(41, 120),
// GENERIC(1, 120);
//
// private int min;
//
// private int max;
// PersonType(int min, int max) {
// this.min = min;
// this.max = max;
// }
//
// public int getMin() {
// return min;
// }
//
// public int getMax() {
// return max;
// }
//
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/person/BirthdayGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.person.PersonType;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.Period;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.util.Date;
package me.xdrop.jrand.generators.person;
@Facade(accessor = "birthday")
public class BirthdayGenerator extends Generator<Date> {
|
protected PersonType personType;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/model/location/CountryMapper.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/AssetMapper.java
// public interface AssetMapper<T> {
// T map(String element);
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/IndexMapper.java
// public interface IndexMapper<T> {
//
// Tuple<String,T> indexedMap(T element);
// }
|
import me.xdrop.jrand.Tuple;
import me.xdrop.jrand.data.AssetMapper;
import me.xdrop.jrand.data.IndexMapper;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
|
package me.xdrop.jrand.model.location;
public class CountryMapper implements IndexMapper<Country>, AssetMapper<Country> {
private Pattern pattern = Pattern.compile("\"\"\"([\\w\\d\\s]+)\"\"\"");
public Country map(String element) {
String[] parts = element.split(";");
boolean fixedCode = false;
String postalCode = parts[2];
if (parts[2].startsWith("\"\"\"")) {
fixedCode = true;
Matcher matcher = pattern.matcher(parts[2]);
if (matcher.find()) {
postalCode = matcher.group(1);
}
}
return new Country(parts[1], parts[0], postalCode, fixedCode);
}
@Override
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/AssetMapper.java
// public interface AssetMapper<T> {
// T map(String element);
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/IndexMapper.java
// public interface IndexMapper<T> {
//
// Tuple<String,T> indexedMap(T element);
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/location/CountryMapper.java
import me.xdrop.jrand.Tuple;
import me.xdrop.jrand.data.AssetMapper;
import me.xdrop.jrand.data.IndexMapper;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package me.xdrop.jrand.model.location;
public class CountryMapper implements IndexMapper<Country>, AssetMapper<Country> {
private Pattern pattern = Pattern.compile("\"\"\"([\\w\\d\\s]+)\"\"\"");
public Country map(String element) {
String[] parts = element.split(";");
boolean fixedCode = false;
String postalCode = parts[2];
if (parts[2].startsWith("\"\"\"")) {
fixedCode = true;
Matcher matcher = pattern.matcher(parts[2]);
if (matcher.find()) {
postalCode = matcher.group(1);
}
}
return new Country(parts[1], parts[0], postalCode, fixedCode);
}
@Override
|
public Tuple<String, Country> indexedMap(Country element) {
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DoubleGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.Range;
|
package me.xdrop.jrand.generators.basics;
@Facade(accessor = "dbl")
public class DoubleGenerator extends Generator<Double> {
protected double min;
protected double max;
public DoubleGenerator() {
this.min = Double.MIN_VALUE;
this.max = Double.MAX_VALUE;
}
/**
* Sets the maximum value (inclusive)
*
* @param max The maximum value
* @return The same generator
*/
public DoubleGenerator max(double max) {
this.max = max;
return this;
}
/**
* Set the minimum value (inclusive)
*
* @param min The minimum value
* @return The same generator
*/
public DoubleGenerator min(double min) {
this.min = min;
if (this.max < min) {
this.max = min * 2;
}
return this;
}
/**
* Set a min/max range
*
* @param min Minimum value to be returned (inclusive)
* @param max Maximum value to be returned (inclusive)
* @return The same generator
*/
public DoubleGenerator range(double min, double max) {
this.max = max;
this.min = min;
return this;
}
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/Range.java
// public class Range<T extends Number> {
// private T min;
// private T max;
//
// public static <T extends Number> Range<T> from(T min, T max) {
// return new Range<>(min, max);
// }
//
// public static <T extends Number> Range<T> from(T fixed) {
// return new Range<>(fixed, fixed);
// }
//
// private Range(T min, T max) {
// this.min = min;
// this.max = max;
// }
//
// public boolean isSingle() {
// return min.equals(max);
// }
//
// public T getMin() {
// return min;
// }
//
// public T getMax() {
// return max;
// }
//
// public Range<T> newMin(T min) {
// return new Range<>(min, max);
// }
//
// public Range<T> newMax(T max) {
// return new Range<>(min, max);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/DoubleGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.Range;
package me.xdrop.jrand.generators.basics;
@Facade(accessor = "dbl")
public class DoubleGenerator extends Generator<Double> {
protected double min;
protected double max;
public DoubleGenerator() {
this.min = Double.MIN_VALUE;
this.max = Double.MAX_VALUE;
}
/**
* Sets the maximum value (inclusive)
*
* @param max The maximum value
* @return The same generator
*/
public DoubleGenerator max(double max) {
this.max = max;
return this;
}
/**
* Set the minimum value (inclusive)
*
* @param min The minimum value
* @return The same generator
*/
public DoubleGenerator min(double min) {
this.min = min;
if (this.max < min) {
this.max = min * 2;
}
return this;
}
/**
* Set a min/max range
*
* @param min Minimum value to be returned (inclusive)
* @param max Maximum value to be returned (inclusive)
* @return The same generator
*/
public DoubleGenerator range(double min, double max) {
this.max = max;
this.min = min;
return this;
}
|
public DoubleGenerator range(Range<Double> range) {
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/model/location/CityMapper.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/AssetMapper.java
// public interface AssetMapper<T> {
// T map(String element);
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/IndexMapper.java
// public interface IndexMapper<T> {
//
// Tuple<String,T> indexedMap(T element);
// }
|
import me.xdrop.jrand.Tuple;
import me.xdrop.jrand.data.AssetMapper;
import me.xdrop.jrand.data.IndexMapper;
|
package me.xdrop.jrand.model.location;
public class CityMapper implements AssetMapper<City>, IndexMapper<City>{
@Override
public City map(String element) {
String[] parts = element.split(",");
return new City(parts[1], parts[0], parts[2], parts[3]);
}
@Override
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/AssetMapper.java
// public interface AssetMapper<T> {
// T map(String element);
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/IndexMapper.java
// public interface IndexMapper<T> {
//
// Tuple<String,T> indexedMap(T element);
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/location/CityMapper.java
import me.xdrop.jrand.Tuple;
import me.xdrop.jrand.data.AssetMapper;
import me.xdrop.jrand.data.IndexMapper;
package me.xdrop.jrand.model.location;
public class CityMapper implements AssetMapper<City>, IndexMapper<City>{
@Override
public City map(String element) {
String[] parts = element.split(",");
return new City(parts[1], parts[0], parts[2], parts[3]);
}
@Override
|
public Tuple<String, City> indexedMap(City element) {
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/data/Assets.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Prefix.java
// public class Prefix {
// private String abbreviation;
// private String full;
// private String gender;
//
// public Prefix(String abbreviation, String full, String gender) {
// this.abbreviation = abbreviation;
// this.full = full;
// this.gender = gender;
// }
//
// public String getAbbreviation() {
// return abbreviation;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getGender() {
// return gender;
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PrefixMapper.java
// public class PrefixMapper implements AssetMapper<Prefix> {
// @Override
// public Prefix map(String element) {
// String[] parts = element.split(";");
// return new Prefix(parts[0], parts[1], parts[2]);
// }
// }
|
import me.xdrop.jrand.model.location.*;
import me.xdrop.jrand.model.person.Prefix;
import me.xdrop.jrand.model.person.PrefixMapper;
|
package me.xdrop.jrand.data;
public class Assets {
public static AssetDescriptor<City> CITIES = new AssetDescriptor<>("cities.txt", new CityMapper(), null, new CityMapper());
public static AssetDescriptor<Country> COUNTRIES = new AssetDescriptor<>("countries.txt", new CountryMapper(), new CountryMapper());
public static AssetDescriptor<StreetSuffix> UK_STREET_SUFFIXES = new AssetDescriptor<>("uk/street_suffixes.txt", new StreetSuffixMapper());
public static AssetDescriptor<StreetSuffix> US_STREET_SUFFIXES = new AssetDescriptor<>("us/street_suffixes.txt", new StreetSuffixMapper());
public static AssetDescriptor<String> NEUTRAL_SURNAMES = new AssetDescriptor<>("neutral/surnames.txt", new StringMapper());
public static AssetDescriptor<String> MALE_FIRSTNAMES = new AssetDescriptor<>("male/firstnames.txt", new StringMapper());
public static AssetDescriptor<String> FEMALE_FIRSTNAMES = new AssetDescriptor<>("female/firstnames.txt", new StringMapper());
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Prefix.java
// public class Prefix {
// private String abbreviation;
// private String full;
// private String gender;
//
// public Prefix(String abbreviation, String full, String gender) {
// this.abbreviation = abbreviation;
// this.full = full;
// this.gender = gender;
// }
//
// public String getAbbreviation() {
// return abbreviation;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getGender() {
// return gender;
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PrefixMapper.java
// public class PrefixMapper implements AssetMapper<Prefix> {
// @Override
// public Prefix map(String element) {
// String[] parts = element.split(";");
// return new Prefix(parts[0], parts[1], parts[2]);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/Assets.java
import me.xdrop.jrand.model.location.*;
import me.xdrop.jrand.model.person.Prefix;
import me.xdrop.jrand.model.person.PrefixMapper;
package me.xdrop.jrand.data;
public class Assets {
public static AssetDescriptor<City> CITIES = new AssetDescriptor<>("cities.txt", new CityMapper(), null, new CityMapper());
public static AssetDescriptor<Country> COUNTRIES = new AssetDescriptor<>("countries.txt", new CountryMapper(), new CountryMapper());
public static AssetDescriptor<StreetSuffix> UK_STREET_SUFFIXES = new AssetDescriptor<>("uk/street_suffixes.txt", new StreetSuffixMapper());
public static AssetDescriptor<StreetSuffix> US_STREET_SUFFIXES = new AssetDescriptor<>("us/street_suffixes.txt", new StreetSuffixMapper());
public static AssetDescriptor<String> NEUTRAL_SURNAMES = new AssetDescriptor<>("neutral/surnames.txt", new StringMapper());
public static AssetDescriptor<String> MALE_FIRSTNAMES = new AssetDescriptor<>("male/firstnames.txt", new StringMapper());
public static AssetDescriptor<String> FEMALE_FIRSTNAMES = new AssetDescriptor<>("female/firstnames.txt", new StringMapper());
|
public static AssetDescriptor<Prefix> NEUTRAL_PREFIXES = new AssetDescriptor<>("neutral/prefixes.txt", new PrefixMapper());
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/data/Assets.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Prefix.java
// public class Prefix {
// private String abbreviation;
// private String full;
// private String gender;
//
// public Prefix(String abbreviation, String full, String gender) {
// this.abbreviation = abbreviation;
// this.full = full;
// this.gender = gender;
// }
//
// public String getAbbreviation() {
// return abbreviation;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getGender() {
// return gender;
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PrefixMapper.java
// public class PrefixMapper implements AssetMapper<Prefix> {
// @Override
// public Prefix map(String element) {
// String[] parts = element.split(";");
// return new Prefix(parts[0], parts[1], parts[2]);
// }
// }
|
import me.xdrop.jrand.model.location.*;
import me.xdrop.jrand.model.person.Prefix;
import me.xdrop.jrand.model.person.PrefixMapper;
|
package me.xdrop.jrand.data;
public class Assets {
public static AssetDescriptor<City> CITIES = new AssetDescriptor<>("cities.txt", new CityMapper(), null, new CityMapper());
public static AssetDescriptor<Country> COUNTRIES = new AssetDescriptor<>("countries.txt", new CountryMapper(), new CountryMapper());
public static AssetDescriptor<StreetSuffix> UK_STREET_SUFFIXES = new AssetDescriptor<>("uk/street_suffixes.txt", new StreetSuffixMapper());
public static AssetDescriptor<StreetSuffix> US_STREET_SUFFIXES = new AssetDescriptor<>("us/street_suffixes.txt", new StreetSuffixMapper());
public static AssetDescriptor<String> NEUTRAL_SURNAMES = new AssetDescriptor<>("neutral/surnames.txt", new StringMapper());
public static AssetDescriptor<String> MALE_FIRSTNAMES = new AssetDescriptor<>("male/firstnames.txt", new StringMapper());
public static AssetDescriptor<String> FEMALE_FIRSTNAMES = new AssetDescriptor<>("female/firstnames.txt", new StringMapper());
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/Prefix.java
// public class Prefix {
// private String abbreviation;
// private String full;
// private String gender;
//
// public Prefix(String abbreviation, String full, String gender) {
// this.abbreviation = abbreviation;
// this.full = full;
// this.gender = gender;
// }
//
// public String getAbbreviation() {
// return abbreviation;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getGender() {
// return gender;
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/person/PrefixMapper.java
// public class PrefixMapper implements AssetMapper<Prefix> {
// @Override
// public Prefix map(String element) {
// String[] parts = element.split(";");
// return new Prefix(parts[0], parts[1], parts[2]);
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/data/Assets.java
import me.xdrop.jrand.model.location.*;
import me.xdrop.jrand.model.person.Prefix;
import me.xdrop.jrand.model.person.PrefixMapper;
package me.xdrop.jrand.data;
public class Assets {
public static AssetDescriptor<City> CITIES = new AssetDescriptor<>("cities.txt", new CityMapper(), null, new CityMapper());
public static AssetDescriptor<Country> COUNTRIES = new AssetDescriptor<>("countries.txt", new CountryMapper(), new CountryMapper());
public static AssetDescriptor<StreetSuffix> UK_STREET_SUFFIXES = new AssetDescriptor<>("uk/street_suffixes.txt", new StreetSuffixMapper());
public static AssetDescriptor<StreetSuffix> US_STREET_SUFFIXES = new AssetDescriptor<>("us/street_suffixes.txt", new StreetSuffixMapper());
public static AssetDescriptor<String> NEUTRAL_SURNAMES = new AssetDescriptor<>("neutral/surnames.txt", new StringMapper());
public static AssetDescriptor<String> MALE_FIRSTNAMES = new AssetDescriptor<>("male/firstnames.txt", new StringMapper());
public static AssetDescriptor<String> FEMALE_FIRSTNAMES = new AssetDescriptor<>("female/firstnames.txt", new StringMapper());
|
public static AssetDescriptor<Prefix> NEUTRAL_PREFIXES = new AssetDescriptor<>("neutral/prefixes.txt", new PrefixMapper());
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/money/ExpiryDateGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
|
package me.xdrop.jrand.generators.money;
@Facade(accessor = "expiryDate")
public class ExpiryDateGenerator extends Generator<String>{
protected boolean longVersion;
protected boolean expired;
protected boolean canExpire;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/NaturalGenerator.java
// @Facade(accessor = "natural")
// public class NaturalGenerator extends Generator<Integer> {
//
// protected int min;
// protected int max;
//
// public NaturalGenerator() {
// this.max = Integer.MAX_VALUE - 1;
// this.min = 0;
// }
//
// /**
// * Set the minimum value (inclusive)
// *
// * @param min The minimum value
// * @return The same generator
// */
// public NaturalGenerator min(int min) {
// this.min = min;
// return this;
// }
//
// /**
// * Set the maximum value to return (inclusive)
// *
// * @param max The maximum value to return (inclusive)
// * @return The same generator
// */
// public NaturalGenerator max(int max) {
// this.max = max;
// return this;
// }
//
// /**
// * Set a min/max range
// *
// * @param min Minimum value to be returned (inclusive)
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int min, int max) {
// min(min);
// max(max);
// return this;
// }
//
// /**
// * Set a range starting from 0
// *
// * @param max Maximum value to be returned (inclusive)
// * @return The same generator
// */
// public NaturalGenerator range(int max) {
// min(0);
// max(max - 1);
// return this;
// }
//
// public NaturalGenerator range(Range<Integer> rangeOption) {
// min(rangeOption.getMin());
// max(rangeOption.getMax());
// return this;
// }
//
// /**
// * Retrieve n uniform samples from population without replacement
// * @param sampleSize Number of samples to retrieve
// * @param population The population size
// * @return A list of integer samples
// */
// public List<Integer> sample(int sampleSize, int population) {
// int t = 0, m =0;
// List<Integer> samples = new ArrayList<>();
//
// while (m < sampleSize) {
// double u = random().randDouble();
// if ((population -t) * u >= sampleSize -m) {
// t++;
// } else {
// samples.add(t);
// t++; m++;
// }
// }
// return samples;
// }
//
// @Override
// public Integer gen() {
// return random().randInt((max - min) + 1) + min;
// }
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/money/ExpiryDateGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.generators.basics.NaturalGenerator;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
package me.xdrop.jrand.generators.money;
@Facade(accessor = "expiryDate")
public class ExpiryDateGenerator extends Generator<String>{
protected boolean longVersion;
protected boolean expired;
protected boolean canExpire;
|
protected NaturalGenerator nat;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/basics/CharacterGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/basics/enums/CHARSET.java
// public enum CHARSET {
//
// CHARS_LOWER(alphaLowerPoolChar),
// CHARS_UPPER(alphaUpperPoolChar),
// NUMBERS(numericPoolChar),
// SYMBOLS(symbolsPoolChar);
//
// char[] charset;
//
// CHARSET(char[] set) {
// this.charset = set;
// }
//
// public char[] getCharset(){
// return this.charset;
// }
//
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.Tuple;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.basics.enums.CHARSET;
import java.nio.charset.Charset;
import java.util.*;
|
package me.xdrop.jrand.generators.basics;
@Facade(accessor = "character")
public class CharacterGenerator extends Generator<Character> {
protected List<Character> pool;
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/basics/enums/CHARSET.java
// public enum CHARSET {
//
// CHARS_LOWER(alphaLowerPoolChar),
// CHARS_UPPER(alphaUpperPoolChar),
// NUMBERS(numericPoolChar),
// SYMBOLS(symbolsPoolChar);
//
// char[] charset;
//
// CHARSET(char[] set) {
// this.charset = set;
// }
//
// public char[] getCharset(){
// return this.charset;
// }
//
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/CharacterGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.Tuple;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.basics.enums.CHARSET;
import java.nio.charset.Charset;
import java.util.*;
package me.xdrop.jrand.generators.basics;
@Facade(accessor = "character")
public class CharacterGenerator extends Generator<Character> {
protected List<Character> pool;
|
protected Set<CHARSET> includedCharsets;
|
xdrop/jRand
|
jrand-core/src/main/java/me/xdrop/jrand/generators/basics/CharacterGenerator.java
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/basics/enums/CHARSET.java
// public enum CHARSET {
//
// CHARS_LOWER(alphaLowerPoolChar),
// CHARS_UPPER(alphaUpperPoolChar),
// NUMBERS(numericPoolChar),
// SYMBOLS(symbolsPoolChar);
//
// char[] charset;
//
// CHARSET(char[] set) {
// this.charset = set;
// }
//
// public char[] getCharset(){
// return this.charset;
// }
//
// }
|
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.Tuple;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.basics.enums.CHARSET;
import java.nio.charset.Charset;
import java.util.*;
|
} else {
return casing(Casing.UPPER);
}
}
private void preparePool() {
pool.clear();
for (CHARSET charset: includedCharsets) {
for (char c : charset.getCharset()){
pool.add(c);
}
}
}
@Override
public Character gen() {
if (pool == null || pool.size() < 1){
throw new RuntimeException("The character pool is empty, please ensure you call .pool()" +
"before continuing");
}
return pool.get(random().randInt(pool.size() - 1));
}
/**
* When specifying a pool you can use this to generate an item from the pool
* along with its index it in the pool
* @return A {@link Tuple} of a character and its index in the pool
*/
|
// Path: jrand-core/src/main/java/me/xdrop/jrand/Generator.java
// public abstract class Generator<T> {
//
// private Rand randGen;
//
// public Generator() {
// this.randGen = new Rand();
// }
//
// public Rand random() {
// return this.randGen;
// }
//
// public abstract T gen();
//
// public String repeat(int times) {
// StringBuilder sb = new StringBuilder();
// while (times-- > 0) {
// sb.append(gen());
// }
// return sb.toString();
// }
//
// public String genString() {
// return gen().toString();
// }
//
// public List<T> genMany(int num) {
// List<T> many = new ArrayList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return many;
// }
//
// public List<T> genManyUnique(int num) {
// List<T> many = new LinkedList<>();
// Set<T> present = new HashSet<>();
//
//
// for (int n = 0; n < num; n++) {
// T gen;
// do {
// gen = gen();
// } while (present.contains(gen));
// many.add(gen);
// present.add(gen);
// }
//
// return many;
// }
//
// public Set<T> genManyAsSet(int num) {
// List<T> many = new LinkedList<>();
// for (int n = 0; n < num; n++) {
// many.add(gen());
// }
// return new HashSet<>(many);
// }
//
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/Tuple.java
// public class Tuple<K,V> {
// K key;
// V val;
//
// public Tuple(K key, V val) {
// this.key = key;
// this.val = val;
// }
//
// public K getKey() {
// return key;
// }
//
// public void setKey(K key) {
// this.key = key;
// }
//
// public V getVal() {
// return val;
// }
//
// public void setVal(V val) {
// this.val = val;
// }
//
// public static <K,V> Tuple<K,V> from(K key, V val) {
// return new Tuple<>(key,val);
// }
// }
//
// Path: jrand-core/src/main/java/me/xdrop/jrand/model/basics/enums/CHARSET.java
// public enum CHARSET {
//
// CHARS_LOWER(alphaLowerPoolChar),
// CHARS_UPPER(alphaUpperPoolChar),
// NUMBERS(numericPoolChar),
// SYMBOLS(symbolsPoolChar);
//
// char[] charset;
//
// CHARSET(char[] set) {
// this.charset = set;
// }
//
// public char[] getCharset(){
// return this.charset;
// }
//
// }
// Path: jrand-core/src/main/java/me/xdrop/jrand/generators/basics/CharacterGenerator.java
import me.xdrop.jrand.Generator;
import me.xdrop.jrand.Tuple;
import me.xdrop.jrand.annotation.Facade;
import me.xdrop.jrand.model.basics.enums.CHARSET;
import java.nio.charset.Charset;
import java.util.*;
} else {
return casing(Casing.UPPER);
}
}
private void preparePool() {
pool.clear();
for (CHARSET charset: includedCharsets) {
for (char c : charset.getCharset()){
pool.add(c);
}
}
}
@Override
public Character gen() {
if (pool == null || pool.size() < 1){
throw new RuntimeException("The character pool is empty, please ensure you call .pool()" +
"before continuing");
}
return pool.get(random().randInt(pool.size() - 1));
}
/**
* When specifying a pool you can use this to generate an item from the pool
* along with its index it in the pool
* @return A {@link Tuple} of a character and its index in the pool
*/
|
public Tuple<Character, Integer> genWithIndex() {
|
OpenNMS/wsman
|
openwsman/src/test/java/org/opennms/core/wsman/openwsman/OpenWSManClientDracIT.java
|
// Path: itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientDracIT.java
// public abstract class AbstractWSManClientDracIT {
// private final static Logger LOG = LoggerFactory.getLogger(AbstractWSManClientDracIT.class);
//
// private WSManClient client;
//
// public abstract WSManClientFactory getFactory();
//
// @BeforeClass
// public static void setupClass() {
// System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
// }
//
// @Before
// public void setUp() throws IOException {
// WSManEndpoint endpoint = TestUtils.getEndpointFromLocalConfiguration();
// LOG.info("Using endpoint: {}", endpoint);
// client = getFactory().getClient(endpoint);
// }
//
// @Test
// public void canGetInputVoltage() {
// List<Node> powerSupplies = Lists.newLinkedList();
// client.enumerateAndPullUsingFilter(
// WSManConstants.CIM_ALL_AVAILABLE_CLASSES,
// WSManConstants.XML_NS_WQL_DIALECT,
// "select DeviceDescription,PrimaryStatus,TotalOutputPower,InputVoltage,Range1MaxInputPower,FirmwareVersion,RedundancyStatus from DCIM_PowerSupplyView where DetailedState != 'Absent' and PrimaryStatus != 0",
// powerSupplies,
// true);
// assertEquals(1, powerSupplies.size());
//
// XMLTag tag = XMLDoc.from(powerSupplies.get(0), true);
// int inputVoltage = Integer.valueOf(tag.gotoChild("n1:InputVoltage").getText());
// assertEquals(120, inputVoltage);
// }
//
// @Test
// public void canGetSystemPrimaryStatus() {
// Map<String, String> selectors = Maps.newHashMap();
// selectors.put("CreationClassName", "DCIM_ComputerSystem");
// selectors.put("Name", "srv:system");
// Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
// assertNotNull(node);
//
// assertEquals("DCIM_ComputerSystem", node.getLocalName());
// assertEquals("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", node.getNamespaceURI());
//
// XMLTag tag = XMLDoc.from(node, true);
// System.err.println(tag.getCurrentTagName());
// System.err.println(tag);
// int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
// assertEquals(1, primaryStatus);
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/WSManClientFactory.java
// public interface WSManClientFactory {
//
// /**
// * Constructs a new {@link WSManClient} for the given endpoint.
// *
// * @param endpoint target
// * @return a new client instance
// */
// public WSManClient getClient(WSManEndpoint endpoint);
// }
|
import org.junit.Ignore;
import org.opennms.core.wsman.AbstractWSManClientDracIT;
import org.opennms.core.wsman.WSManClientFactory;
|
/*
* Copyright 2015, The OpenNMS Group
*
* 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.
*/
package org.opennms.core.wsman.openwsman;
@Ignore("Expects an iDrac to be configured in ~/wsman.properties")
public class OpenWSManClientDracIT extends AbstractWSManClientDracIT {
@Override
|
// Path: itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientDracIT.java
// public abstract class AbstractWSManClientDracIT {
// private final static Logger LOG = LoggerFactory.getLogger(AbstractWSManClientDracIT.class);
//
// private WSManClient client;
//
// public abstract WSManClientFactory getFactory();
//
// @BeforeClass
// public static void setupClass() {
// System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
// }
//
// @Before
// public void setUp() throws IOException {
// WSManEndpoint endpoint = TestUtils.getEndpointFromLocalConfiguration();
// LOG.info("Using endpoint: {}", endpoint);
// client = getFactory().getClient(endpoint);
// }
//
// @Test
// public void canGetInputVoltage() {
// List<Node> powerSupplies = Lists.newLinkedList();
// client.enumerateAndPullUsingFilter(
// WSManConstants.CIM_ALL_AVAILABLE_CLASSES,
// WSManConstants.XML_NS_WQL_DIALECT,
// "select DeviceDescription,PrimaryStatus,TotalOutputPower,InputVoltage,Range1MaxInputPower,FirmwareVersion,RedundancyStatus from DCIM_PowerSupplyView where DetailedState != 'Absent' and PrimaryStatus != 0",
// powerSupplies,
// true);
// assertEquals(1, powerSupplies.size());
//
// XMLTag tag = XMLDoc.from(powerSupplies.get(0), true);
// int inputVoltage = Integer.valueOf(tag.gotoChild("n1:InputVoltage").getText());
// assertEquals(120, inputVoltage);
// }
//
// @Test
// public void canGetSystemPrimaryStatus() {
// Map<String, String> selectors = Maps.newHashMap();
// selectors.put("CreationClassName", "DCIM_ComputerSystem");
// selectors.put("Name", "srv:system");
// Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
// assertNotNull(node);
//
// assertEquals("DCIM_ComputerSystem", node.getLocalName());
// assertEquals("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", node.getNamespaceURI());
//
// XMLTag tag = XMLDoc.from(node, true);
// System.err.println(tag.getCurrentTagName());
// System.err.println(tag);
// int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
// assertEquals(1, primaryStatus);
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/WSManClientFactory.java
// public interface WSManClientFactory {
//
// /**
// * Constructs a new {@link WSManClient} for the given endpoint.
// *
// * @param endpoint target
// * @return a new client instance
// */
// public WSManClient getClient(WSManEndpoint endpoint);
// }
// Path: openwsman/src/test/java/org/opennms/core/wsman/openwsman/OpenWSManClientDracIT.java
import org.junit.Ignore;
import org.opennms.core.wsman.AbstractWSManClientDracIT;
import org.opennms.core.wsman.WSManClientFactory;
/*
* Copyright 2015, The OpenNMS Group
*
* 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.
*/
package org.opennms.core.wsman.openwsman;
@Ignore("Expects an iDrac to be configured in ~/wsman.properties")
public class OpenWSManClientDracIT extends AbstractWSManClientDracIT {
@Override
|
public WSManClientFactory getFactory() {
|
OpenNMS/wsman
|
cxf/src/test/java/org/opennms/core/wsman/cxf/CXFWSManClientDracIT.java
|
// Path: itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientDracIT.java
// public abstract class AbstractWSManClientDracIT {
// private final static Logger LOG = LoggerFactory.getLogger(AbstractWSManClientDracIT.class);
//
// private WSManClient client;
//
// public abstract WSManClientFactory getFactory();
//
// @BeforeClass
// public static void setupClass() {
// System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
// }
//
// @Before
// public void setUp() throws IOException {
// WSManEndpoint endpoint = TestUtils.getEndpointFromLocalConfiguration();
// LOG.info("Using endpoint: {}", endpoint);
// client = getFactory().getClient(endpoint);
// }
//
// @Test
// public void canGetInputVoltage() {
// List<Node> powerSupplies = Lists.newLinkedList();
// client.enumerateAndPullUsingFilter(
// WSManConstants.CIM_ALL_AVAILABLE_CLASSES,
// WSManConstants.XML_NS_WQL_DIALECT,
// "select DeviceDescription,PrimaryStatus,TotalOutputPower,InputVoltage,Range1MaxInputPower,FirmwareVersion,RedundancyStatus from DCIM_PowerSupplyView where DetailedState != 'Absent' and PrimaryStatus != 0",
// powerSupplies,
// true);
// assertEquals(1, powerSupplies.size());
//
// XMLTag tag = XMLDoc.from(powerSupplies.get(0), true);
// int inputVoltage = Integer.valueOf(tag.gotoChild("n1:InputVoltage").getText());
// assertEquals(120, inputVoltage);
// }
//
// @Test
// public void canGetSystemPrimaryStatus() {
// Map<String, String> selectors = Maps.newHashMap();
// selectors.put("CreationClassName", "DCIM_ComputerSystem");
// selectors.put("Name", "srv:system");
// Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
// assertNotNull(node);
//
// assertEquals("DCIM_ComputerSystem", node.getLocalName());
// assertEquals("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", node.getNamespaceURI());
//
// XMLTag tag = XMLDoc.from(node, true);
// System.err.println(tag.getCurrentTagName());
// System.err.println(tag);
// int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
// assertEquals(1, primaryStatus);
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/WSManClientFactory.java
// public interface WSManClientFactory {
//
// /**
// * Constructs a new {@link WSManClient} for the given endpoint.
// *
// * @param endpoint target
// * @return a new client instance
// */
// public WSManClient getClient(WSManEndpoint endpoint);
// }
|
import org.junit.Ignore;
import org.opennms.core.wsman.AbstractWSManClientDracIT;
import org.opennms.core.wsman.WSManClientFactory;
|
/*
* Copyright 2015, The OpenNMS Group
*
* 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.
*/
package org.opennms.core.wsman.cxf;
@Ignore("Expects an iDrac to be configured in ~/wsman.properties")
public class CXFWSManClientDracIT extends AbstractWSManClientDracIT {
@Override
|
// Path: itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientDracIT.java
// public abstract class AbstractWSManClientDracIT {
// private final static Logger LOG = LoggerFactory.getLogger(AbstractWSManClientDracIT.class);
//
// private WSManClient client;
//
// public abstract WSManClientFactory getFactory();
//
// @BeforeClass
// public static void setupClass() {
// System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
// }
//
// @Before
// public void setUp() throws IOException {
// WSManEndpoint endpoint = TestUtils.getEndpointFromLocalConfiguration();
// LOG.info("Using endpoint: {}", endpoint);
// client = getFactory().getClient(endpoint);
// }
//
// @Test
// public void canGetInputVoltage() {
// List<Node> powerSupplies = Lists.newLinkedList();
// client.enumerateAndPullUsingFilter(
// WSManConstants.CIM_ALL_AVAILABLE_CLASSES,
// WSManConstants.XML_NS_WQL_DIALECT,
// "select DeviceDescription,PrimaryStatus,TotalOutputPower,InputVoltage,Range1MaxInputPower,FirmwareVersion,RedundancyStatus from DCIM_PowerSupplyView where DetailedState != 'Absent' and PrimaryStatus != 0",
// powerSupplies,
// true);
// assertEquals(1, powerSupplies.size());
//
// XMLTag tag = XMLDoc.from(powerSupplies.get(0), true);
// int inputVoltage = Integer.valueOf(tag.gotoChild("n1:InputVoltage").getText());
// assertEquals(120, inputVoltage);
// }
//
// @Test
// public void canGetSystemPrimaryStatus() {
// Map<String, String> selectors = Maps.newHashMap();
// selectors.put("CreationClassName", "DCIM_ComputerSystem");
// selectors.put("Name", "srv:system");
// Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
// assertNotNull(node);
//
// assertEquals("DCIM_ComputerSystem", node.getLocalName());
// assertEquals("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", node.getNamespaceURI());
//
// XMLTag tag = XMLDoc.from(node, true);
// System.err.println(tag.getCurrentTagName());
// System.err.println(tag);
// int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
// assertEquals(1, primaryStatus);
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/WSManClientFactory.java
// public interface WSManClientFactory {
//
// /**
// * Constructs a new {@link WSManClient} for the given endpoint.
// *
// * @param endpoint target
// * @return a new client instance
// */
// public WSManClient getClient(WSManEndpoint endpoint);
// }
// Path: cxf/src/test/java/org/opennms/core/wsman/cxf/CXFWSManClientDracIT.java
import org.junit.Ignore;
import org.opennms.core.wsman.AbstractWSManClientDracIT;
import org.opennms.core.wsman.WSManClientFactory;
/*
* Copyright 2015, The OpenNMS Group
*
* 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.
*/
package org.opennms.core.wsman.cxf;
@Ignore("Expects an iDrac to be configured in ~/wsman.properties")
public class CXFWSManClientDracIT extends AbstractWSManClientDracIT {
@Override
|
public WSManClientFactory getFactory() {
|
OpenNMS/wsman
|
itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientIT.java
|
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/InvalidResourceURI.java
// public class InvalidResourceURI extends SOAPFault {
// private static final long serialVersionUID = 2596542137169661371L;
//
// public InvalidResourceURI(Throwable cause) {
// super(cause);
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/UnauthorizedException.java
// public class UnauthorizedException extends HTTPException {
// private static final long serialVersionUID = 8958931434340638066L;
//
// public UnauthorizedException(Throwable cause) {
// super(cause);
// }
// }
|
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.findAll;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.opennms.core.wsman.exceptions.InvalidResourceURI;
import org.opennms.core.wsman.exceptions.UnauthorizedException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.stubbing.Scenario;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mycila.xmltool.XMLDoc;
import com.mycila.xmltool.XMLTag;
|
if (child.getLocalName() == null || child.getTextContent() == null) {
continue;
}
map.put(child.getLocalName(), child.getTextContent());
}
return map;
}
@Test
public void canGet() throws FileNotFoundException, IOException {
stubFor(post(urlEqualTo("/wsman"))
.willReturn(aResponse()
.withHeader("Content-Type", "Content-Type: application/soap+xml; charset=utf-8")
.withBodyFile("get-response.xml")));
Map<String, String> selectors = Maps.newHashMap();
selectors.put("CreationClassName", "DCIM_ComputerSystem");
selectors.put("Name", "srv:system");
Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
dumpRequestsToStdout();
assertNotNull(node);
XMLTag tag = XMLDoc.from(node, true);
int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
assertEquals(1, primaryStatus);
}
|
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/InvalidResourceURI.java
// public class InvalidResourceURI extends SOAPFault {
// private static final long serialVersionUID = 2596542137169661371L;
//
// public InvalidResourceURI(Throwable cause) {
// super(cause);
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/UnauthorizedException.java
// public class UnauthorizedException extends HTTPException {
// private static final long serialVersionUID = 8958931434340638066L;
//
// public UnauthorizedException(Throwable cause) {
// super(cause);
// }
// }
// Path: itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientIT.java
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.findAll;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.opennms.core.wsman.exceptions.InvalidResourceURI;
import org.opennms.core.wsman.exceptions.UnauthorizedException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.stubbing.Scenario;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mycila.xmltool.XMLDoc;
import com.mycila.xmltool.XMLTag;
if (child.getLocalName() == null || child.getTextContent() == null) {
continue;
}
map.put(child.getLocalName(), child.getTextContent());
}
return map;
}
@Test
public void canGet() throws FileNotFoundException, IOException {
stubFor(post(urlEqualTo("/wsman"))
.willReturn(aResponse()
.withHeader("Content-Type", "Content-Type: application/soap+xml; charset=utf-8")
.withBodyFile("get-response.xml")));
Map<String, String> selectors = Maps.newHashMap();
selectors.put("CreationClassName", "DCIM_ComputerSystem");
selectors.put("Name", "srv:system");
Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
dumpRequestsToStdout();
assertNotNull(node);
XMLTag tag = XMLDoc.from(node, true);
int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
assertEquals(1, primaryStatus);
}
|
@Test(expected=UnauthorizedException.class)
|
OpenNMS/wsman
|
itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientIT.java
|
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/InvalidResourceURI.java
// public class InvalidResourceURI extends SOAPFault {
// private static final long serialVersionUID = 2596542137169661371L;
//
// public InvalidResourceURI(Throwable cause) {
// super(cause);
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/UnauthorizedException.java
// public class UnauthorizedException extends HTTPException {
// private static final long serialVersionUID = 8958931434340638066L;
//
// public UnauthorizedException(Throwable cause) {
// super(cause);
// }
// }
|
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.findAll;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.opennms.core.wsman.exceptions.InvalidResourceURI;
import org.opennms.core.wsman.exceptions.UnauthorizedException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.stubbing.Scenario;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mycila.xmltool.XMLDoc;
import com.mycila.xmltool.XMLTag;
|
stubFor(post(urlEqualTo("/wsman"))
.willReturn(aResponse()
.withHeader("Content-Type", "Content-Type: application/soap+xml; charset=utf-8")
.withBodyFile("get-response.xml")));
Map<String, String> selectors = Maps.newHashMap();
selectors.put("CreationClassName", "DCIM_ComputerSystem");
selectors.put("Name", "srv:system");
Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
dumpRequestsToStdout();
assertNotNull(node);
XMLTag tag = XMLDoc.from(node, true);
int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
assertEquals(1, primaryStatus);
}
@Test(expected=UnauthorizedException.class)
public void throwsUnauthorizedExceptionOn401() {
stubFor(post(urlEqualTo("/wsman"))
.willReturn(
aResponse()
.withStatus(401)
.withHeader("Content-Type", "text/plain")
.withBody("Not allowed!")));
client.enumerate("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem");
}
|
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/InvalidResourceURI.java
// public class InvalidResourceURI extends SOAPFault {
// private static final long serialVersionUID = 2596542137169661371L;
//
// public InvalidResourceURI(Throwable cause) {
// super(cause);
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/UnauthorizedException.java
// public class UnauthorizedException extends HTTPException {
// private static final long serialVersionUID = 8958931434340638066L;
//
// public UnauthorizedException(Throwable cause) {
// super(cause);
// }
// }
// Path: itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientIT.java
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.findAll;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.opennms.core.wsman.exceptions.InvalidResourceURI;
import org.opennms.core.wsman.exceptions.UnauthorizedException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.stubbing.Scenario;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mycila.xmltool.XMLDoc;
import com.mycila.xmltool.XMLTag;
stubFor(post(urlEqualTo("/wsman"))
.willReturn(aResponse()
.withHeader("Content-Type", "Content-Type: application/soap+xml; charset=utf-8")
.withBodyFile("get-response.xml")));
Map<String, String> selectors = Maps.newHashMap();
selectors.put("CreationClassName", "DCIM_ComputerSystem");
selectors.put("Name", "srv:system");
Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
dumpRequestsToStdout();
assertNotNull(node);
XMLTag tag = XMLDoc.from(node, true);
int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
assertEquals(1, primaryStatus);
}
@Test(expected=UnauthorizedException.class)
public void throwsUnauthorizedExceptionOn401() {
stubFor(post(urlEqualTo("/wsman"))
.willReturn(
aResponse()
.withStatus(401)
.withHeader("Content-Type", "text/plain")
.withBody("Not allowed!")));
client.enumerate("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem");
}
|
@Test(expected=InvalidResourceURI.class)
|
OpenNMS/wsman
|
cxf/src/main/java/org/opennms/core/wsman/cxf/TypeUtils.java
|
// Path: api/src/main/java/org/opennms/core/wsman/WSManConstants.java
// public class WSManConstants {
//
// public static final String XML_NS_DMTF_WSMAN_V1 = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd";
//
// public static final String XML_NS_DMTF_WSMAN_IDENTITY_V1 = "http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd";
//
// public static final String XML_NS_WS_2004_08_ADDRESSING = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
//
// public static final String XML_NS_WS_2004_09_ENUMERATION = "http://schemas.xmlsoap.org/ws/2004/09/enumeration";
//
// public static final String XML_NS_WS_2004_09_TRANSFER = "http://schemas.xmlsoap.org/ws/2004/09/transfer";
//
// public static final String XML_NS_WQL_DIALECT = "http://schemas.microsoft.com/wbem/wsman/1/WQL";
//
// public static final String CIM_ALL_AVAILABLE_CLASSES = "http://schemas.dmtf.org/wbem/wscim/1/*";
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/WSManException.java
// public class WSManException extends RuntimeException {
// private static final long serialVersionUID = -2894934806760355903L;
//
// public WSManException(String message) {
// super(message);
// }
//
// public WSManException(Throwable cause) {
// super(cause);
// }
//
// public WSManException(String message, Throwable cause) {
// super(message, cause);
// }
// }
|
import java.net.URI;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMResult;
import org.opennms.core.wsman.WSManConstants;
import org.opennms.core.wsman.exceptions.WSManException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xmlsoap.schemas.ws._2004._09.enumeration.EnumerateResponse;
import org.xmlsoap.schemas.ws._2004._09.enumeration.EnumerationContextType;
import org.xmlsoap.schemas.ws._2004._09.enumeration.PullResponse;
import org.xmlsoap.schemas.ws._2004._09.transfer.TransferElement;
import schemas.dmtf.org.wbem.wsman.v1.AnyListType;
import schemas.dmtf.org.wbem.wsman.v1.MixedDataType;
|
package org.opennms.core.wsman.cxf;
/**
* Utility functions for manipulating WS-Man specific types.
*
* These functions should be very strict, and a {@link WSManException}
* should be thrown if they encounter anything unexpected.
*
* @author jwhite
*/
public class TypeUtils {
private final static QName WSEN_Items_QNAME = new QName(WSManConstants.XML_NS_WS_2004_09_ENUMERATION, "Items");
private final static QName WSEN_EndOfSequence_QNAME = new QName(WSManConstants.XML_NS_WS_2004_09_ENUMERATION, "EndOfSequence");
private final static QName WSMAN_Items_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "Items");
private final static QName WSMAN_EndOfSequence_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "EndOfSequence");
private final static QName WSMAN_XmlFragment_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "XmlFragment");
private final static DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
protected static String getContextIdFrom(EnumerateResponse response) {
// A valid response must always include the EnumerationContext element
return getContextIdFrom(response.getEnumerationContext());
}
protected static String getContextIdFrom(PullResponse response) {
if (response.getEnumerationContext() == null) {
// The PullResponse will not contain an EnumerationContext if EndOfSequence is set
return null;
}
return getContextIdFrom(response.getEnumerationContext());
}
protected static String getContextIdFrom(EnumerationContextType context) {
// The content of the EnumerationContext should contain a single string, the context id
if (context == null || context.getContent() == null) {
|
// Path: api/src/main/java/org/opennms/core/wsman/WSManConstants.java
// public class WSManConstants {
//
// public static final String XML_NS_DMTF_WSMAN_V1 = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd";
//
// public static final String XML_NS_DMTF_WSMAN_IDENTITY_V1 = "http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd";
//
// public static final String XML_NS_WS_2004_08_ADDRESSING = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
//
// public static final String XML_NS_WS_2004_09_ENUMERATION = "http://schemas.xmlsoap.org/ws/2004/09/enumeration";
//
// public static final String XML_NS_WS_2004_09_TRANSFER = "http://schemas.xmlsoap.org/ws/2004/09/transfer";
//
// public static final String XML_NS_WQL_DIALECT = "http://schemas.microsoft.com/wbem/wsman/1/WQL";
//
// public static final String CIM_ALL_AVAILABLE_CLASSES = "http://schemas.dmtf.org/wbem/wscim/1/*";
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/exceptions/WSManException.java
// public class WSManException extends RuntimeException {
// private static final long serialVersionUID = -2894934806760355903L;
//
// public WSManException(String message) {
// super(message);
// }
//
// public WSManException(Throwable cause) {
// super(cause);
// }
//
// public WSManException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: cxf/src/main/java/org/opennms/core/wsman/cxf/TypeUtils.java
import java.net.URI;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMResult;
import org.opennms.core.wsman.WSManConstants;
import org.opennms.core.wsman.exceptions.WSManException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xmlsoap.schemas.ws._2004._09.enumeration.EnumerateResponse;
import org.xmlsoap.schemas.ws._2004._09.enumeration.EnumerationContextType;
import org.xmlsoap.schemas.ws._2004._09.enumeration.PullResponse;
import org.xmlsoap.schemas.ws._2004._09.transfer.TransferElement;
import schemas.dmtf.org.wbem.wsman.v1.AnyListType;
import schemas.dmtf.org.wbem.wsman.v1.MixedDataType;
package org.opennms.core.wsman.cxf;
/**
* Utility functions for manipulating WS-Man specific types.
*
* These functions should be very strict, and a {@link WSManException}
* should be thrown if they encounter anything unexpected.
*
* @author jwhite
*/
public class TypeUtils {
private final static QName WSEN_Items_QNAME = new QName(WSManConstants.XML_NS_WS_2004_09_ENUMERATION, "Items");
private final static QName WSEN_EndOfSequence_QNAME = new QName(WSManConstants.XML_NS_WS_2004_09_ENUMERATION, "EndOfSequence");
private final static QName WSMAN_Items_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "Items");
private final static QName WSMAN_EndOfSequence_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "EndOfSequence");
private final static QName WSMAN_XmlFragment_QNAME = new QName(WSManConstants.XML_NS_DMTF_WSMAN_V1, "XmlFragment");
private final static DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
protected static String getContextIdFrom(EnumerateResponse response) {
// A valid response must always include the EnumerationContext element
return getContextIdFrom(response.getEnumerationContext());
}
protected static String getContextIdFrom(PullResponse response) {
if (response.getEnumerationContext() == null) {
// The PullResponse will not contain an EnumerationContext if EndOfSequence is set
return null;
}
return getContextIdFrom(response.getEnumerationContext());
}
protected static String getContextIdFrom(EnumerationContextType context) {
// The content of the EnumerationContext should contain a single string, the context id
if (context == null || context.getContent() == null) {
|
throw new WSManException(String.format("EnumerationContext %s has no content.", context));
|
OpenNMS/wsman
|
cxf/src/test/java/org/opennms/core/wsman/cxf/CXFWSManClientWinServer2008IT.java
|
// Path: itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientWinServer2008IT.java
// public abstract class AbstractWSManClientWinServer2008IT {
// private final static Logger LOG = LoggerFactory.getLogger(AbstractWSManClientWinServer2008IT.class);
//
// private WSManClient client;
//
// public abstract WSManClientFactory getFactory();
//
// @BeforeClass
// public static void setupClass() {
// System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
// }
//
// @Before
// public void setUp() throws IOException {
// WSManEndpoint endpoint = TestUtils.getEndpointFromLocalConfiguration();
// LOG.info("Using endpoint: {}", endpoint);
// client = getFactory().getClient(endpoint);
// }
//
// @Test
// public void canEnumerateWin32Services() {
// List<Node> services = Lists.newArrayList();
// client.enumerateAndPull("http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service", services, true);
// assertTrue(services.size() + " services", services.size() > 10);
// }
//
// @Test
// public void canIdentifyOS() {
// Identity identifyResponse = client.identify();
// assertEquals("Microsoft Corporation", identifyResponse.getProductVendor());
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/WSManClientFactory.java
// public interface WSManClientFactory {
//
// /**
// * Constructs a new {@link WSManClient} for the given endpoint.
// *
// * @param endpoint target
// * @return a new client instance
// */
// public WSManClient getClient(WSManEndpoint endpoint);
// }
|
import org.junit.Ignore;
import org.opennms.core.wsman.AbstractWSManClientWinServer2008IT;
import org.opennms.core.wsman.WSManClientFactory;
|
package org.opennms.core.wsman.cxf;
@Ignore("Expects an Windows 2k8 Service to be configured in ~/wsman.properties")
public class CXFWSManClientWinServer2008IT extends AbstractWSManClientWinServer2008IT {
@Override
|
// Path: itests/src/main/java/org/opennms/core/wsman/AbstractWSManClientWinServer2008IT.java
// public abstract class AbstractWSManClientWinServer2008IT {
// private final static Logger LOG = LoggerFactory.getLogger(AbstractWSManClientWinServer2008IT.class);
//
// private WSManClient client;
//
// public abstract WSManClientFactory getFactory();
//
// @BeforeClass
// public static void setupClass() {
// System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
// }
//
// @Before
// public void setUp() throws IOException {
// WSManEndpoint endpoint = TestUtils.getEndpointFromLocalConfiguration();
// LOG.info("Using endpoint: {}", endpoint);
// client = getFactory().getClient(endpoint);
// }
//
// @Test
// public void canEnumerateWin32Services() {
// List<Node> services = Lists.newArrayList();
// client.enumerateAndPull("http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service", services, true);
// assertTrue(services.size() + " services", services.size() > 10);
// }
//
// @Test
// public void canIdentifyOS() {
// Identity identifyResponse = client.identify();
// assertEquals("Microsoft Corporation", identifyResponse.getProductVendor());
// }
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/WSManClientFactory.java
// public interface WSManClientFactory {
//
// /**
// * Constructs a new {@link WSManClient} for the given endpoint.
// *
// * @param endpoint target
// * @return a new client instance
// */
// public WSManClient getClient(WSManEndpoint endpoint);
// }
// Path: cxf/src/test/java/org/opennms/core/wsman/cxf/CXFWSManClientWinServer2008IT.java
import org.junit.Ignore;
import org.opennms.core.wsman.AbstractWSManClientWinServer2008IT;
import org.opennms.core.wsman.WSManClientFactory;
package org.opennms.core.wsman.cxf;
@Ignore("Expects an Windows 2k8 Service to be configured in ~/wsman.properties")
public class CXFWSManClientWinServer2008IT extends AbstractWSManClientWinServer2008IT {
@Override
|
public WSManClientFactory getFactory() {
|
OpenNMS/wsman
|
cxf/src/main/java/org/opennms/core/wsman/cxf/CXFWSManClientFactory.java
|
// Path: api/src/main/java/org/opennms/core/wsman/WSManClientFactory.java
// public interface WSManClientFactory {
//
// /**
// * Constructs a new {@link WSManClient} for the given endpoint.
// *
// * @param endpoint target
// * @return a new client instance
// */
// public WSManClient getClient(WSManEndpoint endpoint);
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/WSManEndpoint.java
// public class WSManEndpoint {
//
// private final URL url;
// private final String username;
// private final String password;
// private final boolean gssAuth;
// private final boolean strictSSL;
// private final WSManVersion serverVersion;
// private final Integer maxElements;
// private final Integer maxEnvelopeSize;
// private final Integer connectionTimeout;
// private final Integer receiveTimeout;
//
// private WSManEndpoint(Builder builder) {
// url = builder.url;
// username = builder.username;
// password = builder.password;
// gssAuth = builder.gssAuth;
// strictSSL = builder.strictSSL;
// serverVersion = builder.serverVersion;
// maxElements = builder.maxElements;
// maxEnvelopeSize = builder.maxEnvelopeSize;
// connectionTimeout = builder.connectionTimeout;
// receiveTimeout = builder.receiveTimeout;
// }
//
// public static class Builder {
// private final URL url;
// private boolean strictSSL = true;
// private String username;
// private String password;
// private boolean gssAuth = false;
// private WSManVersion serverVersion = WSManVersion.WSMAN_1_2;
// private Integer maxElements;
// private Integer maxEnvelopeSize;
// private Integer connectionTimeout;
// private Integer receiveTimeout;
//
// public Builder(String url) throws MalformedURLException {
// this(new URL(Objects.requireNonNull(url, "url cannot be null")));
// }
//
// public Builder(URL url) {
// this.url = Objects.requireNonNull(url, "url cannot be null");
// }
//
// public Builder withBasicAuth(String username, String password) {
// this.username = Objects.requireNonNull(username, "username cannot be null");
// this.password = Objects.requireNonNull(password, "password cannot be null");
// return this;
// }
//
// public Builder withGSSAuth() {
// gssAuth = true;
// return this;
// }
//
// public Builder withStrictSSL(boolean strictSSL) {
// this.strictSSL = strictSSL;
// return this;
// }
//
// public Builder withServerVersion(WSManVersion version) {
// this.serverVersion = Objects.requireNonNull(version, "version cannot be null");
// return this;
// }
//
// public Builder withMaxElements(Integer maxElements) {
// if (maxElements == null || maxElements < 1) {
// throw new IllegalArgumentException("maxElements must be strictly positive");
// }
// this.maxElements = maxElements;
// return this;
// }
//
// public Builder withMaxEnvelopeSize(Integer maxEnvelopeSize) {
// if (maxEnvelopeSize == null || maxEnvelopeSize < 1) {
// throw new IllegalArgumentException("maxEnvelopeSize must be strictly positive");
// }
// this.maxEnvelopeSize = maxEnvelopeSize;
// return this;
// }
//
// public Builder withConnectionTimeout(Integer connectionTimeout) {
// if (connectionTimeout == null || connectionTimeout < 0) {
// throw new IllegalArgumentException("connectionTimeout must be non-negative");
// }
// this.connectionTimeout = connectionTimeout;
// return this;
// }
//
// public Builder withReceiveTimeout(Integer receiveTimeout) {
// if (receiveTimeout == null || receiveTimeout < 0) {
// throw new IllegalArgumentException("receiveTimeout must be non-negative");
// }
// this.receiveTimeout = receiveTimeout;
// return this;
// }
//
// public WSManEndpoint build() {
// return new WSManEndpoint(this);
// }
// }
//
// public URL getUrl() {
// return url;
// }
//
// public boolean isBasicAuth() {
// return !isGSSAuth() && username != null;
// }
//
// public String getUsername() {
// return username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public boolean isGSSAuth() {
// return gssAuth;
// }
//
// public boolean isStrictSSL() {
// return strictSSL;
// }
//
// public WSManVersion getServerVersion() {
// return serverVersion;
// }
//
// public Integer getMaxElements() {
// return maxElements;
// }
//
// public Integer getMaxEnvelopeSize() {
// return maxEnvelopeSize;
// }
//
// public Integer getConnectionTimeout() {
// return connectionTimeout;
// }
//
// public Integer getReceiveTimeout() {
// return receiveTimeout;
// }
//
// public String toString() {
// return String.format("WSManEndpoint[url='%s', isGSSAuth='%s', isBasicAuth='%s', isStrictSSL='%s', "
// + "serverVersion='%s', maxElements='%s', maxEnvelopeSize='%s'"
// + "connectionTimeout='%s', receiveTimeout='%s']",
// url, isGSSAuth(), isBasicAuth(), isStrictSSL(), serverVersion,
// maxElements, maxEnvelopeSize, connectionTimeout, receiveTimeout);
// }
// }
|
import org.opennms.core.wsman.WSManClientFactory;
import org.opennms.core.wsman.WSManEndpoint;
|
/*
* Copyright 2015, The OpenNMS Group
*
* 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.
*/
package org.opennms.core.wsman.cxf;
/**
* Used to instantiate a new {@link CXFWSManClient} from a
* given {@link WSManEndpoint}.
*
* @author jwhite
*/
public class CXFWSManClientFactory implements WSManClientFactory {
@Override
|
// Path: api/src/main/java/org/opennms/core/wsman/WSManClientFactory.java
// public interface WSManClientFactory {
//
// /**
// * Constructs a new {@link WSManClient} for the given endpoint.
// *
// * @param endpoint target
// * @return a new client instance
// */
// public WSManClient getClient(WSManEndpoint endpoint);
// }
//
// Path: api/src/main/java/org/opennms/core/wsman/WSManEndpoint.java
// public class WSManEndpoint {
//
// private final URL url;
// private final String username;
// private final String password;
// private final boolean gssAuth;
// private final boolean strictSSL;
// private final WSManVersion serverVersion;
// private final Integer maxElements;
// private final Integer maxEnvelopeSize;
// private final Integer connectionTimeout;
// private final Integer receiveTimeout;
//
// private WSManEndpoint(Builder builder) {
// url = builder.url;
// username = builder.username;
// password = builder.password;
// gssAuth = builder.gssAuth;
// strictSSL = builder.strictSSL;
// serverVersion = builder.serverVersion;
// maxElements = builder.maxElements;
// maxEnvelopeSize = builder.maxEnvelopeSize;
// connectionTimeout = builder.connectionTimeout;
// receiveTimeout = builder.receiveTimeout;
// }
//
// public static class Builder {
// private final URL url;
// private boolean strictSSL = true;
// private String username;
// private String password;
// private boolean gssAuth = false;
// private WSManVersion serverVersion = WSManVersion.WSMAN_1_2;
// private Integer maxElements;
// private Integer maxEnvelopeSize;
// private Integer connectionTimeout;
// private Integer receiveTimeout;
//
// public Builder(String url) throws MalformedURLException {
// this(new URL(Objects.requireNonNull(url, "url cannot be null")));
// }
//
// public Builder(URL url) {
// this.url = Objects.requireNonNull(url, "url cannot be null");
// }
//
// public Builder withBasicAuth(String username, String password) {
// this.username = Objects.requireNonNull(username, "username cannot be null");
// this.password = Objects.requireNonNull(password, "password cannot be null");
// return this;
// }
//
// public Builder withGSSAuth() {
// gssAuth = true;
// return this;
// }
//
// public Builder withStrictSSL(boolean strictSSL) {
// this.strictSSL = strictSSL;
// return this;
// }
//
// public Builder withServerVersion(WSManVersion version) {
// this.serverVersion = Objects.requireNonNull(version, "version cannot be null");
// return this;
// }
//
// public Builder withMaxElements(Integer maxElements) {
// if (maxElements == null || maxElements < 1) {
// throw new IllegalArgumentException("maxElements must be strictly positive");
// }
// this.maxElements = maxElements;
// return this;
// }
//
// public Builder withMaxEnvelopeSize(Integer maxEnvelopeSize) {
// if (maxEnvelopeSize == null || maxEnvelopeSize < 1) {
// throw new IllegalArgumentException("maxEnvelopeSize must be strictly positive");
// }
// this.maxEnvelopeSize = maxEnvelopeSize;
// return this;
// }
//
// public Builder withConnectionTimeout(Integer connectionTimeout) {
// if (connectionTimeout == null || connectionTimeout < 0) {
// throw new IllegalArgumentException("connectionTimeout must be non-negative");
// }
// this.connectionTimeout = connectionTimeout;
// return this;
// }
//
// public Builder withReceiveTimeout(Integer receiveTimeout) {
// if (receiveTimeout == null || receiveTimeout < 0) {
// throw new IllegalArgumentException("receiveTimeout must be non-negative");
// }
// this.receiveTimeout = receiveTimeout;
// return this;
// }
//
// public WSManEndpoint build() {
// return new WSManEndpoint(this);
// }
// }
//
// public URL getUrl() {
// return url;
// }
//
// public boolean isBasicAuth() {
// return !isGSSAuth() && username != null;
// }
//
// public String getUsername() {
// return username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public boolean isGSSAuth() {
// return gssAuth;
// }
//
// public boolean isStrictSSL() {
// return strictSSL;
// }
//
// public WSManVersion getServerVersion() {
// return serverVersion;
// }
//
// public Integer getMaxElements() {
// return maxElements;
// }
//
// public Integer getMaxEnvelopeSize() {
// return maxEnvelopeSize;
// }
//
// public Integer getConnectionTimeout() {
// return connectionTimeout;
// }
//
// public Integer getReceiveTimeout() {
// return receiveTimeout;
// }
//
// public String toString() {
// return String.format("WSManEndpoint[url='%s', isGSSAuth='%s', isBasicAuth='%s', isStrictSSL='%s', "
// + "serverVersion='%s', maxElements='%s', maxEnvelopeSize='%s'"
// + "connectionTimeout='%s', receiveTimeout='%s']",
// url, isGSSAuth(), isBasicAuth(), isStrictSSL(), serverVersion,
// maxElements, maxEnvelopeSize, connectionTimeout, receiveTimeout);
// }
// }
// Path: cxf/src/main/java/org/opennms/core/wsman/cxf/CXFWSManClientFactory.java
import org.opennms.core.wsman.WSManClientFactory;
import org.opennms.core.wsman.WSManEndpoint;
/*
* Copyright 2015, The OpenNMS Group
*
* 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.
*/
package org.opennms.core.wsman.cxf;
/**
* Used to instantiate a new {@link CXFWSManClient} from a
* given {@link WSManEndpoint}.
*
* @author jwhite
*/
public class CXFWSManClientFactory implements WSManClientFactory {
@Override
|
public CXFWSManClient getClient(WSManEndpoint endpoint) {
|
OpenNMS/wsman
|
cli/src/main/java/org/opennms/core/wsman/WSManCli.java
|
// Path: cxf/src/main/java/org/opennms/core/wsman/cxf/CXFWSManClientFactory.java
// public class CXFWSManClientFactory implements WSManClientFactory {
//
// @Override
// public CXFWSManClient getClient(WSManEndpoint endpoint) {
// return new CXFWSManClient(endpoint);
// }
// }
|
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.spi.StandardLevel;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.ParserProperties;
import org.kohsuke.args4j.spi.MapOptionHandler;
import org.opennms.core.wsman.cxf.CXFWSManClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.google.common.collect.Lists;
|
@Option(name="-p", usage="password")
private String password;
@Option(name="-strictSSL", usage="ssl certificate verification")
private boolean strictSSL = false;
@Option(name="-gssAuth", usage="GSS authentication")
private boolean gssAuth = false;
@Option(name="-o", usage="operation")
WSManOperation operation = WSManOperation.ENUM;
@Option(name="-resourceUri", usage="resource uri")
private String resourceUri = WSManConstants.CIM_ALL_AVAILABLE_CLASSES;
@Option(name="-w", usage="server version")
private WSManVersion serverVersion = WSManVersion.WSMAN_1_2;
@Option(name="-v", usage="logging level")
private StandardLevel logLevel = StandardLevel.INFO;
@Option(name="-vvv", usage="log request and responses")
private boolean logRequests = false;
@Option(name="-s", handler=MapOptionHandler.class)
private Map<String,String> selectors;
@Argument
private List<String> arguments = new ArrayList<String>();
|
// Path: cxf/src/main/java/org/opennms/core/wsman/cxf/CXFWSManClientFactory.java
// public class CXFWSManClientFactory implements WSManClientFactory {
//
// @Override
// public CXFWSManClient getClient(WSManEndpoint endpoint) {
// return new CXFWSManClient(endpoint);
// }
// }
// Path: cli/src/main/java/org/opennms/core/wsman/WSManCli.java
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.spi.StandardLevel;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.ParserProperties;
import org.kohsuke.args4j.spi.MapOptionHandler;
import org.opennms.core.wsman.cxf.CXFWSManClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.google.common.collect.Lists;
@Option(name="-p", usage="password")
private String password;
@Option(name="-strictSSL", usage="ssl certificate verification")
private boolean strictSSL = false;
@Option(name="-gssAuth", usage="GSS authentication")
private boolean gssAuth = false;
@Option(name="-o", usage="operation")
WSManOperation operation = WSManOperation.ENUM;
@Option(name="-resourceUri", usage="resource uri")
private String resourceUri = WSManConstants.CIM_ALL_AVAILABLE_CLASSES;
@Option(name="-w", usage="server version")
private WSManVersion serverVersion = WSManVersion.WSMAN_1_2;
@Option(name="-v", usage="logging level")
private StandardLevel logLevel = StandardLevel.INFO;
@Option(name="-vvv", usage="log request and responses")
private boolean logRequests = false;
@Option(name="-s", handler=MapOptionHandler.class)
private Map<String,String> selectors;
@Argument
private List<String> arguments = new ArrayList<String>();
|
private WSManClientFactory clientFactory = new CXFWSManClientFactory();
|
jboss-openshift/openshift-ping
|
common/src/main/java/org/openshift/ping/common/OpenshiftPing.java
|
// Path: common/src/main/java/org/openshift/ping/common/compatibility/CompatibilityUtils.java
// public class CompatibilityUtils {
//
// private CompatibilityUtils() {
// }
//
// /**
// * @return <code>true</code> when JGroups 4 is on the classpath. <code>false</code> otherwise.
// */
// public static boolean isJGroups4() {
// final short[] decodedVersion = Version.decode(Version.version);
// return decodedVersion[0] == 4;
// }
// }
//
// Path: common/src/main/java/org/openshift/ping/common/server/ServerFactory.java
// public interface ServerFactory {
// public boolean isAvailable();
// public Server getServer(int port);
// }
|
import org.jgroups.stack.IpAddress;
import org.jgroups.stack.Protocol;
import org.openshift.ping.common.compatibility.CompatibilityException;
import org.openshift.ping.common.compatibility.CompatibilityUtils;
import org.openshift.ping.common.server.ServerFactory;
import static org.openshift.ping.common.Utils.getSystemEnvInt;
import static org.openshift.ping.common.Utils.trimToNull;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
import org.jgroups.Event;
import org.jgroups.Message;
import org.jgroups.PhysicalAddress;
import org.jgroups.annotations.Property;
import org.jgroups.protocols.PING;
|
/**
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.
*/
package org.openshift.ping.common;
public abstract class OpenshiftPing extends PING {
private String clusterName;
private final String _systemEnvPrefix;
@Property
private int connectTimeout = 5000;
private int _connectTimeout;
@Property
private int readTimeout = 30000;
private int _readTimeout;
@Property
private int operationAttempts = 3;
private int _operationAttempts;
@Property
private long operationSleep = 1000;
private long _operationSleep;
private static Method sendDownMethod; //handled via reflection due to JGroups 3/4 incompatibility
public OpenshiftPing(String systemEnvPrefix) {
super();
_systemEnvPrefix = trimToNull(systemEnvPrefix);
try {
|
// Path: common/src/main/java/org/openshift/ping/common/compatibility/CompatibilityUtils.java
// public class CompatibilityUtils {
//
// private CompatibilityUtils() {
// }
//
// /**
// * @return <code>true</code> when JGroups 4 is on the classpath. <code>false</code> otherwise.
// */
// public static boolean isJGroups4() {
// final short[] decodedVersion = Version.decode(Version.version);
// return decodedVersion[0] == 4;
// }
// }
//
// Path: common/src/main/java/org/openshift/ping/common/server/ServerFactory.java
// public interface ServerFactory {
// public boolean isAvailable();
// public Server getServer(int port);
// }
// Path: common/src/main/java/org/openshift/ping/common/OpenshiftPing.java
import org.jgroups.stack.IpAddress;
import org.jgroups.stack.Protocol;
import org.openshift.ping.common.compatibility.CompatibilityException;
import org.openshift.ping.common.compatibility.CompatibilityUtils;
import org.openshift.ping.common.server.ServerFactory;
import static org.openshift.ping.common.Utils.getSystemEnvInt;
import static org.openshift.ping.common.Utils.trimToNull;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
import org.jgroups.Event;
import org.jgroups.Message;
import org.jgroups.PhysicalAddress;
import org.jgroups.annotations.Property;
import org.jgroups.protocols.PING;
/**
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.
*/
package org.openshift.ping.common;
public abstract class OpenshiftPing extends PING {
private String clusterName;
private final String _systemEnvPrefix;
@Property
private int connectTimeout = 5000;
private int _connectTimeout;
@Property
private int readTimeout = 30000;
private int _readTimeout;
@Property
private int operationAttempts = 3;
private int _operationAttempts;
@Property
private long operationSleep = 1000;
private long _operationSleep;
private static Method sendDownMethod; //handled via reflection due to JGroups 3/4 incompatibility
public OpenshiftPing(String systemEnvPrefix) {
super();
_systemEnvPrefix = trimToNull(systemEnvPrefix);
try {
|
if(CompatibilityUtils.isJGroups4()) {
|
jboss-openshift/openshift-ping
|
common/src/main/java/org/openshift/ping/common/OpenshiftPing.java
|
// Path: common/src/main/java/org/openshift/ping/common/compatibility/CompatibilityUtils.java
// public class CompatibilityUtils {
//
// private CompatibilityUtils() {
// }
//
// /**
// * @return <code>true</code> when JGroups 4 is on the classpath. <code>false</code> otherwise.
// */
// public static boolean isJGroups4() {
// final short[] decodedVersion = Version.decode(Version.version);
// return decodedVersion[0] == 4;
// }
// }
//
// Path: common/src/main/java/org/openshift/ping/common/server/ServerFactory.java
// public interface ServerFactory {
// public boolean isAvailable();
// public Server getServer(int port);
// }
|
import org.jgroups.stack.IpAddress;
import org.jgroups.stack.Protocol;
import org.openshift.ping.common.compatibility.CompatibilityException;
import org.openshift.ping.common.compatibility.CompatibilityUtils;
import org.openshift.ping.common.server.ServerFactory;
import static org.openshift.ping.common.Utils.getSystemEnvInt;
import static org.openshift.ping.common.Utils.trimToNull;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
import org.jgroups.Event;
import org.jgroups.Message;
import org.jgroups.PhysicalAddress;
import org.jgroups.annotations.Property;
import org.jgroups.protocols.PING;
|
String suffix = trimToNull(systemEnvSuffix);
if (suffix != null) {
if (_systemEnvPrefix != null) {
sb.append(_systemEnvPrefix);
}
sb.append(suffix);
}
return sb.length() > 0 ? sb.toString() : null;
}
protected final int getConnectTimeout() {
return _connectTimeout;
}
protected final int getReadTimeout() {
return _readTimeout;
}
protected final int getOperationAttempts() {
return _operationAttempts;
}
protected final long getOperationSleep() {
return _operationSleep;
}
protected abstract boolean isClusteringEnabled();
protected abstract int getServerPort();
|
// Path: common/src/main/java/org/openshift/ping/common/compatibility/CompatibilityUtils.java
// public class CompatibilityUtils {
//
// private CompatibilityUtils() {
// }
//
// /**
// * @return <code>true</code> when JGroups 4 is on the classpath. <code>false</code> otherwise.
// */
// public static boolean isJGroups4() {
// final short[] decodedVersion = Version.decode(Version.version);
// return decodedVersion[0] == 4;
// }
// }
//
// Path: common/src/main/java/org/openshift/ping/common/server/ServerFactory.java
// public interface ServerFactory {
// public boolean isAvailable();
// public Server getServer(int port);
// }
// Path: common/src/main/java/org/openshift/ping/common/OpenshiftPing.java
import org.jgroups.stack.IpAddress;
import org.jgroups.stack.Protocol;
import org.openshift.ping.common.compatibility.CompatibilityException;
import org.openshift.ping.common.compatibility.CompatibilityUtils;
import org.openshift.ping.common.server.ServerFactory;
import static org.openshift.ping.common.Utils.getSystemEnvInt;
import static org.openshift.ping.common.Utils.trimToNull;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
import org.jgroups.Event;
import org.jgroups.Message;
import org.jgroups.PhysicalAddress;
import org.jgroups.annotations.Property;
import org.jgroups.protocols.PING;
String suffix = trimToNull(systemEnvSuffix);
if (suffix != null) {
if (_systemEnvPrefix != null) {
sb.append(_systemEnvPrefix);
}
sb.append(suffix);
}
return sb.length() > 0 ? sb.toString() : null;
}
protected final int getConnectTimeout() {
return _connectTimeout;
}
protected final int getReadTimeout() {
return _readTimeout;
}
protected final int getOperationAttempts() {
return _operationAttempts;
}
protected final long getOperationSleep() {
return _operationSleep;
}
protected abstract boolean isClusteringEnabled();
protected abstract int getServerPort();
|
public final void setServerFactory(ServerFactory serverFactory) {
|
jboss-openshift/openshift-ping
|
kube/src/main/java/org/openshift/ping/kube/Client.java
|
// Path: common/src/main/java/org/openshift/ping/common/stream/StreamProvider.java
// public interface StreamProvider {
//
// public InputStream openStream(String url, Map<String, String> headers, int connectTimeout, int readTimeout) throws IOException;
//
// }
|
import static org.openshift.ping.common.Utils.openStream;
import static org.openshift.ping.common.Utils.urlencode;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jboss.dmr.ModelNode;
import org.openshift.ping.common.stream.StreamProvider;
|
/**
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.
*/
package org.openshift.ping.kube;
/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public class Client {
private static final Logger log = Logger.getLogger(Client.class.getName());
private final String masterUrl;
private final Map<String, String> headers;
private final int connectTimeout;
private final int readTimeout;
private final int operationAttempts;
private final long operationSleep;
|
// Path: common/src/main/java/org/openshift/ping/common/stream/StreamProvider.java
// public interface StreamProvider {
//
// public InputStream openStream(String url, Map<String, String> headers, int connectTimeout, int readTimeout) throws IOException;
//
// }
// Path: kube/src/main/java/org/openshift/ping/kube/Client.java
import static org.openshift.ping.common.Utils.openStream;
import static org.openshift.ping.common.Utils.urlencode;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jboss.dmr.ModelNode;
import org.openshift.ping.common.stream.StreamProvider;
/**
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.
*/
package org.openshift.ping.kube;
/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public class Client {
private static final Logger log = Logger.getLogger(Client.class.getName());
private final String masterUrl;
private final Map<String, String> headers;
private final int connectTimeout;
private final int readTimeout;
private final int operationAttempts;
private final long operationSleep;
|
private final StreamProvider streamProvider;
|
jboss-openshift/openshift-ping
|
kube/src/test/java/org/openshift/ping/kube/test/PingTestBase.java
|
// Path: common/src/main/java/org/openshift/ping/common/compatibility/CompatibilityUtils.java
// public class CompatibilityUtils {
//
// private CompatibilityUtils() {
// }
//
// /**
// * @return <code>true</code> when JGroups 4 is on the classpath. <code>false</code> otherwise.
// */
// public static boolean isJGroups4() {
// final short[] decodedVersion = Version.decode(Version.version);
// return decodedVersion[0] == 4;
// }
// }
|
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.jgroups.Channel;
import org.jgroups.JChannel;
import org.jgroups.util.Util;
import org.junit.Assert;
import org.junit.Test;
import org.openshift.ping.common.compatibility.CompatibilityException;
import org.openshift.ping.common.compatibility.CompatibilityUtils;
|
/**
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.
*/
package org.openshift.ping.kube.test;
/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public abstract class PingTestBase extends TestBase {
//handles via reflection because of JGroups 3/4 incompatibility.
private static final Method waitForViewMethod;
static {
try {
|
// Path: common/src/main/java/org/openshift/ping/common/compatibility/CompatibilityUtils.java
// public class CompatibilityUtils {
//
// private CompatibilityUtils() {
// }
//
// /**
// * @return <code>true</code> when JGroups 4 is on the classpath. <code>false</code> otherwise.
// */
// public static boolean isJGroups4() {
// final short[] decodedVersion = Version.decode(Version.version);
// return decodedVersion[0] == 4;
// }
// }
// Path: kube/src/test/java/org/openshift/ping/kube/test/PingTestBase.java
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.jgroups.Channel;
import org.jgroups.JChannel;
import org.jgroups.util.Util;
import org.junit.Assert;
import org.junit.Test;
import org.openshift.ping.common.compatibility.CompatibilityException;
import org.openshift.ping.common.compatibility.CompatibilityUtils;
/**
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.
*/
package org.openshift.ping.kube.test;
/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public abstract class PingTestBase extends TestBase {
//handles via reflection because of JGroups 3/4 incompatibility.
private static final Method waitForViewMethod;
static {
try {
|
if (CompatibilityUtils.isJGroups4()) {
|
andresdominguez/jsToolbox
|
src/com/karateca/jstoolbox/config/JsToolboxConfigurable.java
|
// Path: src/com/karateca/jstoolbox/config/JsToolboxSettings.java
// public enum Property {
// TestSuffix("com.karateca.jstoolbox.testSuffix", "-spec.js"),
// FileSuffix("com.karateca.jstoolbox.fileSuffix", ".js"),
// ViewSuffix("com.karateca.jstoolbox.viewSuffix", ".html"),
// SearchUrl("com.karateca.jstoolbox.searchUrl",
// "https://github.com/search?q={fileName}#L{line}"),
// UseFilePath("com.karateca.jstoolbox.useFilePath", "false"),
// FromPath("com.karateca.jstoolbox.fromPath", "");
//
// private final String property;
// private final String defaultValue;
//
// private Property(String property, String defaultValue) {
// this.property = property;
// this.defaultValue = defaultValue;
// }
//
// public String getProperty() {
// return property;
// }
//
// public String getDefaultValue() {
// return defaultValue;
// }
// }
|
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static com.karateca.jstoolbox.config.JsToolboxSettings.Property;
|
package com.karateca.jstoolbox.config;
/**
* @author Andres Dominguez.
*/
public class JsToolboxConfigurable implements Configurable {
private ConfigurationView view;
private final JsToolboxSettings settings;
public JsToolboxConfigurable() {
settings = new JsToolboxSettings();
}
@Nls
@Override
public String getDisplayName() {
return "JS Toolbox";
}
@Nullable
@Override
public String getHelpTopic() {
return "Configure the default settings for the JS Toolbox";
}
@Nullable
@Override
public JComponent createComponent() {
if (view == null) {
view = new ConfigurationView();
}
// Reset on click.
view.getResetButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
view.setTestSuffix(
|
// Path: src/com/karateca/jstoolbox/config/JsToolboxSettings.java
// public enum Property {
// TestSuffix("com.karateca.jstoolbox.testSuffix", "-spec.js"),
// FileSuffix("com.karateca.jstoolbox.fileSuffix", ".js"),
// ViewSuffix("com.karateca.jstoolbox.viewSuffix", ".html"),
// SearchUrl("com.karateca.jstoolbox.searchUrl",
// "https://github.com/search?q={fileName}#L{line}"),
// UseFilePath("com.karateca.jstoolbox.useFilePath", "false"),
// FromPath("com.karateca.jstoolbox.fromPath", "");
//
// private final String property;
// private final String defaultValue;
//
// private Property(String property, String defaultValue) {
// this.property = property;
// this.defaultValue = defaultValue;
// }
//
// public String getProperty() {
// return property;
// }
//
// public String getDefaultValue() {
// return defaultValue;
// }
// }
// Path: src/com/karateca/jstoolbox/config/JsToolboxConfigurable.java
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static com.karateca.jstoolbox.config.JsToolboxSettings.Property;
package com.karateca.jstoolbox.config;
/**
* @author Andres Dominguez.
*/
public class JsToolboxConfigurable implements Configurable {
private ConfigurationView view;
private final JsToolboxSettings settings;
public JsToolboxConfigurable() {
settings = new JsToolboxSettings();
}
@Nls
@Override
public String getDisplayName() {
return "JS Toolbox";
}
@Nullable
@Override
public String getHelpTopic() {
return "Configure the default settings for the JS Toolbox";
}
@Nullable
@Override
public JComponent createComponent() {
if (view == null) {
view = new ConfigurationView();
}
// Reset on click.
view.getResetButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
view.setTestSuffix(
|
Property.TestSuffix.getDefaultValue());
|
WanionCane/UniDict
|
src/main/java/wanion/unidict/integration/DraconicEvolutionIntegration.java
|
// Path: src/main/java/wanion/unidict/common/Util.java
// public final class Util
// {
// public static final Comparator<ItemStack> itemStackComparatorByModName = new Comparator<ItemStack>()
// {
// @Override
// public int compare(@Nonnull final ItemStack itemStack1, @Nonnull final ItemStack itemStack2)
// {
// final String stack1ModName = getModName(itemStack1), stack2ModName = getModName(itemStack2);
// final Config config = UniDict.getConfig();
// if (config.keepOneEntry && config.keepOneEntryModBlackSet.contains(stack1ModName))
// ResourceHandler.addToKeepOneEntryModBlackSet(itemStack1);
// final int stackIndex1 = getIndex(stack1ModName), stackIndex2 = getIndex(stack2ModName);
// final boolean sameIndexModAndItem = stackIndex1 == stackIndex2 && stack1ModName.equals(stack2ModName) && itemStack1.getItem() == itemStack2.getItem();
// return !sameIndexModAndItem ? (stackIndex1 < stackIndex2 ? -1 : 0) : itemStack1.getItemDamage() < itemStack2.getItemDamage() ? -1 : 0;
// }
//
// private int getIndex(final String modName)
// {
// return UniDict.getConfig().ownerOfEveryThing.get(modName);
// }
// };
//
// private Util()
// {
// }
//
// public static int getCumulative(@Nonnull final Object[] objects, @Nonnull final ResourceHandler resourceHandler)
// {
// int cumulativeKey = 0;
// for (final Object object : objects)
// if (object instanceof ItemStack)
// cumulativeKey += MetaItem.get(resourceHandler.getMainItemStack((ItemStack) object));
// else if (object instanceof List && !((List) object).isEmpty())
// cumulativeKey += MetaItem.get((ItemStack) ((List) object).get(0));
// return cumulativeKey;
// }
//
// public static TIntList getList(@Nonnull final Object[] objects, @Nonnull final ResourceHandler resourceHandler)
// {
// final TIntList keys = new TIntArrayList();
// int bufKey;
// for (final Object object : objects)
// if (object instanceof ItemStack) {
// if ((bufKey = MetaItem.get(resourceHandler.getMainItemStack((ItemStack) object))) > 0)
// keys.add(bufKey);
// } else if (object instanceof Ingredient && ((Ingredient) object).getMatchingStacks().length > 0) {
// if ((bufKey = MetaItem.get(resourceHandler.getMainItemStack(((Ingredient) object).getMatchingStacks()[0]))) > 0)
// keys.add(bufKey);
// } else if (object instanceof List && !((List) object).isEmpty())
// if ((bufKey = MetaItem.get(((ItemStack) ((List) object).get(0)))) > 0)
// keys.add(bufKey);
// return keys;
// }
//
// public static TIntList getList(@Nonnull final List<?> objects, @Nonnull final ResourceHandler resourceHandler)
// {
// return getList(objects.toArray(), resourceHandler);
// }
//
// public static TIntSet getSet(@Nonnull final Collection<Resource> resourceCollection, final int kind)
// {
// final TIntSet keys = new TIntHashSet();
// resourceCollection.stream().filter(resource -> resource.childExists(kind)).forEach(resource -> keys.addAll(MetaItem.getList(resource.getChild(kind).getEntries())));
// return keys;
// }
//
// public static List<ItemStack> stringListToItemStackList(@Nonnull final List<String> stringList)
// {
// final List<ItemStack> itemStackList = new ArrayList<>();
// stringList.forEach(itemName -> {
// final int separatorChar = itemName.indexOf('#');
// final Item item = Item.REGISTRY.getObject(new ResourceLocation(separatorChar == -1 ? itemName : itemName.substring(0, separatorChar)));
// if (item != null) {
// final int metadata = separatorChar == -1 ? 0 : Integer.parseInt(itemName.substring(separatorChar + 1));
// itemStackList.add(new ItemStack(item, 1, metadata));
// }
// });
// return itemStackList;
// }
//
// public static String getOreNameFromIngredient(OreIngredient ingredient) {
// // This code gets patched by the core mod.
// return ingredient.toString();
// }
// }
|
import com.brandon3055.draconicevolution.lib.OreDoublingRegistry;
import gnu.trove.set.TIntSet;
import net.minecraft.item.ItemStack;
import wanion.lib.common.MetaItem;
import wanion.unidict.common.Util;
import java.util.Map;
|
package wanion.unidict.integration;
final class DraconicEvolutionIntegration extends AbstractIntegrationThread
{
private final TIntSet outputsToIgnore;
DraconicEvolutionIntegration()
{
super("Draconic Evolution");
|
// Path: src/main/java/wanion/unidict/common/Util.java
// public final class Util
// {
// public static final Comparator<ItemStack> itemStackComparatorByModName = new Comparator<ItemStack>()
// {
// @Override
// public int compare(@Nonnull final ItemStack itemStack1, @Nonnull final ItemStack itemStack2)
// {
// final String stack1ModName = getModName(itemStack1), stack2ModName = getModName(itemStack2);
// final Config config = UniDict.getConfig();
// if (config.keepOneEntry && config.keepOneEntryModBlackSet.contains(stack1ModName))
// ResourceHandler.addToKeepOneEntryModBlackSet(itemStack1);
// final int stackIndex1 = getIndex(stack1ModName), stackIndex2 = getIndex(stack2ModName);
// final boolean sameIndexModAndItem = stackIndex1 == stackIndex2 && stack1ModName.equals(stack2ModName) && itemStack1.getItem() == itemStack2.getItem();
// return !sameIndexModAndItem ? (stackIndex1 < stackIndex2 ? -1 : 0) : itemStack1.getItemDamage() < itemStack2.getItemDamage() ? -1 : 0;
// }
//
// private int getIndex(final String modName)
// {
// return UniDict.getConfig().ownerOfEveryThing.get(modName);
// }
// };
//
// private Util()
// {
// }
//
// public static int getCumulative(@Nonnull final Object[] objects, @Nonnull final ResourceHandler resourceHandler)
// {
// int cumulativeKey = 0;
// for (final Object object : objects)
// if (object instanceof ItemStack)
// cumulativeKey += MetaItem.get(resourceHandler.getMainItemStack((ItemStack) object));
// else if (object instanceof List && !((List) object).isEmpty())
// cumulativeKey += MetaItem.get((ItemStack) ((List) object).get(0));
// return cumulativeKey;
// }
//
// public static TIntList getList(@Nonnull final Object[] objects, @Nonnull final ResourceHandler resourceHandler)
// {
// final TIntList keys = new TIntArrayList();
// int bufKey;
// for (final Object object : objects)
// if (object instanceof ItemStack) {
// if ((bufKey = MetaItem.get(resourceHandler.getMainItemStack((ItemStack) object))) > 0)
// keys.add(bufKey);
// } else if (object instanceof Ingredient && ((Ingredient) object).getMatchingStacks().length > 0) {
// if ((bufKey = MetaItem.get(resourceHandler.getMainItemStack(((Ingredient) object).getMatchingStacks()[0]))) > 0)
// keys.add(bufKey);
// } else if (object instanceof List && !((List) object).isEmpty())
// if ((bufKey = MetaItem.get(((ItemStack) ((List) object).get(0)))) > 0)
// keys.add(bufKey);
// return keys;
// }
//
// public static TIntList getList(@Nonnull final List<?> objects, @Nonnull final ResourceHandler resourceHandler)
// {
// return getList(objects.toArray(), resourceHandler);
// }
//
// public static TIntSet getSet(@Nonnull final Collection<Resource> resourceCollection, final int kind)
// {
// final TIntSet keys = new TIntHashSet();
// resourceCollection.stream().filter(resource -> resource.childExists(kind)).forEach(resource -> keys.addAll(MetaItem.getList(resource.getChild(kind).getEntries())));
// return keys;
// }
//
// public static List<ItemStack> stringListToItemStackList(@Nonnull final List<String> stringList)
// {
// final List<ItemStack> itemStackList = new ArrayList<>();
// stringList.forEach(itemName -> {
// final int separatorChar = itemName.indexOf('#');
// final Item item = Item.REGISTRY.getObject(new ResourceLocation(separatorChar == -1 ? itemName : itemName.substring(0, separatorChar)));
// if (item != null) {
// final int metadata = separatorChar == -1 ? 0 : Integer.parseInt(itemName.substring(separatorChar + 1));
// itemStackList.add(new ItemStack(item, 1, metadata));
// }
// });
// return itemStackList;
// }
//
// public static String getOreNameFromIngredient(OreIngredient ingredient) {
// // This code gets patched by the core mod.
// return ingredient.toString();
// }
// }
// Path: src/main/java/wanion/unidict/integration/DraconicEvolutionIntegration.java
import com.brandon3055.draconicevolution.lib.OreDoublingRegistry;
import gnu.trove.set.TIntSet;
import net.minecraft.item.ItemStack;
import wanion.lib.common.MetaItem;
import wanion.unidict.common.Util;
import java.util.Map;
package wanion.unidict.integration;
final class DraconicEvolutionIntegration extends AbstractIntegrationThread
{
private final TIntSet outputsToIgnore;
DraconicEvolutionIntegration()
{
super("Draconic Evolution");
|
outputsToIgnore = MetaItem.getSet(Util.stringListToItemStackList(config.furnaceOutputsToIgnore));
|
WanionCane/UniDict
|
src/main/java/wanion/unidict/proxy/ClientProxy.java
|
// Path: src/main/java/wanion/unidict/UniDict.java
// @SuppressWarnings("unused")
// @Mod(modid = MOD_ID, name = MOD_NAME, version = MOD_VERSION, acceptedMinecraftVersions = MC_VERSION, dependencies = DEPENDENCIES)
// public final class UniDict
// {
// @Mod.Instance(MOD_ID)
// public static UniDict instance;
//
// @SidedProxy(clientSide = CLIENT_PROXY, serverSide = SERVER_PROXY)
// public static CommonProxy proxy;
//
// private static Logger logger;
//
// public static Logger getLogger()
// {
// return logger;
// }
//
// public static Dependencies<IDependency> getDependencies()
// {
// return proxy.dependencies;
// }
//
// public static ResourceHandler getResourceHandler()
// {
// return proxy.dependencies.get(ResourceHandler.class);
// }
//
// public static UniOreDictionary getUniOreDictionary()
// {
// return proxy.dependencies.get(UniOreDictionary.class);
// }
//
// public static Config getConfig()
// {
// return Config.INSTANCE;
// }
//
// public static UniDictAPI getAPI()
// {
// return UniDictAPI.getInstance();
// }
//
// public static ModuleHandler getModuleHandler()
// {
// return proxy.moduleHandler;
// }
//
// @Mod.EventHandler
// public void preInit(final FMLPreInitializationEvent event)
// {
// logger = event.getModLog();
// proxy.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(final FMLInitializationEvent event)
// {
// proxy.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event)
// {
// proxy.postInit(event);
// }
//
// @Mod.EventHandler
// public void loadComplete(final FMLLoadCompleteEvent event)
// {
// proxy.loadComplete(event);
// proxy.clean();
// }
//
// @NetworkCheckHandler
// public boolean matchModVersions(final Map<String, String> remoteVersions, final Side side)
// {
// return side == Side.CLIENT ? remoteVersions.containsKey(MOD_ID) : !remoteVersions.containsKey(MOD_ID) || remoteVersions.get(MOD_ID).equals(MOD_VERSION);
// }
//
// public interface IDependency {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Module {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Integration {}
// }
|
import net.minecraft.client.util.RecipeBookClient;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import wanion.unidict.UniDict;
|
package wanion.unidict.proxy;
/*
* Created by WanionCane(https://github.com/WanionCane).
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
public class ClientProxy extends CommonProxy {
@Override
public void postInit(final FMLPostInitializationEvent event)
{
super.postInit(event);
try {
RecipeBookClient.rebuildTable();
|
// Path: src/main/java/wanion/unidict/UniDict.java
// @SuppressWarnings("unused")
// @Mod(modid = MOD_ID, name = MOD_NAME, version = MOD_VERSION, acceptedMinecraftVersions = MC_VERSION, dependencies = DEPENDENCIES)
// public final class UniDict
// {
// @Mod.Instance(MOD_ID)
// public static UniDict instance;
//
// @SidedProxy(clientSide = CLIENT_PROXY, serverSide = SERVER_PROXY)
// public static CommonProxy proxy;
//
// private static Logger logger;
//
// public static Logger getLogger()
// {
// return logger;
// }
//
// public static Dependencies<IDependency> getDependencies()
// {
// return proxy.dependencies;
// }
//
// public static ResourceHandler getResourceHandler()
// {
// return proxy.dependencies.get(ResourceHandler.class);
// }
//
// public static UniOreDictionary getUniOreDictionary()
// {
// return proxy.dependencies.get(UniOreDictionary.class);
// }
//
// public static Config getConfig()
// {
// return Config.INSTANCE;
// }
//
// public static UniDictAPI getAPI()
// {
// return UniDictAPI.getInstance();
// }
//
// public static ModuleHandler getModuleHandler()
// {
// return proxy.moduleHandler;
// }
//
// @Mod.EventHandler
// public void preInit(final FMLPreInitializationEvent event)
// {
// logger = event.getModLog();
// proxy.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(final FMLInitializationEvent event)
// {
// proxy.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event)
// {
// proxy.postInit(event);
// }
//
// @Mod.EventHandler
// public void loadComplete(final FMLLoadCompleteEvent event)
// {
// proxy.loadComplete(event);
// proxy.clean();
// }
//
// @NetworkCheckHandler
// public boolean matchModVersions(final Map<String, String> remoteVersions, final Side side)
// {
// return side == Side.CLIENT ? remoteVersions.containsKey(MOD_ID) : !remoteVersions.containsKey(MOD_ID) || remoteVersions.get(MOD_ID).equals(MOD_VERSION);
// }
//
// public interface IDependency {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Module {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Integration {}
// }
// Path: src/main/java/wanion/unidict/proxy/ClientProxy.java
import net.minecraft.client.util.RecipeBookClient;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import wanion.unidict.UniDict;
package wanion.unidict.proxy;
/*
* Created by WanionCane(https://github.com/WanionCane).
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
public class ClientProxy extends CommonProxy {
@Override
public void postInit(final FMLPostInitializationEvent event)
{
super.postInit(event);
try {
RecipeBookClient.rebuildTable();
|
UniDict.getLogger().info("Fixed the Recipe Book");
|
WanionCane/UniDict
|
src/main/java/wanion/unidict/integration/IntegrationModule.java
|
// Path: src/main/java/wanion/unidict/UniDict.java
// @SuppressWarnings("unused")
// @Mod(modid = MOD_ID, name = MOD_NAME, version = MOD_VERSION, acceptedMinecraftVersions = MC_VERSION, dependencies = DEPENDENCIES)
// public final class UniDict
// {
// @Mod.Instance(MOD_ID)
// public static UniDict instance;
//
// @SidedProxy(clientSide = CLIENT_PROXY, serverSide = SERVER_PROXY)
// public static CommonProxy proxy;
//
// private static Logger logger;
//
// public static Logger getLogger()
// {
// return logger;
// }
//
// public static Dependencies<IDependency> getDependencies()
// {
// return proxy.dependencies;
// }
//
// public static ResourceHandler getResourceHandler()
// {
// return proxy.dependencies.get(ResourceHandler.class);
// }
//
// public static UniOreDictionary getUniOreDictionary()
// {
// return proxy.dependencies.get(UniOreDictionary.class);
// }
//
// public static Config getConfig()
// {
// return Config.INSTANCE;
// }
//
// public static UniDictAPI getAPI()
// {
// return UniDictAPI.getInstance();
// }
//
// public static ModuleHandler getModuleHandler()
// {
// return proxy.moduleHandler;
// }
//
// @Mod.EventHandler
// public void preInit(final FMLPreInitializationEvent event)
// {
// logger = event.getModLog();
// proxy.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(final FMLInitializationEvent event)
// {
// proxy.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event)
// {
// proxy.postInit(event);
// }
//
// @Mod.EventHandler
// public void loadComplete(final FMLLoadCompleteEvent event)
// {
// proxy.loadComplete(event);
// proxy.clean();
// }
//
// @NetworkCheckHandler
// public boolean matchModVersions(final Map<String, String> remoteVersions, final Side side)
// {
// return side == Side.CLIENT ? remoteVersions.containsKey(MOD_ID) : !remoteVersions.containsKey(MOD_ID) || remoteVersions.get(MOD_ID).equals(MOD_VERSION);
// }
//
// public interface IDependency {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Module {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Integration {}
// }
//
// Path: src/main/java/wanion/unidict/common/Reference.java
// public final class Reference
// {
// public static final String MOD_ID = "unidict";
// public static final String MOD_NAME = "UniDict";
// public static final String MOD_VERSION = "@version@";
// public static final String DEPENDENCIES = "required-after:wanionlib@[1.12.2-2.5,);after:*";
// public static final char SLASH = separatorChar;
// public static final String MC_VERSION = "[1.12,]";
// public static final String CLIENT_PROXY = "wanion.unidict.proxy.ClientProxy";
// public static final String SERVER_PROXY = "wanion.unidict.proxy.CommonProxy";
//
// private Reference() {}
// }
|
import net.minecraftforge.common.config.Configuration;
import org.apache.commons.lang3.text.WordUtils;
import wanion.lib.module.AbstractModule;
import wanion.unidict.UniDict;
import wanion.unidict.common.Reference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.util.LinkedHashSet;
import java.util.Set;
import static net.minecraftforge.fml.common.Loader.isModLoaded;
import static wanion.unidict.common.Reference.SLASH;
|
package wanion.unidict.integration;
/*
* Created by WanionCane(https://github.com/WanionCane).
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
public final class IntegrationModule extends AbstractModule implements UniDict.IDependency
{
private final Set<Class<AbstractIntegrationThread>> MOD_INTEGRATIONS = new LinkedHashSet<>();
public IntegrationModule()
{
super("Integration", Class::newInstance);
}
public static IntegrationModule getIntegrationModule()
{
return UniDict.getDependencies().get(IntegrationModule.class);
}
public void registerIntegration(@Nonnull final Class<AbstractIntegrationThread> integrationClassToRegister)
{
MOD_INTEGRATIONS.add(integrationClassToRegister);
}
@Override
protected void init()
{
|
// Path: src/main/java/wanion/unidict/UniDict.java
// @SuppressWarnings("unused")
// @Mod(modid = MOD_ID, name = MOD_NAME, version = MOD_VERSION, acceptedMinecraftVersions = MC_VERSION, dependencies = DEPENDENCIES)
// public final class UniDict
// {
// @Mod.Instance(MOD_ID)
// public static UniDict instance;
//
// @SidedProxy(clientSide = CLIENT_PROXY, serverSide = SERVER_PROXY)
// public static CommonProxy proxy;
//
// private static Logger logger;
//
// public static Logger getLogger()
// {
// return logger;
// }
//
// public static Dependencies<IDependency> getDependencies()
// {
// return proxy.dependencies;
// }
//
// public static ResourceHandler getResourceHandler()
// {
// return proxy.dependencies.get(ResourceHandler.class);
// }
//
// public static UniOreDictionary getUniOreDictionary()
// {
// return proxy.dependencies.get(UniOreDictionary.class);
// }
//
// public static Config getConfig()
// {
// return Config.INSTANCE;
// }
//
// public static UniDictAPI getAPI()
// {
// return UniDictAPI.getInstance();
// }
//
// public static ModuleHandler getModuleHandler()
// {
// return proxy.moduleHandler;
// }
//
// @Mod.EventHandler
// public void preInit(final FMLPreInitializationEvent event)
// {
// logger = event.getModLog();
// proxy.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(final FMLInitializationEvent event)
// {
// proxy.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event)
// {
// proxy.postInit(event);
// }
//
// @Mod.EventHandler
// public void loadComplete(final FMLLoadCompleteEvent event)
// {
// proxy.loadComplete(event);
// proxy.clean();
// }
//
// @NetworkCheckHandler
// public boolean matchModVersions(final Map<String, String> remoteVersions, final Side side)
// {
// return side == Side.CLIENT ? remoteVersions.containsKey(MOD_ID) : !remoteVersions.containsKey(MOD_ID) || remoteVersions.get(MOD_ID).equals(MOD_VERSION);
// }
//
// public interface IDependency {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Module {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Integration {}
// }
//
// Path: src/main/java/wanion/unidict/common/Reference.java
// public final class Reference
// {
// public static final String MOD_ID = "unidict";
// public static final String MOD_NAME = "UniDict";
// public static final String MOD_VERSION = "@version@";
// public static final String DEPENDENCIES = "required-after:wanionlib@[1.12.2-2.5,);after:*";
// public static final char SLASH = separatorChar;
// public static final String MC_VERSION = "[1.12,]";
// public static final String CLIENT_PROXY = "wanion.unidict.proxy.ClientProxy";
// public static final String SERVER_PROXY = "wanion.unidict.proxy.CommonProxy";
//
// private Reference() {}
// }
// Path: src/main/java/wanion/unidict/integration/IntegrationModule.java
import net.minecraftforge.common.config.Configuration;
import org.apache.commons.lang3.text.WordUtils;
import wanion.lib.module.AbstractModule;
import wanion.unidict.UniDict;
import wanion.unidict.common.Reference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.util.LinkedHashSet;
import java.util.Set;
import static net.minecraftforge.fml.common.Loader.isModLoaded;
import static wanion.unidict.common.Reference.SLASH;
package wanion.unidict.integration;
/*
* Created by WanionCane(https://github.com/WanionCane).
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
public final class IntegrationModule extends AbstractModule implements UniDict.IDependency
{
private final Set<Class<AbstractIntegrationThread>> MOD_INTEGRATIONS = new LinkedHashSet<>();
public IntegrationModule()
{
super("Integration", Class::newInstance);
}
public static IntegrationModule getIntegrationModule()
{
return UniDict.getDependencies().get(IntegrationModule.class);
}
public void registerIntegration(@Nonnull final Class<AbstractIntegrationThread> integrationClassToRegister)
{
MOD_INTEGRATIONS.add(integrationClassToRegister);
}
@Override
protected void init()
{
|
final Configuration config = new Configuration(new File("." + SLASH + "config" + SLASH + Reference.MOD_ID + SLASH + "IntegrationModule.cfg"));
|
WanionCane/UniDict
|
src/main/java/wanion/unidict/modconfig/ModConfigModule.java
|
// Path: src/main/java/wanion/unidict/UniDict.java
// @SuppressWarnings("unused")
// @Mod(modid = MOD_ID, name = MOD_NAME, version = MOD_VERSION, acceptedMinecraftVersions = MC_VERSION, dependencies = DEPENDENCIES)
// public final class UniDict
// {
// @Mod.Instance(MOD_ID)
// public static UniDict instance;
//
// @SidedProxy(clientSide = CLIENT_PROXY, serverSide = SERVER_PROXY)
// public static CommonProxy proxy;
//
// private static Logger logger;
//
// public static Logger getLogger()
// {
// return logger;
// }
//
// public static Dependencies<IDependency> getDependencies()
// {
// return proxy.dependencies;
// }
//
// public static ResourceHandler getResourceHandler()
// {
// return proxy.dependencies.get(ResourceHandler.class);
// }
//
// public static UniOreDictionary getUniOreDictionary()
// {
// return proxy.dependencies.get(UniOreDictionary.class);
// }
//
// public static Config getConfig()
// {
// return Config.INSTANCE;
// }
//
// public static UniDictAPI getAPI()
// {
// return UniDictAPI.getInstance();
// }
//
// public static ModuleHandler getModuleHandler()
// {
// return proxy.moduleHandler;
// }
//
// @Mod.EventHandler
// public void preInit(final FMLPreInitializationEvent event)
// {
// logger = event.getModLog();
// proxy.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(final FMLInitializationEvent event)
// {
// proxy.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event)
// {
// proxy.postInit(event);
// }
//
// @Mod.EventHandler
// public void loadComplete(final FMLLoadCompleteEvent event)
// {
// proxy.loadComplete(event);
// proxy.clean();
// }
//
// @NetworkCheckHandler
// public boolean matchModVersions(final Map<String, String> remoteVersions, final Side side)
// {
// return side == Side.CLIENT ? remoteVersions.containsKey(MOD_ID) : !remoteVersions.containsKey(MOD_ID) || remoteVersions.get(MOD_ID).equals(MOD_VERSION);
// }
//
// public interface IDependency {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Module {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Integration {}
// }
//
// Path: src/main/java/wanion/unidict/common/Reference.java
// public final class Reference
// {
// public static final String MOD_ID = "unidict";
// public static final String MOD_NAME = "UniDict";
// public static final String MOD_VERSION = "@version@";
// public static final String DEPENDENCIES = "required-after:wanionlib@[1.12.2-2.5,);after:*";
// public static final char SLASH = separatorChar;
// public static final String MC_VERSION = "[1.12,]";
// public static final String CLIENT_PROXY = "wanion.unidict.proxy.ClientProxy";
// public static final String SERVER_PROXY = "wanion.unidict.proxy.CommonProxy";
//
// private Reference() {}
// }
|
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Loader;
import org.apache.commons.lang3.text.WordUtils;
import wanion.lib.module.AbstractModule;
import wanion.unidict.UniDict;
import wanion.unidict.common.Reference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import static wanion.unidict.common.Reference.SLASH;
|
package wanion.unidict.modconfig;
/*
* Created by ElektroKill(https://github.com/ElektroKill).
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
public class ModConfigModule extends AbstractModule implements UniDict.IDependency {
public ModConfigModule() { super("Mod Config", Class::newInstance); }
public static ModConfigModule getModConfigModule()
{
return UniDict.getDependencies().get(ModConfigModule.class);
}
@Override
protected void init() {
final Configuration config =
|
// Path: src/main/java/wanion/unidict/UniDict.java
// @SuppressWarnings("unused")
// @Mod(modid = MOD_ID, name = MOD_NAME, version = MOD_VERSION, acceptedMinecraftVersions = MC_VERSION, dependencies = DEPENDENCIES)
// public final class UniDict
// {
// @Mod.Instance(MOD_ID)
// public static UniDict instance;
//
// @SidedProxy(clientSide = CLIENT_PROXY, serverSide = SERVER_PROXY)
// public static CommonProxy proxy;
//
// private static Logger logger;
//
// public static Logger getLogger()
// {
// return logger;
// }
//
// public static Dependencies<IDependency> getDependencies()
// {
// return proxy.dependencies;
// }
//
// public static ResourceHandler getResourceHandler()
// {
// return proxy.dependencies.get(ResourceHandler.class);
// }
//
// public static UniOreDictionary getUniOreDictionary()
// {
// return proxy.dependencies.get(UniOreDictionary.class);
// }
//
// public static Config getConfig()
// {
// return Config.INSTANCE;
// }
//
// public static UniDictAPI getAPI()
// {
// return UniDictAPI.getInstance();
// }
//
// public static ModuleHandler getModuleHandler()
// {
// return proxy.moduleHandler;
// }
//
// @Mod.EventHandler
// public void preInit(final FMLPreInitializationEvent event)
// {
// logger = event.getModLog();
// proxy.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(final FMLInitializationEvent event)
// {
// proxy.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event)
// {
// proxy.postInit(event);
// }
//
// @Mod.EventHandler
// public void loadComplete(final FMLLoadCompleteEvent event)
// {
// proxy.loadComplete(event);
// proxy.clean();
// }
//
// @NetworkCheckHandler
// public boolean matchModVersions(final Map<String, String> remoteVersions, final Side side)
// {
// return side == Side.CLIENT ? remoteVersions.containsKey(MOD_ID) : !remoteVersions.containsKey(MOD_ID) || remoteVersions.get(MOD_ID).equals(MOD_VERSION);
// }
//
// public interface IDependency {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Module {}
//
// @Retention(RetentionPolicy.RUNTIME)
// @Target(ElementType.TYPE)
// public @interface Integration {}
// }
//
// Path: src/main/java/wanion/unidict/common/Reference.java
// public final class Reference
// {
// public static final String MOD_ID = "unidict";
// public static final String MOD_NAME = "UniDict";
// public static final String MOD_VERSION = "@version@";
// public static final String DEPENDENCIES = "required-after:wanionlib@[1.12.2-2.5,);after:*";
// public static final char SLASH = separatorChar;
// public static final String MC_VERSION = "[1.12,]";
// public static final String CLIENT_PROXY = "wanion.unidict.proxy.ClientProxy";
// public static final String SERVER_PROXY = "wanion.unidict.proxy.CommonProxy";
//
// private Reference() {}
// }
// Path: src/main/java/wanion/unidict/modconfig/ModConfigModule.java
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Loader;
import org.apache.commons.lang3.text.WordUtils;
import wanion.lib.module.AbstractModule;
import wanion.unidict.UniDict;
import wanion.unidict.common.Reference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import static wanion.unidict.common.Reference.SLASH;
package wanion.unidict.modconfig;
/*
* Created by ElektroKill(https://github.com/ElektroKill).
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
public class ModConfigModule extends AbstractModule implements UniDict.IDependency {
public ModConfigModule() { super("Mod Config", Class::newInstance); }
public static ModConfigModule getModConfigModule()
{
return UniDict.getDependencies().get(ModConfigModule.class);
}
@Override
protected void init() {
final Configuration config =
|
new Configuration(new File("." + SLASH + "config" + SLASH + Reference.MOD_ID + SLASH + "ModConfigModule.cfg"));
|
WanionCane/UniDict
|
src/main/java/wanion/unidict/Config.java
|
// Path: src/main/java/wanion/unidict/common/Reference.java
// public final class Reference
// {
// public static final String MOD_ID = "unidict";
// public static final String MOD_NAME = "UniDict";
// public static final String MOD_VERSION = "@version@";
// public static final String DEPENDENCIES = "required-after:wanionlib@[1.12.2-2.5,);after:*";
// public static final char SLASH = separatorChar;
// public static final String MC_VERSION = "[1.12,]";
// public static final String CLIENT_PROXY = "wanion.unidict.proxy.ClientProxy";
// public static final String SERVER_PROXY = "wanion.unidict.proxy.CommonProxy";
//
// private Reference() {}
// }
|
import com.google.common.collect.Sets;
import gnu.trove.map.TObjectIntMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TObjectIntHashMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.config.Configuration;
import wanion.unidict.common.Reference;
import java.io.File;
import java.util.*;
import java.util.regex.Pattern;
import static net.minecraftforge.fml.common.Loader.isModLoaded;
import static wanion.unidict.common.Reference.SLASH;
|
// resource related stuff
public final boolean enableSpecificKindSort;
public final boolean enableSpecificEntrySort;
public final TObjectIntMap<String> ownerOfEveryThing;
public final Set<String> metalsToUnify;
public final Set<String> childrenOfMetals;
public final List<String> resourceBlackList;
public final Set<ResourceLocation> recipesToIgnore;
public final List<String> furnaceInputsToIgnore;
public final List<String> furnaceOutputsToIgnore;
public final Boolean treatRecipesToRemoveAsRegex;
public final List<String> recipesToRemove;
public final Set<String> ignoreModIdRecipes;
public final Map<String, Set<String>> customUnifiedResources;
// integration specific configs:
public final boolean ieIntegrationDuplicateRemoval;
// userEntries
public final List<String> userOreDictEntries;
// modules
public final boolean integrationModule;
public final boolean modConfigModule;
// config
private final Configuration config;
// resource related stuff
private final String resources = "resources";
private Config()
{
boolean deleted = false;
|
// Path: src/main/java/wanion/unidict/common/Reference.java
// public final class Reference
// {
// public static final String MOD_ID = "unidict";
// public static final String MOD_NAME = "UniDict";
// public static final String MOD_VERSION = "@version@";
// public static final String DEPENDENCIES = "required-after:wanionlib@[1.12.2-2.5,);after:*";
// public static final char SLASH = separatorChar;
// public static final String MC_VERSION = "[1.12,]";
// public static final String CLIENT_PROXY = "wanion.unidict.proxy.ClientProxy";
// public static final String SERVER_PROXY = "wanion.unidict.proxy.CommonProxy";
//
// private Reference() {}
// }
// Path: src/main/java/wanion/unidict/Config.java
import com.google.common.collect.Sets;
import gnu.trove.map.TObjectIntMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TObjectIntHashMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.config.Configuration;
import wanion.unidict.common.Reference;
import java.io.File;
import java.util.*;
import java.util.regex.Pattern;
import static net.minecraftforge.fml.common.Loader.isModLoaded;
import static wanion.unidict.common.Reference.SLASH;
// resource related stuff
public final boolean enableSpecificKindSort;
public final boolean enableSpecificEntrySort;
public final TObjectIntMap<String> ownerOfEveryThing;
public final Set<String> metalsToUnify;
public final Set<String> childrenOfMetals;
public final List<String> resourceBlackList;
public final Set<ResourceLocation> recipesToIgnore;
public final List<String> furnaceInputsToIgnore;
public final List<String> furnaceOutputsToIgnore;
public final Boolean treatRecipesToRemoveAsRegex;
public final List<String> recipesToRemove;
public final Set<String> ignoreModIdRecipes;
public final Map<String, Set<String>> customUnifiedResources;
// integration specific configs:
public final boolean ieIntegrationDuplicateRemoval;
// userEntries
public final List<String> userOreDictEntries;
// modules
public final boolean integrationModule;
public final boolean modConfigModule;
// config
private final Configuration config;
// resource related stuff
private final String resources = "resources";
private Config()
{
boolean deleted = false;
|
config = new Configuration(new File("." + SLASH + "config" + SLASH + Reference.MOD_ID + SLASH + Reference.MOD_NAME + ".cfg"), Reference.MOD_VERSION);
|
Vantiq/vantiq-sdk-java
|
examples/JavaProntoClient/src/main/java/io/vantiq/prontoClient/SubscriptionOutputCallback.java
|
// Path: src/main/java/io/vantiq/client/SubscriptionCallback.java
// public interface SubscriptionCallback {
//
// /**
// * Called once the connection has been established and the
// * subscription has been acknowledged by the Vantiq server.
// */
// void onConnect();
//
// /**
// * Called for every matching event that occurs
// *
// * @param message The information associated with the event
// */
// void onMessage(SubscriptionMessage message);
//
// /**
// * Called whenever an error occurs that does not arise from
// * an exception, such as if a non-success response is provided.
// *
// * @param error The error message
// */
// void onError(String error);
//
// /**
// * Called whenever an exception occurs during the subscription
// * processing.
// *
// * @param t The exception thrown
// */
// void onFailure(Throwable t);
// }
//
// Path: src/main/java/io/vantiq/client/SubscriptionMessage.java
// public class SubscriptionMessage {
//
// private int status;
// private String contentType;
// private Map<String, String> headers;
// private Object body;
//
// /**
// * The HTTP status code for this message. Usually, this is 100.
// *
// * @return The status code for the message
// */
// public int getStatus() {
// return status;
// }
//
// /**
// * The content type for the body of the message. Usually, this is
// * application/json indicating the content was JSON encoded.
// *
// * @return The MIME type for the message body
// */
// public String getContentType() {
// return contentType;
// }
//
// /**
// * The headers associated with the message.
// *
// * @return The headers for the message.
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * Returns the payload for the message. For a JSON encoded
// * message, this would be a Map.
// *
// * @return The body of the message.
// */
// public Object getBody() {
// return body;
// }
//
// public String toString() {
// StringBuilder sb = new StringBuilder("SubscriptionMessage[\n");
// sb.append(" status:").append(this.status).append('\n');
// sb.append(" contentType:").append(this.contentType).append('\n');
// sb.append(" headers:").append(this.headers).append('\n');
// sb.append(" body:").append(this.body).append('\n');
// sb.append(']');
// return sb.toString();
// }
// }
|
import java.io.IOException;
import javax.websocket.Session;
import com.google.gson.internal.LinkedTreeMap;
import io.vantiq.client.SubscriptionCallback;
import io.vantiq.client.SubscriptionMessage;
import io.vantiq.prontoClient.servlet.*;
|
package io.vantiq.prontoClient;
public class SubscriptionOutputCallback implements SubscriptionCallback {
// Websocket session used to send messages to client
Session wsSession;
String sessionID;
public SubscriptionOutputCallback(String sessionID) {
this.sessionID = sessionID;
}
@Override
public void onConnect() {
// (Uncomment to debug)
//System.out.println("Connected Successfully");
}
@Override
|
// Path: src/main/java/io/vantiq/client/SubscriptionCallback.java
// public interface SubscriptionCallback {
//
// /**
// * Called once the connection has been established and the
// * subscription has been acknowledged by the Vantiq server.
// */
// void onConnect();
//
// /**
// * Called for every matching event that occurs
// *
// * @param message The information associated with the event
// */
// void onMessage(SubscriptionMessage message);
//
// /**
// * Called whenever an error occurs that does not arise from
// * an exception, such as if a non-success response is provided.
// *
// * @param error The error message
// */
// void onError(String error);
//
// /**
// * Called whenever an exception occurs during the subscription
// * processing.
// *
// * @param t The exception thrown
// */
// void onFailure(Throwable t);
// }
//
// Path: src/main/java/io/vantiq/client/SubscriptionMessage.java
// public class SubscriptionMessage {
//
// private int status;
// private String contentType;
// private Map<String, String> headers;
// private Object body;
//
// /**
// * The HTTP status code for this message. Usually, this is 100.
// *
// * @return The status code for the message
// */
// public int getStatus() {
// return status;
// }
//
// /**
// * The content type for the body of the message. Usually, this is
// * application/json indicating the content was JSON encoded.
// *
// * @return The MIME type for the message body
// */
// public String getContentType() {
// return contentType;
// }
//
// /**
// * The headers associated with the message.
// *
// * @return The headers for the message.
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * Returns the payload for the message. For a JSON encoded
// * message, this would be a Map.
// *
// * @return The body of the message.
// */
// public Object getBody() {
// return body;
// }
//
// public String toString() {
// StringBuilder sb = new StringBuilder("SubscriptionMessage[\n");
// sb.append(" status:").append(this.status).append('\n');
// sb.append(" contentType:").append(this.contentType).append('\n');
// sb.append(" headers:").append(this.headers).append('\n');
// sb.append(" body:").append(this.body).append('\n');
// sb.append(']');
// return sb.toString();
// }
// }
// Path: examples/JavaProntoClient/src/main/java/io/vantiq/prontoClient/SubscriptionOutputCallback.java
import java.io.IOException;
import javax.websocket.Session;
import com.google.gson.internal.LinkedTreeMap;
import io.vantiq.client.SubscriptionCallback;
import io.vantiq.client.SubscriptionMessage;
import io.vantiq.prontoClient.servlet.*;
package io.vantiq.prontoClient;
public class SubscriptionOutputCallback implements SubscriptionCallback {
// Websocket session used to send messages to client
Session wsSession;
String sessionID;
public SubscriptionOutputCallback(String sessionID) {
this.sessionID = sessionID;
}
@Override
public void onConnect() {
// (Uncomment to debug)
//System.out.println("Connected Successfully");
}
@Override
|
public void onMessage(SubscriptionMessage message) {
|
Vantiq/vantiq-sdk-java
|
src/main/java/io/vantiq/client/internal/VantiqSubscriber.java
|
// Path: src/main/java/io/vantiq/client/SubscriptionCallback.java
// public interface SubscriptionCallback {
//
// /**
// * Called once the connection has been established and the
// * subscription has been acknowledged by the Vantiq server.
// */
// void onConnect();
//
// /**
// * Called for every matching event that occurs
// *
// * @param message The information associated with the event
// */
// void onMessage(SubscriptionMessage message);
//
// /**
// * Called whenever an error occurs that does not arise from
// * an exception, such as if a non-success response is provided.
// *
// * @param error The error message
// */
// void onError(String error);
//
// /**
// * Called whenever an exception occurs during the subscription
// * processing.
// *
// * @param t The exception thrown
// */
// void onFailure(Throwable t);
// }
//
// Path: src/main/java/io/vantiq/client/SubscriptionMessage.java
// public class SubscriptionMessage {
//
// private int status;
// private String contentType;
// private Map<String, String> headers;
// private Object body;
//
// /**
// * The HTTP status code for this message. Usually, this is 100.
// *
// * @return The status code for the message
// */
// public int getStatus() {
// return status;
// }
//
// /**
// * The content type for the body of the message. Usually, this is
// * application/json indicating the content was JSON encoded.
// *
// * @return The MIME type for the message body
// */
// public String getContentType() {
// return contentType;
// }
//
// /**
// * The headers associated with the message.
// *
// * @return The headers for the message.
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * Returns the payload for the message. For a JSON encoded
// * message, this would be a Map.
// *
// * @return The body of the message.
// */
// public Object getBody() {
// return body;
// }
//
// public String toString() {
// StringBuilder sb = new StringBuilder("SubscriptionMessage[\n");
// sb.append(" status:").append(this.status).append('\n');
// sb.append(" contentType:").append(this.contentType).append('\n');
// sb.append(" headers:").append(this.headers).append('\n');
// sb.append(" body:").append(this.body).append('\n');
// sb.append(']');
// return sb.toString();
// }
// }
|
import io.vantiq.client.SubscriptionCallback;
import io.vantiq.client.SubscriptionMessage;
import okhttp3.*;
import okio.Buffer;
import okio.ByteString;
import org.jetbrains.annotations.NotNull;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
|
package io.vantiq.client.internal;
/**
* Internal class that manages subscriptions to a Vantiq server.
*/
public class VantiqSubscriber extends WebSocketListener {
private VantiqSession session = null;
private OkHttpClient client = null;
private WebSocket webSocket = null;
private VantiqSubscriberLifecycleListener lifecycleHandler = null;
private boolean enablePings = false;
private ScheduledExecutorService scheduledExecutor = null;
private ScheduledFuture pingerHandle = null;
private boolean wsauthenticated = false;
|
// Path: src/main/java/io/vantiq/client/SubscriptionCallback.java
// public interface SubscriptionCallback {
//
// /**
// * Called once the connection has been established and the
// * subscription has been acknowledged by the Vantiq server.
// */
// void onConnect();
//
// /**
// * Called for every matching event that occurs
// *
// * @param message The information associated with the event
// */
// void onMessage(SubscriptionMessage message);
//
// /**
// * Called whenever an error occurs that does not arise from
// * an exception, such as if a non-success response is provided.
// *
// * @param error The error message
// */
// void onError(String error);
//
// /**
// * Called whenever an exception occurs during the subscription
// * processing.
// *
// * @param t The exception thrown
// */
// void onFailure(Throwable t);
// }
//
// Path: src/main/java/io/vantiq/client/SubscriptionMessage.java
// public class SubscriptionMessage {
//
// private int status;
// private String contentType;
// private Map<String, String> headers;
// private Object body;
//
// /**
// * The HTTP status code for this message. Usually, this is 100.
// *
// * @return The status code for the message
// */
// public int getStatus() {
// return status;
// }
//
// /**
// * The content type for the body of the message. Usually, this is
// * application/json indicating the content was JSON encoded.
// *
// * @return The MIME type for the message body
// */
// public String getContentType() {
// return contentType;
// }
//
// /**
// * The headers associated with the message.
// *
// * @return The headers for the message.
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * Returns the payload for the message. For a JSON encoded
// * message, this would be a Map.
// *
// * @return The body of the message.
// */
// public Object getBody() {
// return body;
// }
//
// public String toString() {
// StringBuilder sb = new StringBuilder("SubscriptionMessage[\n");
// sb.append(" status:").append(this.status).append('\n');
// sb.append(" contentType:").append(this.contentType).append('\n');
// sb.append(" headers:").append(this.headers).append('\n');
// sb.append(" body:").append(this.body).append('\n');
// sb.append(']');
// return sb.toString();
// }
// }
// Path: src/main/java/io/vantiq/client/internal/VantiqSubscriber.java
import io.vantiq.client.SubscriptionCallback;
import io.vantiq.client.SubscriptionMessage;
import okhttp3.*;
import okio.Buffer;
import okio.ByteString;
import org.jetbrains.annotations.NotNull;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
package io.vantiq.client.internal;
/**
* Internal class that manages subscriptions to a Vantiq server.
*/
public class VantiqSubscriber extends WebSocketListener {
private VantiqSession session = null;
private OkHttpClient client = null;
private WebSocket webSocket = null;
private VantiqSubscriberLifecycleListener lifecycleHandler = null;
private boolean enablePings = false;
private ScheduledExecutorService scheduledExecutor = null;
private ScheduledFuture pingerHandle = null;
private boolean wsauthenticated = false;
|
private Map<String,SubscriptionCallback> callbacks = new HashMap<String,SubscriptionCallback>();
|
Vantiq/vantiq-sdk-java
|
src/main/java/io/vantiq/client/internal/VantiqSubscriber.java
|
// Path: src/main/java/io/vantiq/client/SubscriptionCallback.java
// public interface SubscriptionCallback {
//
// /**
// * Called once the connection has been established and the
// * subscription has been acknowledged by the Vantiq server.
// */
// void onConnect();
//
// /**
// * Called for every matching event that occurs
// *
// * @param message The information associated with the event
// */
// void onMessage(SubscriptionMessage message);
//
// /**
// * Called whenever an error occurs that does not arise from
// * an exception, such as if a non-success response is provided.
// *
// * @param error The error message
// */
// void onError(String error);
//
// /**
// * Called whenever an exception occurs during the subscription
// * processing.
// *
// * @param t The exception thrown
// */
// void onFailure(Throwable t);
// }
//
// Path: src/main/java/io/vantiq/client/SubscriptionMessage.java
// public class SubscriptionMessage {
//
// private int status;
// private String contentType;
// private Map<String, String> headers;
// private Object body;
//
// /**
// * The HTTP status code for this message. Usually, this is 100.
// *
// * @return The status code for the message
// */
// public int getStatus() {
// return status;
// }
//
// /**
// * The content type for the body of the message. Usually, this is
// * application/json indicating the content was JSON encoded.
// *
// * @return The MIME type for the message body
// */
// public String getContentType() {
// return contentType;
// }
//
// /**
// * The headers associated with the message.
// *
// * @return The headers for the message.
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * Returns the payload for the message. For a JSON encoded
// * message, this would be a Map.
// *
// * @return The body of the message.
// */
// public Object getBody() {
// return body;
// }
//
// public String toString() {
// StringBuilder sb = new StringBuilder("SubscriptionMessage[\n");
// sb.append(" status:").append(this.status).append('\n');
// sb.append(" contentType:").append(this.contentType).append('\n');
// sb.append(" headers:").append(this.headers).append('\n');
// sb.append(" body:").append(this.body).append('\n');
// sb.append(']');
// return sb.toString();
// }
// }
|
import io.vantiq.client.SubscriptionCallback;
import io.vantiq.client.SubscriptionMessage;
import okhttp3.*;
import okio.Buffer;
import okio.ByteString;
import org.jetbrains.annotations.NotNull;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
|
}
public void startPeriodicPings() {
this.pingerHandle =
this.scheduledExecutor.scheduleAtFixedRate(new WebSockerPinger(),
0, 30, TimeUnit.SECONDS);
}
@Override
public void onOpen(WebSocket webSocket, Response response) {
this.webSocket = webSocket;
//
// Once the socket is open, we first need to validate the token
// to create an authenticated session
//
ValidateAuthenticationRequest request =
new ValidateAuthenticationRequest(this.session.getAccessToken());
String body = VantiqSession.gson.toJson(request);
this.webSocket.send(body);
}
@Override
public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t, Response response) {
this.lifecycleHandler.onFailure(t);
}
@Override
public void onMessage(@NotNull WebSocket webSocket, ByteString bodyBytes) {
String bodyStr = bodyBytes.utf8();
|
// Path: src/main/java/io/vantiq/client/SubscriptionCallback.java
// public interface SubscriptionCallback {
//
// /**
// * Called once the connection has been established and the
// * subscription has been acknowledged by the Vantiq server.
// */
// void onConnect();
//
// /**
// * Called for every matching event that occurs
// *
// * @param message The information associated with the event
// */
// void onMessage(SubscriptionMessage message);
//
// /**
// * Called whenever an error occurs that does not arise from
// * an exception, such as if a non-success response is provided.
// *
// * @param error The error message
// */
// void onError(String error);
//
// /**
// * Called whenever an exception occurs during the subscription
// * processing.
// *
// * @param t The exception thrown
// */
// void onFailure(Throwable t);
// }
//
// Path: src/main/java/io/vantiq/client/SubscriptionMessage.java
// public class SubscriptionMessage {
//
// private int status;
// private String contentType;
// private Map<String, String> headers;
// private Object body;
//
// /**
// * The HTTP status code for this message. Usually, this is 100.
// *
// * @return The status code for the message
// */
// public int getStatus() {
// return status;
// }
//
// /**
// * The content type for the body of the message. Usually, this is
// * application/json indicating the content was JSON encoded.
// *
// * @return The MIME type for the message body
// */
// public String getContentType() {
// return contentType;
// }
//
// /**
// * The headers associated with the message.
// *
// * @return The headers for the message.
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * Returns the payload for the message. For a JSON encoded
// * message, this would be a Map.
// *
// * @return The body of the message.
// */
// public Object getBody() {
// return body;
// }
//
// public String toString() {
// StringBuilder sb = new StringBuilder("SubscriptionMessage[\n");
// sb.append(" status:").append(this.status).append('\n');
// sb.append(" contentType:").append(this.contentType).append('\n');
// sb.append(" headers:").append(this.headers).append('\n');
// sb.append(" body:").append(this.body).append('\n');
// sb.append(']');
// return sb.toString();
// }
// }
// Path: src/main/java/io/vantiq/client/internal/VantiqSubscriber.java
import io.vantiq.client.SubscriptionCallback;
import io.vantiq.client.SubscriptionMessage;
import okhttp3.*;
import okio.Buffer;
import okio.ByteString;
import org.jetbrains.annotations.NotNull;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
}
public void startPeriodicPings() {
this.pingerHandle =
this.scheduledExecutor.scheduleAtFixedRate(new WebSockerPinger(),
0, 30, TimeUnit.SECONDS);
}
@Override
public void onOpen(WebSocket webSocket, Response response) {
this.webSocket = webSocket;
//
// Once the socket is open, we first need to validate the token
// to create an authenticated session
//
ValidateAuthenticationRequest request =
new ValidateAuthenticationRequest(this.session.getAccessToken());
String body = VantiqSession.gson.toJson(request);
this.webSocket.send(body);
}
@Override
public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t, Response response) {
this.lifecycleHandler.onFailure(t);
}
@Override
public void onMessage(@NotNull WebSocket webSocket, ByteString bodyBytes) {
String bodyStr = bodyBytes.utf8();
|
SubscriptionMessage msg =
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/menu/CreditsLayer.java
|
// Path: core/src/com/alexaut/kroniax/menu/Gui.java
// public enum Layer {
// MAIN, LEVEL_SELECTION, SETTINGS, CREDITS
// }
|
import com.alexaut.kroniax.menu.Gui.Layer;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
package com.alexaut.kroniax.menu;
public class CreditsLayer extends Table {
public CreditsLayer(final Gui gui) {
super();
setFillParent(true);
setPosition(1280, 0);
Label label = new Label("Programmed by Alexander Weinrauch", gui.getSkin());
add(label);
row().padTop(40.f);
label = new Label("Special thanks to the creator of LibGDX", gui.getSkin());
add(label);
row();
label = new Label("Mario Zechner!", gui.getSkin());
add(label);
row().padTop(40.f);
label = new Label("Music created by MafiaFlairBeats", gui.getSkin());
add(label);
row().padTop(40.f);
label = new Label("Thanks to Micheal Goessler and Stefan Papst for playtesting", gui.getSkin());
add(label);
row().padTop(100.f);
// Back button, add credits above!
TextButton bt = new TextButton("Back", gui.getSkin());
bt.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
int direction = 1280;
|
// Path: core/src/com/alexaut/kroniax/menu/Gui.java
// public enum Layer {
// MAIN, LEVEL_SELECTION, SETTINGS, CREDITS
// }
// Path: core/src/com/alexaut/kroniax/menu/CreditsLayer.java
import com.alexaut.kroniax.menu.Gui.Layer;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
package com.alexaut.kroniax.menu;
public class CreditsLayer extends Table {
public CreditsLayer(final Gui gui) {
super();
setFillParent(true);
setPosition(1280, 0);
Label label = new Label("Programmed by Alexander Weinrauch", gui.getSkin());
add(label);
row().padTop(40.f);
label = new Label("Special thanks to the creator of LibGDX", gui.getSkin());
add(label);
row();
label = new Label("Mario Zechner!", gui.getSkin());
add(label);
row().padTop(40.f);
label = new Label("Music created by MafiaFlairBeats", gui.getSkin());
add(label);
row().padTop(40.f);
label = new Label("Thanks to Micheal Goessler and Stefan Papst for playtesting", gui.getSkin());
add(label);
row().padTop(100.f);
// Back button, add credits above!
TextButton bt = new TextButton("Back", gui.getSkin());
bt.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
int direction = 1280;
|
if (gui.getLayer(Layer.MAIN).getX() > 0)
|
AlexAUT/Kroniax
|
html/src/com/alexaut/kroniax/client/HtmlLauncher.java
|
// Path: core/src/com/alexaut/kroniax/Application.java
// public class Application extends Game {
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// private Skin mSkin;
//
// private ProgressManager mProgressManager;
// private Preferences mSettings;
//
// private MenuScene mMenuScene;
//
// @Override
// public void create() {
// mSpriteBatch = new SpriteBatch();
// mShapeRenderer = new ShapeRenderer();
// mSkin = new Skin(Gdx.files.internal("data/skins/menu.json"));
// mProgressManager = new ProgressManager();
// mSettings = Gdx.app.getPreferences("settings");
//
// mMenuScene = new MenuScene(this);
//
// setScreen(mMenuScene);
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// super.dispose();
// mSpriteBatch.dispose();
// mShapeRenderer.dispose();
// mMenuScene.dispose();
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// super.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// super.resume();
// }
//
// @Override
// public void render() {
//
// // TODO Auto-generated method stub
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
// super.resize(width, height);
// }
//
// public SpriteBatch getSpriteBatch() {
// return mSpriteBatch;
// }
//
// public ShapeRenderer getShapeRenderer() {
// return mShapeRenderer;
// }
//
// public Skin getGuiSkin() {
// return mSkin;
// }
//
// public ProgressManager getProgressManager() {
// return mProgressManager;
// }
//
// public MenuScene getMenuScene() {
// return mMenuScene;
// }
//
// public void toogleMusicEnabled() {
// boolean current = mSettings.getBoolean("music", true);
// mSettings.putBoolean("music", !current);
// mSettings.flush();
// mMenuScene.updateMusicState();
// }
//
// public boolean isMusicEnabled() {
// return mSettings.getBoolean("music", true);
// }
//
// }
|
import com.alexaut.kroniax.Application;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
|
package com.alexaut.kroniax.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig() {
GwtApplicationConfiguration config = new GwtApplicationConfiguration(1280, 720);
config.antialiasing = true;
return config;
}
@Override
public ApplicationListener getApplicationListener() {
|
// Path: core/src/com/alexaut/kroniax/Application.java
// public class Application extends Game {
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// private Skin mSkin;
//
// private ProgressManager mProgressManager;
// private Preferences mSettings;
//
// private MenuScene mMenuScene;
//
// @Override
// public void create() {
// mSpriteBatch = new SpriteBatch();
// mShapeRenderer = new ShapeRenderer();
// mSkin = new Skin(Gdx.files.internal("data/skins/menu.json"));
// mProgressManager = new ProgressManager();
// mSettings = Gdx.app.getPreferences("settings");
//
// mMenuScene = new MenuScene(this);
//
// setScreen(mMenuScene);
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// super.dispose();
// mSpriteBatch.dispose();
// mShapeRenderer.dispose();
// mMenuScene.dispose();
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// super.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// super.resume();
// }
//
// @Override
// public void render() {
//
// // TODO Auto-generated method stub
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
// super.resize(width, height);
// }
//
// public SpriteBatch getSpriteBatch() {
// return mSpriteBatch;
// }
//
// public ShapeRenderer getShapeRenderer() {
// return mShapeRenderer;
// }
//
// public Skin getGuiSkin() {
// return mSkin;
// }
//
// public ProgressManager getProgressManager() {
// return mProgressManager;
// }
//
// public MenuScene getMenuScene() {
// return mMenuScene;
// }
//
// public void toogleMusicEnabled() {
// boolean current = mSettings.getBoolean("music", true);
// mSettings.putBoolean("music", !current);
// mSettings.flush();
// mMenuScene.updateMusicState();
// }
//
// public boolean isMusicEnabled() {
// return mSettings.getBoolean("music", true);
// }
//
// }
// Path: html/src/com/alexaut/kroniax/client/HtmlLauncher.java
import com.alexaut.kroniax.Application;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
package com.alexaut.kroniax.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig() {
GwtApplicationConfiguration config = new GwtApplicationConfiguration(1280, 720);
config.antialiasing = true;
return config;
}
@Override
public ApplicationListener getApplicationListener() {
|
return new Application();
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/game/tilemap/TileMap.java
|
// Path: core/src/com/alexaut/kroniax/game/level/LevelObject.java
// public abstract class LevelObject {
// private String mType;
//
// private final Color mColor;
//
// protected LevelObject(String type) {
// mType = type;
// mColor = getColorFromType();
// }
//
// // Override these
// public abstract boolean checkCollision(Vector2 p1, Vector2 p2);
//
// public abstract void render(ShapeRenderer renderer);
//
// public String getType() {
// return mType;
// }
//
// public Color getColor() {
// return mColor;
// }
//
// private Color getColorFromType() {
// if (mType.equalsIgnoreCase("finish"))
// return Color.GREEN;
// else if (mType.equalsIgnoreCase("speed_change"))
// return Color.CYAN;
// else if (mType.equalsIgnoreCase("gravity_change"))
// return Color.YELLOW;
// else if (mType.equalsIgnoreCase("checkpoint"))
// return Color.ORANGE;
// else if (mType.equalsIgnoreCase("modal_text"))
// return new Color(0, 0, 0, 0);
// else if (mType.equalsIgnoreCase("size_change"))
// return Color.DARK_GRAY;
// else if (mType.equalsIgnoreCase("camera_rotate"))
// return Color.GOLD;
//
// return Color.WHITE;
// }
// }
//
// Path: core/src/com/alexaut/kroniax/game/scripts/Script.java
// public abstract class Script {
// private boolean mRunning;
// private boolean mStarted;
//
// public Script() {
// mRunning = false;
// mStarted = false;
// }
//
// public boolean isAlive() {
// return mRunning;
// }
//
// public void start() {
// mRunning = true;
// mStarted = true;
// }
//
// public void stop() {
// mRunning = false;
// mStarted = true;
// }
//
// public void reset() {
// mRunning = false;
// mStarted = false;
// }
//
// public boolean alreadyStarted() {
// return mStarted;
// }
//
// public abstract void update(float deltaTime, GameController gameController, Level level, Player player,
// Camera camera);
// }
|
import java.util.ArrayList;
import com.alexaut.kroniax.game.level.LevelObject;
import com.alexaut.kroniax.game.scripts.Script;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
package com.alexaut.kroniax.game.tilemap;
public class TileMap {
private Properties mProperties;
private ArrayList<Tileset> mTilesets;
private ArrayList<TileLayer> mTileLayers;
|
// Path: core/src/com/alexaut/kroniax/game/level/LevelObject.java
// public abstract class LevelObject {
// private String mType;
//
// private final Color mColor;
//
// protected LevelObject(String type) {
// mType = type;
// mColor = getColorFromType();
// }
//
// // Override these
// public abstract boolean checkCollision(Vector2 p1, Vector2 p2);
//
// public abstract void render(ShapeRenderer renderer);
//
// public String getType() {
// return mType;
// }
//
// public Color getColor() {
// return mColor;
// }
//
// private Color getColorFromType() {
// if (mType.equalsIgnoreCase("finish"))
// return Color.GREEN;
// else if (mType.equalsIgnoreCase("speed_change"))
// return Color.CYAN;
// else if (mType.equalsIgnoreCase("gravity_change"))
// return Color.YELLOW;
// else if (mType.equalsIgnoreCase("checkpoint"))
// return Color.ORANGE;
// else if (mType.equalsIgnoreCase("modal_text"))
// return new Color(0, 0, 0, 0);
// else if (mType.equalsIgnoreCase("size_change"))
// return Color.DARK_GRAY;
// else if (mType.equalsIgnoreCase("camera_rotate"))
// return Color.GOLD;
//
// return Color.WHITE;
// }
// }
//
// Path: core/src/com/alexaut/kroniax/game/scripts/Script.java
// public abstract class Script {
// private boolean mRunning;
// private boolean mStarted;
//
// public Script() {
// mRunning = false;
// mStarted = false;
// }
//
// public boolean isAlive() {
// return mRunning;
// }
//
// public void start() {
// mRunning = true;
// mStarted = true;
// }
//
// public void stop() {
// mRunning = false;
// mStarted = true;
// }
//
// public void reset() {
// mRunning = false;
// mStarted = false;
// }
//
// public boolean alreadyStarted() {
// return mStarted;
// }
//
// public abstract void update(float deltaTime, GameController gameController, Level level, Player player,
// Camera camera);
// }
// Path: core/src/com/alexaut/kroniax/game/tilemap/TileMap.java
import java.util.ArrayList;
import com.alexaut.kroniax.game.level.LevelObject;
import com.alexaut.kroniax.game.scripts.Script;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
package com.alexaut.kroniax.game.tilemap;
public class TileMap {
private Properties mProperties;
private ArrayList<Tileset> mTilesets;
private ArrayList<TileLayer> mTileLayers;
|
private ArrayList<LevelObject> mLevelObjects;
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/game/tilemap/TileMap.java
|
// Path: core/src/com/alexaut/kroniax/game/level/LevelObject.java
// public abstract class LevelObject {
// private String mType;
//
// private final Color mColor;
//
// protected LevelObject(String type) {
// mType = type;
// mColor = getColorFromType();
// }
//
// // Override these
// public abstract boolean checkCollision(Vector2 p1, Vector2 p2);
//
// public abstract void render(ShapeRenderer renderer);
//
// public String getType() {
// return mType;
// }
//
// public Color getColor() {
// return mColor;
// }
//
// private Color getColorFromType() {
// if (mType.equalsIgnoreCase("finish"))
// return Color.GREEN;
// else if (mType.equalsIgnoreCase("speed_change"))
// return Color.CYAN;
// else if (mType.equalsIgnoreCase("gravity_change"))
// return Color.YELLOW;
// else if (mType.equalsIgnoreCase("checkpoint"))
// return Color.ORANGE;
// else if (mType.equalsIgnoreCase("modal_text"))
// return new Color(0, 0, 0, 0);
// else if (mType.equalsIgnoreCase("size_change"))
// return Color.DARK_GRAY;
// else if (mType.equalsIgnoreCase("camera_rotate"))
// return Color.GOLD;
//
// return Color.WHITE;
// }
// }
//
// Path: core/src/com/alexaut/kroniax/game/scripts/Script.java
// public abstract class Script {
// private boolean mRunning;
// private boolean mStarted;
//
// public Script() {
// mRunning = false;
// mStarted = false;
// }
//
// public boolean isAlive() {
// return mRunning;
// }
//
// public void start() {
// mRunning = true;
// mStarted = true;
// }
//
// public void stop() {
// mRunning = false;
// mStarted = true;
// }
//
// public void reset() {
// mRunning = false;
// mStarted = false;
// }
//
// public boolean alreadyStarted() {
// return mStarted;
// }
//
// public abstract void update(float deltaTime, GameController gameController, Level level, Player player,
// Camera camera);
// }
|
import java.util.ArrayList;
import com.alexaut.kroniax.game.level.LevelObject;
import com.alexaut.kroniax.game.scripts.Script;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
package com.alexaut.kroniax.game.tilemap;
public class TileMap {
private Properties mProperties;
private ArrayList<Tileset> mTilesets;
private ArrayList<TileLayer> mTileLayers;
private ArrayList<LevelObject> mLevelObjects;
|
// Path: core/src/com/alexaut/kroniax/game/level/LevelObject.java
// public abstract class LevelObject {
// private String mType;
//
// private final Color mColor;
//
// protected LevelObject(String type) {
// mType = type;
// mColor = getColorFromType();
// }
//
// // Override these
// public abstract boolean checkCollision(Vector2 p1, Vector2 p2);
//
// public abstract void render(ShapeRenderer renderer);
//
// public String getType() {
// return mType;
// }
//
// public Color getColor() {
// return mColor;
// }
//
// private Color getColorFromType() {
// if (mType.equalsIgnoreCase("finish"))
// return Color.GREEN;
// else if (mType.equalsIgnoreCase("speed_change"))
// return Color.CYAN;
// else if (mType.equalsIgnoreCase("gravity_change"))
// return Color.YELLOW;
// else if (mType.equalsIgnoreCase("checkpoint"))
// return Color.ORANGE;
// else if (mType.equalsIgnoreCase("modal_text"))
// return new Color(0, 0, 0, 0);
// else if (mType.equalsIgnoreCase("size_change"))
// return Color.DARK_GRAY;
// else if (mType.equalsIgnoreCase("camera_rotate"))
// return Color.GOLD;
//
// return Color.WHITE;
// }
// }
//
// Path: core/src/com/alexaut/kroniax/game/scripts/Script.java
// public abstract class Script {
// private boolean mRunning;
// private boolean mStarted;
//
// public Script() {
// mRunning = false;
// mStarted = false;
// }
//
// public boolean isAlive() {
// return mRunning;
// }
//
// public void start() {
// mRunning = true;
// mStarted = true;
// }
//
// public void stop() {
// mRunning = false;
// mStarted = true;
// }
//
// public void reset() {
// mRunning = false;
// mStarted = false;
// }
//
// public boolean alreadyStarted() {
// return mStarted;
// }
//
// public abstract void update(float deltaTime, GameController gameController, Level level, Player player,
// Camera camera);
// }
// Path: core/src/com/alexaut/kroniax/game/tilemap/TileMap.java
import java.util.ArrayList;
import com.alexaut.kroniax.game.level.LevelObject;
import com.alexaut.kroniax.game.scripts.Script;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
package com.alexaut.kroniax.game.tilemap;
public class TileMap {
private Properties mProperties;
private ArrayList<Tileset> mTilesets;
private ArrayList<TileLayer> mTileLayers;
private ArrayList<LevelObject> mLevelObjects;
|
private ArrayList<Script> mScripts;
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/game/gamecontrollerscenes/ModalScene.java
|
// Path: core/src/com/alexaut/kroniax/Application.java
// public class Application extends Game {
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// private Skin mSkin;
//
// private ProgressManager mProgressManager;
// private Preferences mSettings;
//
// private MenuScene mMenuScene;
//
// @Override
// public void create() {
// mSpriteBatch = new SpriteBatch();
// mShapeRenderer = new ShapeRenderer();
// mSkin = new Skin(Gdx.files.internal("data/skins/menu.json"));
// mProgressManager = new ProgressManager();
// mSettings = Gdx.app.getPreferences("settings");
//
// mMenuScene = new MenuScene(this);
//
// setScreen(mMenuScene);
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// super.dispose();
// mSpriteBatch.dispose();
// mShapeRenderer.dispose();
// mMenuScene.dispose();
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// super.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// super.resume();
// }
//
// @Override
// public void render() {
//
// // TODO Auto-generated method stub
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
// super.resize(width, height);
// }
//
// public SpriteBatch getSpriteBatch() {
// return mSpriteBatch;
// }
//
// public ShapeRenderer getShapeRenderer() {
// return mShapeRenderer;
// }
//
// public Skin getGuiSkin() {
// return mSkin;
// }
//
// public ProgressManager getProgressManager() {
// return mProgressManager;
// }
//
// public MenuScene getMenuScene() {
// return mMenuScene;
// }
//
// public void toogleMusicEnabled() {
// boolean current = mSettings.getBoolean("music", true);
// mSettings.putBoolean("music", !current);
// mSettings.flush();
// mMenuScene.updateMusicState();
// }
//
// public boolean isMusicEnabled() {
// return mSettings.getBoolean("music", true);
// }
//
// }
|
import com.alexaut.kroniax.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
package com.alexaut.kroniax.game.gamecontrollerscenes;
public class ModalScene extends Table {
private Label mText;
|
// Path: core/src/com/alexaut/kroniax/Application.java
// public class Application extends Game {
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// private Skin mSkin;
//
// private ProgressManager mProgressManager;
// private Preferences mSettings;
//
// private MenuScene mMenuScene;
//
// @Override
// public void create() {
// mSpriteBatch = new SpriteBatch();
// mShapeRenderer = new ShapeRenderer();
// mSkin = new Skin(Gdx.files.internal("data/skins/menu.json"));
// mProgressManager = new ProgressManager();
// mSettings = Gdx.app.getPreferences("settings");
//
// mMenuScene = new MenuScene(this);
//
// setScreen(mMenuScene);
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// super.dispose();
// mSpriteBatch.dispose();
// mShapeRenderer.dispose();
// mMenuScene.dispose();
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// super.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// super.resume();
// }
//
// @Override
// public void render() {
//
// // TODO Auto-generated method stub
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
// super.resize(width, height);
// }
//
// public SpriteBatch getSpriteBatch() {
// return mSpriteBatch;
// }
//
// public ShapeRenderer getShapeRenderer() {
// return mShapeRenderer;
// }
//
// public Skin getGuiSkin() {
// return mSkin;
// }
//
// public ProgressManager getProgressManager() {
// return mProgressManager;
// }
//
// public MenuScene getMenuScene() {
// return mMenuScene;
// }
//
// public void toogleMusicEnabled() {
// boolean current = mSettings.getBoolean("music", true);
// mSettings.putBoolean("music", !current);
// mSettings.flush();
// mMenuScene.updateMusicState();
// }
//
// public boolean isMusicEnabled() {
// return mSettings.getBoolean("music", true);
// }
//
// }
// Path: core/src/com/alexaut/kroniax/game/gamecontrollerscenes/ModalScene.java
import com.alexaut.kroniax.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
package com.alexaut.kroniax.game.gamecontrollerscenes;
public class ModalScene extends Table {
private Label mText;
|
public ModalScene(Application app) {
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/game/GameHUD.java
|
// Path: core/src/com/alexaut/kroniax/Application.java
// public class Application extends Game {
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// private Skin mSkin;
//
// private ProgressManager mProgressManager;
// private Preferences mSettings;
//
// private MenuScene mMenuScene;
//
// @Override
// public void create() {
// mSpriteBatch = new SpriteBatch();
// mShapeRenderer = new ShapeRenderer();
// mSkin = new Skin(Gdx.files.internal("data/skins/menu.json"));
// mProgressManager = new ProgressManager();
// mSettings = Gdx.app.getPreferences("settings");
//
// mMenuScene = new MenuScene(this);
//
// setScreen(mMenuScene);
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// super.dispose();
// mSpriteBatch.dispose();
// mShapeRenderer.dispose();
// mMenuScene.dispose();
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// super.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// super.resume();
// }
//
// @Override
// public void render() {
//
// // TODO Auto-generated method stub
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
// super.resize(width, height);
// }
//
// public SpriteBatch getSpriteBatch() {
// return mSpriteBatch;
// }
//
// public ShapeRenderer getShapeRenderer() {
// return mShapeRenderer;
// }
//
// public Skin getGuiSkin() {
// return mSkin;
// }
//
// public ProgressManager getProgressManager() {
// return mProgressManager;
// }
//
// public MenuScene getMenuScene() {
// return mMenuScene;
// }
//
// public void toogleMusicEnabled() {
// boolean current = mSettings.getBoolean("music", true);
// mSettings.putBoolean("music", !current);
// mSettings.flush();
// mMenuScene.updateMusicState();
// }
//
// public boolean isMusicEnabled() {
// return mSettings.getBoolean("music", true);
// }
//
// }
|
import com.alexaut.kroniax.Application;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
package com.alexaut.kroniax.game;
public class GameHUD {
private float mTime;
private int mTries;
private BitmapFont mFont;
private OrthographicCamera mCamera;
|
// Path: core/src/com/alexaut/kroniax/Application.java
// public class Application extends Game {
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// private Skin mSkin;
//
// private ProgressManager mProgressManager;
// private Preferences mSettings;
//
// private MenuScene mMenuScene;
//
// @Override
// public void create() {
// mSpriteBatch = new SpriteBatch();
// mShapeRenderer = new ShapeRenderer();
// mSkin = new Skin(Gdx.files.internal("data/skins/menu.json"));
// mProgressManager = new ProgressManager();
// mSettings = Gdx.app.getPreferences("settings");
//
// mMenuScene = new MenuScene(this);
//
// setScreen(mMenuScene);
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// super.dispose();
// mSpriteBatch.dispose();
// mShapeRenderer.dispose();
// mMenuScene.dispose();
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// super.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// super.resume();
// }
//
// @Override
// public void render() {
//
// // TODO Auto-generated method stub
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
// super.resize(width, height);
// }
//
// public SpriteBatch getSpriteBatch() {
// return mSpriteBatch;
// }
//
// public ShapeRenderer getShapeRenderer() {
// return mShapeRenderer;
// }
//
// public Skin getGuiSkin() {
// return mSkin;
// }
//
// public ProgressManager getProgressManager() {
// return mProgressManager;
// }
//
// public MenuScene getMenuScene() {
// return mMenuScene;
// }
//
// public void toogleMusicEnabled() {
// boolean current = mSettings.getBoolean("music", true);
// mSettings.putBoolean("music", !current);
// mSettings.flush();
// mMenuScene.updateMusicState();
// }
//
// public boolean isMusicEnabled() {
// return mSettings.getBoolean("music", true);
// }
//
// }
// Path: core/src/com/alexaut/kroniax/game/GameHUD.java
import com.alexaut.kroniax.Application;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
package com.alexaut.kroniax.game;
public class GameHUD {
private float mTime;
private int mTries;
private BitmapFont mFont;
private OrthographicCamera mCamera;
|
public GameHUD(Application app) {
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/game/player/Player.java
|
// Path: core/src/com/alexaut/kroniax/game/level/LevelProperties.java
// public class LevelProperties {
// // Map Properties
// public Vector2 tileSize;
// public Vector2 size;
// public Vector2 tileCount;
//
// public Vector2 spawn;
// public float velocity;
// public float gravity;
//
// public boolean fixedCamera;
//
// public LevelProperties(TileMap level) throws Exception {
// parseMapDetails(level.getProperties());
//
// checkEssentialValues();
// }
//
// private void parseMapDetails(Properties props) {
// // Search tilesize
// tileSize = new Vector2(props.get("tilewidth"), props.get("tileheight"));
// tileCount = new Vector2(props.get("width"), props.get("height"));
// size = new Vector2(tileCount.x * tileSize.x, tileCount.y * tileSize.y);
// // Spawn
// if (props.hasProperty("spawn_x")) {
// float spawn_x = props.get("spawn_x") * tileSize.x;
// if (spawn == null)
// spawn = new Vector2(spawn_x, 0);
// else
// spawn.x = spawn_x;
// }
// if (props.hasProperty("spawn_y")) {
// float spawn_y = (tileCount.y - props.get("spawn_y")) * tileSize.y;
// if (spawn == null)
// spawn = new Vector2(0, spawn_y);
// else
// spawn.y = spawn_y;
// }
// if (props.hasProperty("gravity"))
// gravity = props.get("gravity");
// else
// gravity = 100.f;
// if (props.hasProperty("velocity"))
// velocity = props.get("velocity");
// else
// velocity = 300;
//
// fixedCamera = props.hasProperty("fixed_camera");
// }
//
// private void checkEssentialValues() throws Exception {
// if (spawn == null)
// throw new Exception("spawn_x and/or spawn_y are missing, they should be properties of a layer");
// }
//
// }
|
import com.alexaut.kroniax.game.level.LevelProperties;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector2;
|
package com.alexaut.kroniax.game.player;
public class Player {
private Vector2 mPosition;
private Vector2 mSize;
private Vector2 mVelocity;
private float mGravity;
private PlayerShip mShip;
private PlayerScriptTimer mScriptTimers;
private Vector2 mCachePosition;
private Vector2 mCacheSize;
private Vector2 mCacheVelocity;
private float mCacheGravity;
|
// Path: core/src/com/alexaut/kroniax/game/level/LevelProperties.java
// public class LevelProperties {
// // Map Properties
// public Vector2 tileSize;
// public Vector2 size;
// public Vector2 tileCount;
//
// public Vector2 spawn;
// public float velocity;
// public float gravity;
//
// public boolean fixedCamera;
//
// public LevelProperties(TileMap level) throws Exception {
// parseMapDetails(level.getProperties());
//
// checkEssentialValues();
// }
//
// private void parseMapDetails(Properties props) {
// // Search tilesize
// tileSize = new Vector2(props.get("tilewidth"), props.get("tileheight"));
// tileCount = new Vector2(props.get("width"), props.get("height"));
// size = new Vector2(tileCount.x * tileSize.x, tileCount.y * tileSize.y);
// // Spawn
// if (props.hasProperty("spawn_x")) {
// float spawn_x = props.get("spawn_x") * tileSize.x;
// if (spawn == null)
// spawn = new Vector2(spawn_x, 0);
// else
// spawn.x = spawn_x;
// }
// if (props.hasProperty("spawn_y")) {
// float spawn_y = (tileCount.y - props.get("spawn_y")) * tileSize.y;
// if (spawn == null)
// spawn = new Vector2(0, spawn_y);
// else
// spawn.y = spawn_y;
// }
// if (props.hasProperty("gravity"))
// gravity = props.get("gravity");
// else
// gravity = 100.f;
// if (props.hasProperty("velocity"))
// velocity = props.get("velocity");
// else
// velocity = 300;
//
// fixedCamera = props.hasProperty("fixed_camera");
// }
//
// private void checkEssentialValues() throws Exception {
// if (spawn == null)
// throw new Exception("spawn_x and/or spawn_y are missing, they should be properties of a layer");
// }
//
// }
// Path: core/src/com/alexaut/kroniax/game/player/Player.java
import com.alexaut.kroniax.game.level.LevelProperties;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector2;
package com.alexaut.kroniax.game.player;
public class Player {
private Vector2 mPosition;
private Vector2 mSize;
private Vector2 mVelocity;
private float mGravity;
private PlayerShip mShip;
private PlayerScriptTimer mScriptTimers;
private Vector2 mCachePosition;
private Vector2 mCacheSize;
private Vector2 mCacheVelocity;
private float mCacheGravity;
|
public Player(LevelProperties props) {
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/menu/MainLayer.java
|
// Path: core/src/com/alexaut/kroniax/menu/Gui.java
// public enum Layer {
// MAIN, LEVEL_SELECTION, SETTINGS, CREDITS
// }
|
import com.alexaut.kroniax.menu.Gui.Layer;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
package com.alexaut.kroniax.menu;
public class MainLayer extends Table {
public MainLayer(final Gui gui) {
super();
setFillParent(true);
setY(0);
Image logo = new Image(gui.getSkin().getRegion("logo"));
add(logo);
row().padTop(75.f);
// Start button
TextButton bt = new TextButton("Play", gui.getSkin());
// Show level selection Layer
bt.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
// Get movement direction
int direction = 720;
|
// Path: core/src/com/alexaut/kroniax/menu/Gui.java
// public enum Layer {
// MAIN, LEVEL_SELECTION, SETTINGS, CREDITS
// }
// Path: core/src/com/alexaut/kroniax/menu/MainLayer.java
import com.alexaut.kroniax.menu.Gui.Layer;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
package com.alexaut.kroniax.menu;
public class MainLayer extends Table {
public MainLayer(final Gui gui) {
super();
setFillParent(true);
setY(0);
Image logo = new Image(gui.getSkin().getRegion("logo"));
add(logo);
row().padTop(75.f);
// Start button
TextButton bt = new TextButton("Play", gui.getSkin());
// Show level selection Layer
bt.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
// Get movement direction
int direction = 720;
|
if (gui.getLayer(Layer.LEVEL_SELECTION).getY() > 0)
|
AlexAUT/Kroniax
|
desktop/src/com/alexaut/kroniax/desktop/DesktopLauncher.java
|
// Path: core/src/com/alexaut/kroniax/Application.java
// public class Application extends Game {
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// private Skin mSkin;
//
// private ProgressManager mProgressManager;
// private Preferences mSettings;
//
// private MenuScene mMenuScene;
//
// @Override
// public void create() {
// mSpriteBatch = new SpriteBatch();
// mShapeRenderer = new ShapeRenderer();
// mSkin = new Skin(Gdx.files.internal("data/skins/menu.json"));
// mProgressManager = new ProgressManager();
// mSettings = Gdx.app.getPreferences("settings");
//
// mMenuScene = new MenuScene(this);
//
// setScreen(mMenuScene);
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// super.dispose();
// mSpriteBatch.dispose();
// mShapeRenderer.dispose();
// mMenuScene.dispose();
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// super.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// super.resume();
// }
//
// @Override
// public void render() {
//
// // TODO Auto-generated method stub
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
// super.resize(width, height);
// }
//
// public SpriteBatch getSpriteBatch() {
// return mSpriteBatch;
// }
//
// public ShapeRenderer getShapeRenderer() {
// return mShapeRenderer;
// }
//
// public Skin getGuiSkin() {
// return mSkin;
// }
//
// public ProgressManager getProgressManager() {
// return mProgressManager;
// }
//
// public MenuScene getMenuScene() {
// return mMenuScene;
// }
//
// public void toogleMusicEnabled() {
// boolean current = mSettings.getBoolean("music", true);
// mSettings.putBoolean("music", !current);
// mSettings.flush();
// mMenuScene.updateMusicState();
// }
//
// public boolean isMusicEnabled() {
// return mSettings.getBoolean("music", true);
// }
//
// }
|
import com.alexaut.kroniax.Application;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
package com.alexaut.kroniax.desktop;
public class DesktopLauncher {
public static void main(String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 1280;
config.height = 720;
config.vSyncEnabled = true;
config.foregroundFPS = 0;
config.samples = 4;
|
// Path: core/src/com/alexaut/kroniax/Application.java
// public class Application extends Game {
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// private Skin mSkin;
//
// private ProgressManager mProgressManager;
// private Preferences mSettings;
//
// private MenuScene mMenuScene;
//
// @Override
// public void create() {
// mSpriteBatch = new SpriteBatch();
// mShapeRenderer = new ShapeRenderer();
// mSkin = new Skin(Gdx.files.internal("data/skins/menu.json"));
// mProgressManager = new ProgressManager();
// mSettings = Gdx.app.getPreferences("settings");
//
// mMenuScene = new MenuScene(this);
//
// setScreen(mMenuScene);
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// super.dispose();
// mSpriteBatch.dispose();
// mShapeRenderer.dispose();
// mMenuScene.dispose();
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// super.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// super.resume();
// }
//
// @Override
// public void render() {
//
// // TODO Auto-generated method stub
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
// super.resize(width, height);
// }
//
// public SpriteBatch getSpriteBatch() {
// return mSpriteBatch;
// }
//
// public ShapeRenderer getShapeRenderer() {
// return mShapeRenderer;
// }
//
// public Skin getGuiSkin() {
// return mSkin;
// }
//
// public ProgressManager getProgressManager() {
// return mProgressManager;
// }
//
// public MenuScene getMenuScene() {
// return mMenuScene;
// }
//
// public void toogleMusicEnabled() {
// boolean current = mSettings.getBoolean("music", true);
// mSettings.putBoolean("music", !current);
// mSettings.flush();
// mMenuScene.updateMusicState();
// }
//
// public boolean isMusicEnabled() {
// return mSettings.getBoolean("music", true);
// }
//
// }
// Path: desktop/src/com/alexaut/kroniax/desktop/DesktopLauncher.java
import com.alexaut.kroniax.Application;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
package com.alexaut.kroniax.desktop;
public class DesktopLauncher {
public static void main(String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 1280;
config.height = 720;
config.vSyncEnabled = true;
config.foregroundFPS = 0;
config.samples = 4;
|
new LwjglApplication(new Application(), config);
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/game/level/LevelProperties.java
|
// Path: core/src/com/alexaut/kroniax/game/tilemap/Properties.java
// public class Properties {
// Map<String, Integer> mProperties;
//
// public Properties() {
// mProperties = new HashMap<String, Integer>();
// }
//
// public void add(String key, int value) {
// mProperties.put(key, value);
// }
//
// public boolean hasProperty(String key) {
// return mProperties.get(key) != null;
// }
//
// public int get(String key) {
// return mProperties.get(key);
// }
//
// public Set<String> getKeySet() {
// return mProperties.keySet();
// }
//
// }
//
// Path: core/src/com/alexaut/kroniax/game/tilemap/TileMap.java
// public class TileMap {
//
// private Properties mProperties;
//
// private ArrayList<Tileset> mTilesets;
// private ArrayList<TileLayer> mTileLayers;
// private ArrayList<LevelObject> mLevelObjects;
// private ArrayList<Script> mScripts;
//
// public TileMap() {
// mProperties = new Properties();
// mTilesets = new ArrayList<Tileset>();
// mTileLayers = new ArrayList<TileLayer>();
// mLevelObjects = new ArrayList<LevelObject>();
// mScripts = new ArrayList<Script>();
// }
//
// public Properties getProperties() {
// return mProperties;
// }
//
// public ArrayList<Tileset> getTilesets() {
// return mTilesets;
// }
//
// public ArrayList<TileLayer> getTileLayers() {
// return mTileLayers;
// }
//
// public ArrayList<LevelObject> getLevelObjects() {
// return mLevelObjects;
// }
//
// public ArrayList<Script> getScripts() {
// return mScripts;
// }
//
// public TextureRegion getTileRegion(int id) {
// if (id == 0)
// return null;
//
// for (Tileset tileset : mTilesets) {
// if (tileset.getFirstID() <= id) {
// return tileset.getTile(id);
// }
// }
// return null;
// }
//
// // Convenient functions
// public int getWidth() {
// if (mProperties.hasProperty("width"))
// return mProperties.get("width");
// return 0;
// }
//
// public int getHeight() {
// if (mProperties.hasProperty("height"))
// return mProperties.get("height");
// return 0;
// }
//
// public int getTileWidth() {
// if (mProperties.hasProperty("tilewidth"))
// return mProperties.get("tilewidth");
// return 0;
// }
//
// public int getTileHeight() {
// if (mProperties.hasProperty("tileheight"))
// return mProperties.get("tileheight");
// return 0;
// }
//
// public void dispose() {
// for (Tileset tileset : mTilesets)
// tileset.dispose();
// }
//
// }
|
import com.alexaut.kroniax.game.tilemap.Properties;
import com.alexaut.kroniax.game.tilemap.TileMap;
import com.badlogic.gdx.math.Vector2;
|
package com.alexaut.kroniax.game.level;
public class LevelProperties {
// Map Properties
public Vector2 tileSize;
public Vector2 size;
public Vector2 tileCount;
public Vector2 spawn;
public float velocity;
public float gravity;
public boolean fixedCamera;
|
// Path: core/src/com/alexaut/kroniax/game/tilemap/Properties.java
// public class Properties {
// Map<String, Integer> mProperties;
//
// public Properties() {
// mProperties = new HashMap<String, Integer>();
// }
//
// public void add(String key, int value) {
// mProperties.put(key, value);
// }
//
// public boolean hasProperty(String key) {
// return mProperties.get(key) != null;
// }
//
// public int get(String key) {
// return mProperties.get(key);
// }
//
// public Set<String> getKeySet() {
// return mProperties.keySet();
// }
//
// }
//
// Path: core/src/com/alexaut/kroniax/game/tilemap/TileMap.java
// public class TileMap {
//
// private Properties mProperties;
//
// private ArrayList<Tileset> mTilesets;
// private ArrayList<TileLayer> mTileLayers;
// private ArrayList<LevelObject> mLevelObjects;
// private ArrayList<Script> mScripts;
//
// public TileMap() {
// mProperties = new Properties();
// mTilesets = new ArrayList<Tileset>();
// mTileLayers = new ArrayList<TileLayer>();
// mLevelObjects = new ArrayList<LevelObject>();
// mScripts = new ArrayList<Script>();
// }
//
// public Properties getProperties() {
// return mProperties;
// }
//
// public ArrayList<Tileset> getTilesets() {
// return mTilesets;
// }
//
// public ArrayList<TileLayer> getTileLayers() {
// return mTileLayers;
// }
//
// public ArrayList<LevelObject> getLevelObjects() {
// return mLevelObjects;
// }
//
// public ArrayList<Script> getScripts() {
// return mScripts;
// }
//
// public TextureRegion getTileRegion(int id) {
// if (id == 0)
// return null;
//
// for (Tileset tileset : mTilesets) {
// if (tileset.getFirstID() <= id) {
// return tileset.getTile(id);
// }
// }
// return null;
// }
//
// // Convenient functions
// public int getWidth() {
// if (mProperties.hasProperty("width"))
// return mProperties.get("width");
// return 0;
// }
//
// public int getHeight() {
// if (mProperties.hasProperty("height"))
// return mProperties.get("height");
// return 0;
// }
//
// public int getTileWidth() {
// if (mProperties.hasProperty("tilewidth"))
// return mProperties.get("tilewidth");
// return 0;
// }
//
// public int getTileHeight() {
// if (mProperties.hasProperty("tileheight"))
// return mProperties.get("tileheight");
// return 0;
// }
//
// public void dispose() {
// for (Tileset tileset : mTilesets)
// tileset.dispose();
// }
//
// }
// Path: core/src/com/alexaut/kroniax/game/level/LevelProperties.java
import com.alexaut.kroniax.game.tilemap.Properties;
import com.alexaut.kroniax.game.tilemap.TileMap;
import com.badlogic.gdx.math.Vector2;
package com.alexaut.kroniax.game.level;
public class LevelProperties {
// Map Properties
public Vector2 tileSize;
public Vector2 size;
public Vector2 tileCount;
public Vector2 spawn;
public float velocity;
public float gravity;
public boolean fixedCamera;
|
public LevelProperties(TileMap level) throws Exception {
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/game/level/LevelProperties.java
|
// Path: core/src/com/alexaut/kroniax/game/tilemap/Properties.java
// public class Properties {
// Map<String, Integer> mProperties;
//
// public Properties() {
// mProperties = new HashMap<String, Integer>();
// }
//
// public void add(String key, int value) {
// mProperties.put(key, value);
// }
//
// public boolean hasProperty(String key) {
// return mProperties.get(key) != null;
// }
//
// public int get(String key) {
// return mProperties.get(key);
// }
//
// public Set<String> getKeySet() {
// return mProperties.keySet();
// }
//
// }
//
// Path: core/src/com/alexaut/kroniax/game/tilemap/TileMap.java
// public class TileMap {
//
// private Properties mProperties;
//
// private ArrayList<Tileset> mTilesets;
// private ArrayList<TileLayer> mTileLayers;
// private ArrayList<LevelObject> mLevelObjects;
// private ArrayList<Script> mScripts;
//
// public TileMap() {
// mProperties = new Properties();
// mTilesets = new ArrayList<Tileset>();
// mTileLayers = new ArrayList<TileLayer>();
// mLevelObjects = new ArrayList<LevelObject>();
// mScripts = new ArrayList<Script>();
// }
//
// public Properties getProperties() {
// return mProperties;
// }
//
// public ArrayList<Tileset> getTilesets() {
// return mTilesets;
// }
//
// public ArrayList<TileLayer> getTileLayers() {
// return mTileLayers;
// }
//
// public ArrayList<LevelObject> getLevelObjects() {
// return mLevelObjects;
// }
//
// public ArrayList<Script> getScripts() {
// return mScripts;
// }
//
// public TextureRegion getTileRegion(int id) {
// if (id == 0)
// return null;
//
// for (Tileset tileset : mTilesets) {
// if (tileset.getFirstID() <= id) {
// return tileset.getTile(id);
// }
// }
// return null;
// }
//
// // Convenient functions
// public int getWidth() {
// if (mProperties.hasProperty("width"))
// return mProperties.get("width");
// return 0;
// }
//
// public int getHeight() {
// if (mProperties.hasProperty("height"))
// return mProperties.get("height");
// return 0;
// }
//
// public int getTileWidth() {
// if (mProperties.hasProperty("tilewidth"))
// return mProperties.get("tilewidth");
// return 0;
// }
//
// public int getTileHeight() {
// if (mProperties.hasProperty("tileheight"))
// return mProperties.get("tileheight");
// return 0;
// }
//
// public void dispose() {
// for (Tileset tileset : mTilesets)
// tileset.dispose();
// }
//
// }
|
import com.alexaut.kroniax.game.tilemap.Properties;
import com.alexaut.kroniax.game.tilemap.TileMap;
import com.badlogic.gdx.math.Vector2;
|
package com.alexaut.kroniax.game.level;
public class LevelProperties {
// Map Properties
public Vector2 tileSize;
public Vector2 size;
public Vector2 tileCount;
public Vector2 spawn;
public float velocity;
public float gravity;
public boolean fixedCamera;
public LevelProperties(TileMap level) throws Exception {
parseMapDetails(level.getProperties());
checkEssentialValues();
}
|
// Path: core/src/com/alexaut/kroniax/game/tilemap/Properties.java
// public class Properties {
// Map<String, Integer> mProperties;
//
// public Properties() {
// mProperties = new HashMap<String, Integer>();
// }
//
// public void add(String key, int value) {
// mProperties.put(key, value);
// }
//
// public boolean hasProperty(String key) {
// return mProperties.get(key) != null;
// }
//
// public int get(String key) {
// return mProperties.get(key);
// }
//
// public Set<String> getKeySet() {
// return mProperties.keySet();
// }
//
// }
//
// Path: core/src/com/alexaut/kroniax/game/tilemap/TileMap.java
// public class TileMap {
//
// private Properties mProperties;
//
// private ArrayList<Tileset> mTilesets;
// private ArrayList<TileLayer> mTileLayers;
// private ArrayList<LevelObject> mLevelObjects;
// private ArrayList<Script> mScripts;
//
// public TileMap() {
// mProperties = new Properties();
// mTilesets = new ArrayList<Tileset>();
// mTileLayers = new ArrayList<TileLayer>();
// mLevelObjects = new ArrayList<LevelObject>();
// mScripts = new ArrayList<Script>();
// }
//
// public Properties getProperties() {
// return mProperties;
// }
//
// public ArrayList<Tileset> getTilesets() {
// return mTilesets;
// }
//
// public ArrayList<TileLayer> getTileLayers() {
// return mTileLayers;
// }
//
// public ArrayList<LevelObject> getLevelObjects() {
// return mLevelObjects;
// }
//
// public ArrayList<Script> getScripts() {
// return mScripts;
// }
//
// public TextureRegion getTileRegion(int id) {
// if (id == 0)
// return null;
//
// for (Tileset tileset : mTilesets) {
// if (tileset.getFirstID() <= id) {
// return tileset.getTile(id);
// }
// }
// return null;
// }
//
// // Convenient functions
// public int getWidth() {
// if (mProperties.hasProperty("width"))
// return mProperties.get("width");
// return 0;
// }
//
// public int getHeight() {
// if (mProperties.hasProperty("height"))
// return mProperties.get("height");
// return 0;
// }
//
// public int getTileWidth() {
// if (mProperties.hasProperty("tilewidth"))
// return mProperties.get("tilewidth");
// return 0;
// }
//
// public int getTileHeight() {
// if (mProperties.hasProperty("tileheight"))
// return mProperties.get("tileheight");
// return 0;
// }
//
// public void dispose() {
// for (Tileset tileset : mTilesets)
// tileset.dispose();
// }
//
// }
// Path: core/src/com/alexaut/kroniax/game/level/LevelProperties.java
import com.alexaut.kroniax.game.tilemap.Properties;
import com.alexaut.kroniax.game.tilemap.TileMap;
import com.badlogic.gdx.math.Vector2;
package com.alexaut.kroniax.game.level;
public class LevelProperties {
// Map Properties
public Vector2 tileSize;
public Vector2 size;
public Vector2 tileCount;
public Vector2 spawn;
public float velocity;
public float gravity;
public boolean fixedCamera;
public LevelProperties(TileMap level) throws Exception {
parseMapDetails(level.getProperties());
checkEssentialValues();
}
|
private void parseMapDetails(Properties props) {
|
AlexAUT/Kroniax
|
core/src/com/alexaut/kroniax/Application.java
|
// Path: core/src/com/alexaut/kroniax/game/ProgressManager.java
// public class ProgressManager {
// private Preferences mUnlockedLevels;
//
// public ProgressManager() {
// mUnlockedLevels = Gdx.app.getPreferences("progress");
// if (!mUnlockedLevels.contains("unlocked_levels")) {
// mUnlockedLevels.putInteger("unlocked_levels", 1);
// mUnlockedLevels.flush();
// }
// }
//
// public int getUnlockedLevels() {
// return mUnlockedLevels.getInteger("unlocked_levels");
// }
//
// public void finishedLevel(int lvlNumber) {
// if (lvlNumber >= mUnlockedLevels.getInteger("unlocked_levels")) {
// mUnlockedLevels.putInteger("unlocked_levels", lvlNumber + 1);
// mUnlockedLevels.flush();
// }
// }
// }
//
// Path: core/src/com/alexaut/kroniax/screens/MenuScene.java
// public class MenuScene implements Screen {
//
// private Application mApp;
//
// private MenuBackground mBackground;
// private Gui mGui;
//
// private Music mMusic;
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// public MenuScene(Application app) {
// mApp = app;
//
// mBackground = new MenuBackground();
// mGui = new Gui(app);
//
// mSpriteBatch = app.getSpriteBatch();
// mShapeRenderer = app.getShapeRenderer();
// }
//
// @Override
// public void show() {
// mMusic = Gdx.audio.newMusic(Gdx.files.internal("data/music/PowerFight-ElectroTechnoBeat.ogg"));
// mMusic.setVolume(0.75f);
// if (mApp.isMusicEnabled())
// mMusic.play();
// mMusic.setLooping(true);
//
// mGui.show();
// mGui.fadeActiveIn();
// }
//
// @Override
// public void render(float delta) {
// mBackground.update(Gdx.graphics.getDeltaTime());
// mGui.update(Gdx.graphics.getDeltaTime());
//
// Gdx.gl.glClearColor(0, 0, 0, 1);
// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// // mStage.getViewport().setCamera(mCamera);
//
// mBackground.render(mSpriteBatch, mShapeRenderer);
//
// mSpriteBatch.begin();
// mGui.render(mSpriteBatch);
// mSpriteBatch.end();
// }
//
// @Override
// public void resize(int width, int height) {
// mGui.updateViewport(width, height);
// mBackground.updateViewport(width, height);
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// mMusic.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// if (mApp.isMusicEnabled())
// mMusic.play();
// }
//
// @Override
// public void hide() {
// mGui.hide();
// mMusic.stop();
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// mGui.dispose();
// mBackground.dispose();
// mMusic.dispose();
// }
//
// public void updateMusicState() {
// if (mApp.isMusicEnabled())
// mMusic.play();
// else
// mMusic.stop();
// }
// }
|
import com.alexaut.kroniax.game.ProgressManager;
import com.alexaut.kroniax.screens.MenuScene;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
package com.alexaut.kroniax;
public class Application extends Game {
private SpriteBatch mSpriteBatch;
private ShapeRenderer mShapeRenderer;
private Skin mSkin;
|
// Path: core/src/com/alexaut/kroniax/game/ProgressManager.java
// public class ProgressManager {
// private Preferences mUnlockedLevels;
//
// public ProgressManager() {
// mUnlockedLevels = Gdx.app.getPreferences("progress");
// if (!mUnlockedLevels.contains("unlocked_levels")) {
// mUnlockedLevels.putInteger("unlocked_levels", 1);
// mUnlockedLevels.flush();
// }
// }
//
// public int getUnlockedLevels() {
// return mUnlockedLevels.getInteger("unlocked_levels");
// }
//
// public void finishedLevel(int lvlNumber) {
// if (lvlNumber >= mUnlockedLevels.getInteger("unlocked_levels")) {
// mUnlockedLevels.putInteger("unlocked_levels", lvlNumber + 1);
// mUnlockedLevels.flush();
// }
// }
// }
//
// Path: core/src/com/alexaut/kroniax/screens/MenuScene.java
// public class MenuScene implements Screen {
//
// private Application mApp;
//
// private MenuBackground mBackground;
// private Gui mGui;
//
// private Music mMusic;
//
// private SpriteBatch mSpriteBatch;
// private ShapeRenderer mShapeRenderer;
//
// public MenuScene(Application app) {
// mApp = app;
//
// mBackground = new MenuBackground();
// mGui = new Gui(app);
//
// mSpriteBatch = app.getSpriteBatch();
// mShapeRenderer = app.getShapeRenderer();
// }
//
// @Override
// public void show() {
// mMusic = Gdx.audio.newMusic(Gdx.files.internal("data/music/PowerFight-ElectroTechnoBeat.ogg"));
// mMusic.setVolume(0.75f);
// if (mApp.isMusicEnabled())
// mMusic.play();
// mMusic.setLooping(true);
//
// mGui.show();
// mGui.fadeActiveIn();
// }
//
// @Override
// public void render(float delta) {
// mBackground.update(Gdx.graphics.getDeltaTime());
// mGui.update(Gdx.graphics.getDeltaTime());
//
// Gdx.gl.glClearColor(0, 0, 0, 1);
// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// // mStage.getViewport().setCamera(mCamera);
//
// mBackground.render(mSpriteBatch, mShapeRenderer);
//
// mSpriteBatch.begin();
// mGui.render(mSpriteBatch);
// mSpriteBatch.end();
// }
//
// @Override
// public void resize(int width, int height) {
// mGui.updateViewport(width, height);
// mBackground.updateViewport(width, height);
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
// mMusic.pause();
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
// if (mApp.isMusicEnabled())
// mMusic.play();
// }
//
// @Override
// public void hide() {
// mGui.hide();
// mMusic.stop();
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
// mGui.dispose();
// mBackground.dispose();
// mMusic.dispose();
// }
//
// public void updateMusicState() {
// if (mApp.isMusicEnabled())
// mMusic.play();
// else
// mMusic.stop();
// }
// }
// Path: core/src/com/alexaut/kroniax/Application.java
import com.alexaut.kroniax.game.ProgressManager;
import com.alexaut.kroniax.screens.MenuScene;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
package com.alexaut.kroniax;
public class Application extends Game {
private SpriteBatch mSpriteBatch;
private ShapeRenderer mShapeRenderer;
private Skin mSkin;
|
private ProgressManager mProgressManager;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.