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 |
|---|---|---|---|---|---|---|
tim-savage/SavageDeathChest | src/main/java/com/winterhavenmc/deathchest/chests/ChestBlock.java | // Path: src/main/java/com/winterhavenmc/deathchest/PluginMain.java
// public final class PluginMain extends JavaPlugin {
//
// public MessageBuilder<MessageId, Macro> messageBuilder;
// public WorldManager worldManager;
// public SoundConfiguration soundConfig;
// public ChestManager chestManager;
// public CommandManager commandManager;
// public ProtectionPluginRegistry protectionPluginRegistry;
//
//
// @Override
// public void onEnable() {
//
// // bStats
// new Metrics(this, 13916);
//
// // copy default config from jar if it doesn't exist
// saveDefaultConfig();
//
// // initialize message builder
// messageBuilder = new MessageBuilder<>(this);
//
// // instantiate sound configuration
// soundConfig = new YamlSoundConfiguration(this);
//
// // instantiate world manager
// worldManager = new WorldManager(this);
//
// // instantiate chest manager
// chestManager = new ChestManager(this);
//
// // load all chests from datastore
// chestManager.loadChests();
//
// // instantiate command manager
// commandManager = new CommandManager(this);
//
// // initialize event listeners
// new PlayerEventListener(this);
// new BlockEventListener(this);
// new InventoryEventListener(this);
//
// // instantiate protection plugin registry
// protectionPluginRegistry = new ProtectionPluginRegistry(this);
// }
//
//
// @Override
// public void onDisable() {
//
// // close datastore
// chestManager.closeDataStore();
// }
//
// }
//
// Path: src/main/java/com/winterhavenmc/deathchest/sounds/SoundId.java
// public enum SoundId {
//
// CHEST_BREAK,
// CHEST_DENIED_ACCESS,
// COMMAND_FAIL,
// INVENTORY_ADD_ITEM,
// COMMAND_INVALID,
// COMMAND_RELOAD_SUCCESS,
//
// }
| import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.*;
import com.winterhavenmc.deathchest.PluginMain;
import com.winterhavenmc.deathchest.sounds.SoundId;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.block.data.type.Sign;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; | }
// get in game block at deathBlock location
Block block = this.getLocation().getBlock();
// confirm block is still death chest block
if (plugin.chestManager.isChestBlockChest(block)) {
// get player inventory object
final PlayerInventory playerInventory = player.getInventory();
// get chest object
final Chest chest = (Chest) block.getState();
// get Collection of ItemStack for chest inventory
final Collection<ItemStack> chestInventory = new LinkedList<>(Arrays.asList(chest.getInventory().getContents()));
// iterate through all inventory slots in chest inventory
for (ItemStack itemStack : chestInventory) {
// if inventory slot item is not null...
if (itemStack != null) {
// remove item from chest inventory
chest.getInventory().removeItem(itemStack);
// add item to player inventory
remainingItems.addAll(playerInventory.addItem(itemStack).values());
// play inventory add sound | // Path: src/main/java/com/winterhavenmc/deathchest/PluginMain.java
// public final class PluginMain extends JavaPlugin {
//
// public MessageBuilder<MessageId, Macro> messageBuilder;
// public WorldManager worldManager;
// public SoundConfiguration soundConfig;
// public ChestManager chestManager;
// public CommandManager commandManager;
// public ProtectionPluginRegistry protectionPluginRegistry;
//
//
// @Override
// public void onEnable() {
//
// // bStats
// new Metrics(this, 13916);
//
// // copy default config from jar if it doesn't exist
// saveDefaultConfig();
//
// // initialize message builder
// messageBuilder = new MessageBuilder<>(this);
//
// // instantiate sound configuration
// soundConfig = new YamlSoundConfiguration(this);
//
// // instantiate world manager
// worldManager = new WorldManager(this);
//
// // instantiate chest manager
// chestManager = new ChestManager(this);
//
// // load all chests from datastore
// chestManager.loadChests();
//
// // instantiate command manager
// commandManager = new CommandManager(this);
//
// // initialize event listeners
// new PlayerEventListener(this);
// new BlockEventListener(this);
// new InventoryEventListener(this);
//
// // instantiate protection plugin registry
// protectionPluginRegistry = new ProtectionPluginRegistry(this);
// }
//
//
// @Override
// public void onDisable() {
//
// // close datastore
// chestManager.closeDataStore();
// }
//
// }
//
// Path: src/main/java/com/winterhavenmc/deathchest/sounds/SoundId.java
// public enum SoundId {
//
// CHEST_BREAK,
// CHEST_DENIED_ACCESS,
// COMMAND_FAIL,
// INVENTORY_ADD_ITEM,
// COMMAND_INVALID,
// COMMAND_RELOAD_SUCCESS,
//
// }
// Path: src/main/java/com/winterhavenmc/deathchest/chests/ChestBlock.java
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.*;
import com.winterhavenmc.deathchest.PluginMain;
import com.winterhavenmc.deathchest.sounds.SoundId;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.block.data.type.Sign;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
}
// get in game block at deathBlock location
Block block = this.getLocation().getBlock();
// confirm block is still death chest block
if (plugin.chestManager.isChestBlockChest(block)) {
// get player inventory object
final PlayerInventory playerInventory = player.getInventory();
// get chest object
final Chest chest = (Chest) block.getState();
// get Collection of ItemStack for chest inventory
final Collection<ItemStack> chestInventory = new LinkedList<>(Arrays.asList(chest.getInventory().getContents()));
// iterate through all inventory slots in chest inventory
for (ItemStack itemStack : chestInventory) {
// if inventory slot item is not null...
if (itemStack != null) {
// remove item from chest inventory
chest.getInventory().removeItem(itemStack);
// add item to player inventory
remainingItems.addAll(playerInventory.addItem(itemStack).values());
// play inventory add sound | plugin.soundConfig.playSound(player, SoundId.INVENTORY_ADD_ITEM); |
tim-savage/SavageDeathChest | src/test/java/com/winterhavenmc/deathchest/SavageDeathChestPluginTests.java | // Path: src/main/java/com/winterhavenmc/deathchest/sounds/SoundId.java
// public enum SoundId {
//
// CHEST_BREAK,
// CHEST_DENIED_ACCESS,
// COMMAND_FAIL,
// INVENTORY_ADD_ITEM,
// COMMAND_INVALID,
// COMMAND_RELOAD_SUCCESS,
//
// }
| import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock;
import be.seeseemelk.mockbukkit.WorldMock;
import be.seeseemelk.mockbukkit.entity.PlayerMock;
import com.winterhavenmc.deathchest.sounds.SoundId;
import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set; | @Test
@DisplayName("test enum string set not empty.")
void EnumStringsNotEmpty() {
Assertions.assertFalse(enumConfigKeyStrings.isEmpty(),
"Enum key set is empty.");
}
@ParameterizedTest
@EnumSource(ConfigSetting.class)
@DisplayName("ConfigSetting enum matches config file key/value pairs.")
void ConfigFileKeysContainsEnumKey(ConfigSetting configSetting) {
Assertions.assertEquals(configSetting.getValue(), plugin.getConfig().getString(configSetting.getKey()),
"Enum key " + configSetting.getKey() + " not found in config file.");
}
}
@Nested
@DisplayName("Test Sounds config.")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class SoundTests {
// collection of enum sound name strings
Collection<String> enumSoundNames = new HashSet<>();
// class constructor
SoundTests() {
// add all SoundId enum values to collection | // Path: src/main/java/com/winterhavenmc/deathchest/sounds/SoundId.java
// public enum SoundId {
//
// CHEST_BREAK,
// CHEST_DENIED_ACCESS,
// COMMAND_FAIL,
// INVENTORY_ADD_ITEM,
// COMMAND_INVALID,
// COMMAND_RELOAD_SUCCESS,
//
// }
// Path: src/test/java/com/winterhavenmc/deathchest/SavageDeathChestPluginTests.java
import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock;
import be.seeseemelk.mockbukkit.WorldMock;
import be.seeseemelk.mockbukkit.entity.PlayerMock;
import com.winterhavenmc.deathchest.sounds.SoundId;
import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@Test
@DisplayName("test enum string set not empty.")
void EnumStringsNotEmpty() {
Assertions.assertFalse(enumConfigKeyStrings.isEmpty(),
"Enum key set is empty.");
}
@ParameterizedTest
@EnumSource(ConfigSetting.class)
@DisplayName("ConfigSetting enum matches config file key/value pairs.")
void ConfigFileKeysContainsEnumKey(ConfigSetting configSetting) {
Assertions.assertEquals(configSetting.getValue(), plugin.getConfig().getString(configSetting.getKey()),
"Enum key " + configSetting.getKey() + " not found in config file.");
}
}
@Nested
@DisplayName("Test Sounds config.")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class SoundTests {
// collection of enum sound name strings
Collection<String> enumSoundNames = new HashSet<>();
// class constructor
SoundTests() {
// add all SoundId enum values to collection | for (com.winterhavenmc.deathchest.sounds.SoundId SoundId : SoundId.values()) { |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/ui/dialog/PermissionRationalDialogFragment.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/exception/MissingListenerException.java
// public class MissingListenerException extends RuntimeException {
//
// /**
// * Constructor for this exception class.
// *
// * @param listenerClass The Listener {@link Class}.
// * @param classExpectingListener The {@link Class} that discovered the missing Listener.
// */
// public MissingListenerException(final Class<?> listenerClass, final Class<?> classExpectingListener) {
// super("Class " + classExpectingListener.getName() + " expects the listener " + listenerClass.getCanonicalName() +
// " to be set.");
// }
//
// /**
// * Constructor for this exception class.
// *
// * @param listenerClass The Listener {@link Class}.
// * @param classToImplementListener The {@link Class} that should implement the Listener but does not.
// * @param classExpectingListener The {@link Class} that discovered the missing Listener.
// */
// public MissingListenerException(final Class<?> listenerClass, final Class<?> classToImplementListener, final Class<?> classExpectingListener) {
// super("Class " + classExpectingListener.getName() + " expects the class " + classToImplementListener.getName() +
// "to implement the listener " + listenerClass.getCanonicalName());
// }
// }
| import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.exception.MissingListenerException; | package com.chrynan.android_guitar_tuner.ui.dialog;
/**
* A {@link DialogFragment} that displays more information on why the AUDIO_RECORD permission is
* needed.
*/
public class PermissionRationalDialogFragment extends DialogFragment {
public static final String TAG = "PermissionRationalDialogFragment";
private DialogListener listener;
public static PermissionRationalDialogFragment newInstance() {
return new PermissionRationalDialogFragment();
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (DialogListener.class.isInstance(getParentFragment())) {
listener = (DialogListener) getParentFragment();
} else if (DialogListener.class.isInstance(getActivity())) {
listener = (DialogListener) getActivity();
} else {
Class<?> parentClazz = getParentFragment() != null ? getParentFragment().getClass() : getActivity().getClass();
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/exception/MissingListenerException.java
// public class MissingListenerException extends RuntimeException {
//
// /**
// * Constructor for this exception class.
// *
// * @param listenerClass The Listener {@link Class}.
// * @param classExpectingListener The {@link Class} that discovered the missing Listener.
// */
// public MissingListenerException(final Class<?> listenerClass, final Class<?> classExpectingListener) {
// super("Class " + classExpectingListener.getName() + " expects the listener " + listenerClass.getCanonicalName() +
// " to be set.");
// }
//
// /**
// * Constructor for this exception class.
// *
// * @param listenerClass The Listener {@link Class}.
// * @param classToImplementListener The {@link Class} that should implement the Listener but does not.
// * @param classExpectingListener The {@link Class} that discovered the missing Listener.
// */
// public MissingListenerException(final Class<?> listenerClass, final Class<?> classToImplementListener, final Class<?> classExpectingListener) {
// super("Class " + classExpectingListener.getName() + " expects the class " + classToImplementListener.getName() +
// "to implement the listener " + listenerClass.getCanonicalName());
// }
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/dialog/PermissionRationalDialogFragment.java
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.exception.MissingListenerException;
package com.chrynan.android_guitar_tuner.ui.dialog;
/**
* A {@link DialogFragment} that displays more information on why the AUDIO_RECORD permission is
* needed.
*/
public class PermissionRationalDialogFragment extends DialogFragment {
public static final String TAG = "PermissionRationalDialogFragment";
private DialogListener listener;
public static PermissionRationalDialogFragment newInstance() {
return new PermissionRationalDialogFragment();
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (DialogListener.class.isInstance(getParentFragment())) {
listener = (DialogListener) getParentFragment();
} else if (DialogListener.class.isInstance(getActivity())) {
listener = (DialogListener) getActivity();
} else {
Class<?> parentClazz = getParentFragment() != null ? getParentFragment().getClass() : getActivity().getClass();
| throw new MissingListenerException(DialogListener.class, parentClazz, PermissionRationalDialogFragment.class); |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/di/component/ApplicationComponent.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/GuitarTunerApplication.java
// public class GuitarTunerApplication extends Application {
//
// private static ApplicationComponent applicationComponent;
//
// public static ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Setup Logging
// if (BuildConfig.DEBUG) {
// // Uses the default Timber Debug Tree to output logs to LogCat
// Timber.plant(new Timber.DebugTree());
// }
//
// // Setup the Dagger Application Component
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// applicationComponent.inject(this);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final Application application;
//
// public ApplicationModule(final Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// @ApplicationContext
// Context provideApplicationContext() {
// return application;
// }
// }
| import android.content.Context;
import com.chrynan.android_guitar_tuner.GuitarTunerApplication;
import com.chrynan.android_guitar_tuner.di.ApplicationContext;
import com.chrynan.android_guitar_tuner.di.module.ApplicationModule;
import javax.inject.Singleton;
import dagger.Component; | package com.chrynan.android_guitar_tuner.di.component;
/**
* A Dagger {@link Component} that provides global dependencies.
*/
@Singleton
@Component(modules = ApplicationModule.class)
public interface ApplicationComponent {
@ApplicationContext
Context getApplicationContext();
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/GuitarTunerApplication.java
// public class GuitarTunerApplication extends Application {
//
// private static ApplicationComponent applicationComponent;
//
// public static ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Setup Logging
// if (BuildConfig.DEBUG) {
// // Uses the default Timber Debug Tree to output logs to LogCat
// Timber.plant(new Timber.DebugTree());
// }
//
// // Setup the Dagger Application Component
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// applicationComponent.inject(this);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final Application application;
//
// public ApplicationModule(final Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// @ApplicationContext
// Context provideApplicationContext() {
// return application;
// }
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/component/ApplicationComponent.java
import android.content.Context;
import com.chrynan.android_guitar_tuner.GuitarTunerApplication;
import com.chrynan.android_guitar_tuner.di.ApplicationContext;
import com.chrynan.android_guitar_tuner.di.module.ApplicationModule;
import javax.inject.Singleton;
import dagger.Component;
package com.chrynan.android_guitar_tuner.di.component;
/**
* A Dagger {@link Component} that provides global dependencies.
*/
@Singleton
@Component(modules = ApplicationModule.class)
public interface ApplicationComponent {
@ApplicationContext
Context getApplicationContext();
| void inject(GuitarTunerApplication application); |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/di/component/PitchViewComponent.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/module/PitchViewModule.java
// @Module
// public class PitchViewModule {
//
// private final PitchView view;
//
// public PitchViewModule(final PitchView view) {
// this.view = view;
// }
//
// @Provides
// @FragmentScope
// AudioManager provideAudioManager(@ApplicationContext final Context context) {
// return (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// }
//
// @Provides
// @FragmentScope
// AudioConfig provideAudioConfig() {
// return new AndroidAudioConfig();
// }
//
// @Provides
// @FragmentScope
// AudioPlayer provideAudioPlayer(final AudioConfig audioConfig) {
// return new AndroidAudioPlayer(audioConfig);
// }
//
// @Provides
// @FragmentScope
// FrequencyConverter provideFrequencyConverter(final AudioConfig audioConfig) {
// return new SineWaveFrequencyConverter(audioConfig);
// }
//
// @Provides
// @FragmentScope
// PitchPlayer providePitchPlayer(final AudioPlayer audioPlayer, final FrequencyConverter frequencyConverter) {
// return new GuitarPitchPlayer(audioPlayer, frequencyConverter);
// }
//
// @Provides
// @FragmentScope
// VolumeObserver provideVolumeObserver(final AudioManager audioManager) {
// return new AndroidVolumeObserver(audioManager);
// }
//
// @Provides
// @FragmentScope
// PitchPresenter providePitchPresenter(final PitchPlayer pitchPlayer, final VolumeObserver volumeObserver) {
// return new PitchPresenter(view, pitchPlayer, volumeObserver);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/fragment/PitchPlayerFragment.java
// public class PitchPlayerFragment extends BaseFragment implements PitchView {
//
// public static final String TAG = "PitchPlayerFragment";
// public static final String TITLE = "Pitch Playback";
//
// private static final String KEY_NOTE = "Note";
// private static final String KEY_FREQUENCY = "Frequency";
//
// @BindView(R.id.containerConstraintLayout)
// ConstraintLayout containerConstraintLayout;
// @BindView(R.id.noteTextView)
// TextView noteTextView;
// @BindView(R.id.volumeStateTextView)
// TextView volumeStateTextView;
//
// @Inject
// PitchPresenter presenter;
//
// private double frequency;
//
// private Snackbar snackBar;
//
// public static PitchPlayerFragment newInstance(final String note, final double frequency) {
// Bundle bundle = new Bundle();
// bundle.putString(KEY_NOTE, note);
// bundle.putDouble(KEY_FREQUENCY, frequency);
//
// PitchPlayerFragment fragment = new PitchPlayerFragment();
// fragment.setArguments(bundle);
//
// return fragment;
// }
//
// public PitchPlayerFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// View v = inflateAndBindView(inflater, R.layout.fragment_pitch_player, container, false);
//
// if (getArguments() != null) {
// String note = getArguments().getString(KEY_NOTE);
// frequency = getArguments().getDouble(KEY_FREQUENCY);
//
// noteTextView.setText(note);
// }
//
// return v;
// }
//
// @Override
// public void onResume() {
// super.onResume();
//
// presenter.startPlayingNote(frequency);
// presenter.startListeningToVolumeChanges();
// }
//
// @Override
// public void onPause() {
// super.onPause();
//
// presenter.stopPlayingNote();
// presenter.stopListeningToVolumeChanges();
//
// dismissSnackBar();
// }
//
// @Override
// public void onDestroyView() {
// super.onDestroyView();
//
// presenter.detachView();
//
// unbinder.unbind();
// }
//
// @Override
// protected void setupDaggerComponent() {
// DaggerPitchViewComponent.builder()
// .applicationComponent(GuitarTunerApplication.getApplicationComponent())
// .pitchViewModule(new PitchViewModule(this))
// .build()
// .inject(this);
// }
//
// @Override
// public void onUpdateVolumeState(@StringRes final int volumeStateText, @ColorRes final int textColor) {
// volumeStateTextView.setText(volumeStateText);
// volumeStateTextView.setTextColor(ContextCompat.getColor(getContext(), textColor));
// }
//
// @Override
// public void onErrorPlayingNote(@StringRes final int errorDescription, final boolean showAction,
// @StringRes final int errorAction, @ColorRes final int actionColor) {
// snackBar = Snackbar.make(containerConstraintLayout, errorDescription, Snackbar.LENGTH_INDEFINITE);
//
// if (showAction) {
// snackBar.setAction(errorAction, onClick -> presenter.retryPlayingNote(frequency))
// .setActionTextColor(ContextCompat.getColor(getContext(), actionColor));
// }
//
// snackBar.show();
// }
//
// private void dismissSnackBar() {
// if (snackBar != null) {
// snackBar.dismiss();
// }
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
| import com.chrynan.android_guitar_tuner.di.FragmentScope;
import com.chrynan.android_guitar_tuner.di.module.PitchViewModule;
import com.chrynan.android_guitar_tuner.ui.fragment.PitchPlayerFragment;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import dagger.Component; | package com.chrynan.android_guitar_tuner.di.component;
/**
* A Dagger {@link Component} used for dependency injection in a {@link PitchView} implementation.
*/
@SuppressWarnings("WeakerAccess")
@Component(
dependencies = ApplicationComponent.class, | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/module/PitchViewModule.java
// @Module
// public class PitchViewModule {
//
// private final PitchView view;
//
// public PitchViewModule(final PitchView view) {
// this.view = view;
// }
//
// @Provides
// @FragmentScope
// AudioManager provideAudioManager(@ApplicationContext final Context context) {
// return (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// }
//
// @Provides
// @FragmentScope
// AudioConfig provideAudioConfig() {
// return new AndroidAudioConfig();
// }
//
// @Provides
// @FragmentScope
// AudioPlayer provideAudioPlayer(final AudioConfig audioConfig) {
// return new AndroidAudioPlayer(audioConfig);
// }
//
// @Provides
// @FragmentScope
// FrequencyConverter provideFrequencyConverter(final AudioConfig audioConfig) {
// return new SineWaveFrequencyConverter(audioConfig);
// }
//
// @Provides
// @FragmentScope
// PitchPlayer providePitchPlayer(final AudioPlayer audioPlayer, final FrequencyConverter frequencyConverter) {
// return new GuitarPitchPlayer(audioPlayer, frequencyConverter);
// }
//
// @Provides
// @FragmentScope
// VolumeObserver provideVolumeObserver(final AudioManager audioManager) {
// return new AndroidVolumeObserver(audioManager);
// }
//
// @Provides
// @FragmentScope
// PitchPresenter providePitchPresenter(final PitchPlayer pitchPlayer, final VolumeObserver volumeObserver) {
// return new PitchPresenter(view, pitchPlayer, volumeObserver);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/fragment/PitchPlayerFragment.java
// public class PitchPlayerFragment extends BaseFragment implements PitchView {
//
// public static final String TAG = "PitchPlayerFragment";
// public static final String TITLE = "Pitch Playback";
//
// private static final String KEY_NOTE = "Note";
// private static final String KEY_FREQUENCY = "Frequency";
//
// @BindView(R.id.containerConstraintLayout)
// ConstraintLayout containerConstraintLayout;
// @BindView(R.id.noteTextView)
// TextView noteTextView;
// @BindView(R.id.volumeStateTextView)
// TextView volumeStateTextView;
//
// @Inject
// PitchPresenter presenter;
//
// private double frequency;
//
// private Snackbar snackBar;
//
// public static PitchPlayerFragment newInstance(final String note, final double frequency) {
// Bundle bundle = new Bundle();
// bundle.putString(KEY_NOTE, note);
// bundle.putDouble(KEY_FREQUENCY, frequency);
//
// PitchPlayerFragment fragment = new PitchPlayerFragment();
// fragment.setArguments(bundle);
//
// return fragment;
// }
//
// public PitchPlayerFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// View v = inflateAndBindView(inflater, R.layout.fragment_pitch_player, container, false);
//
// if (getArguments() != null) {
// String note = getArguments().getString(KEY_NOTE);
// frequency = getArguments().getDouble(KEY_FREQUENCY);
//
// noteTextView.setText(note);
// }
//
// return v;
// }
//
// @Override
// public void onResume() {
// super.onResume();
//
// presenter.startPlayingNote(frequency);
// presenter.startListeningToVolumeChanges();
// }
//
// @Override
// public void onPause() {
// super.onPause();
//
// presenter.stopPlayingNote();
// presenter.stopListeningToVolumeChanges();
//
// dismissSnackBar();
// }
//
// @Override
// public void onDestroyView() {
// super.onDestroyView();
//
// presenter.detachView();
//
// unbinder.unbind();
// }
//
// @Override
// protected void setupDaggerComponent() {
// DaggerPitchViewComponent.builder()
// .applicationComponent(GuitarTunerApplication.getApplicationComponent())
// .pitchViewModule(new PitchViewModule(this))
// .build()
// .inject(this);
// }
//
// @Override
// public void onUpdateVolumeState(@StringRes final int volumeStateText, @ColorRes final int textColor) {
// volumeStateTextView.setText(volumeStateText);
// volumeStateTextView.setTextColor(ContextCompat.getColor(getContext(), textColor));
// }
//
// @Override
// public void onErrorPlayingNote(@StringRes final int errorDescription, final boolean showAction,
// @StringRes final int errorAction, @ColorRes final int actionColor) {
// snackBar = Snackbar.make(containerConstraintLayout, errorDescription, Snackbar.LENGTH_INDEFINITE);
//
// if (showAction) {
// snackBar.setAction(errorAction, onClick -> presenter.retryPlayingNote(frequency))
// .setActionTextColor(ContextCompat.getColor(getContext(), actionColor));
// }
//
// snackBar.show();
// }
//
// private void dismissSnackBar() {
// if (snackBar != null) {
// snackBar.dismiss();
// }
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/component/PitchViewComponent.java
import com.chrynan.android_guitar_tuner.di.FragmentScope;
import com.chrynan.android_guitar_tuner.di.module.PitchViewModule;
import com.chrynan.android_guitar_tuner.ui.fragment.PitchPlayerFragment;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import dagger.Component;
package com.chrynan.android_guitar_tuner.di.component;
/**
* A Dagger {@link Component} used for dependency injection in a {@link PitchView} implementation.
*/
@SuppressWarnings("WeakerAccess")
@Component(
dependencies = ApplicationComponent.class, | modules = PitchViewModule.class |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/presenter/PitchPresenter.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/PitchPlayer.java
// public interface PitchPlayer {
//
// /**
// * Starts playing the provided frequency and returns a {@link Completable} that performs the
// * playing of the frequency.
// *
// * @param frequency The frequency to be played.
// * @return A {@link Completable} running the playing operation until unsubscribed.
// */
// Completable startPlaying(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeObserver.java
// public interface VolumeObserver {
//
// /**
// * Subscribes to the volume observer for volume states, either on an interval or changes to the
// * devices volume state.
// *
// * @return An {@link Observable<VolumeState>} providing the volume states as long as subscribed.
// */
// Observable<VolumeState> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeState.java
// public enum VolumeState {
//
// MUTED,
// UNMUTED;
//
// /**
// * Retrieves a {@link VolumeState} for the provided volume.
// *
// * @param volume The volume.
// * @return A {@link VolumeState} representing the provided volume.
// */
// public static VolumeState forVolume(final int volume) {
// if (volume < 1) {
// return MUTED;
// }
//
// return UNMUTED;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
| import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.tuner.PitchPlayer;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeObserver;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeState;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber; | package com.chrynan.android_guitar_tuner.presenter;
public class PitchPresenter implements Presenter {
private static final int RETRY_COUNT_MAX = 3;
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/PitchPlayer.java
// public interface PitchPlayer {
//
// /**
// * Starts playing the provided frequency and returns a {@link Completable} that performs the
// * playing of the frequency.
// *
// * @param frequency The frequency to be played.
// * @return A {@link Completable} running the playing operation until unsubscribed.
// */
// Completable startPlaying(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeObserver.java
// public interface VolumeObserver {
//
// /**
// * Subscribes to the volume observer for volume states, either on an interval or changes to the
// * devices volume state.
// *
// * @return An {@link Observable<VolumeState>} providing the volume states as long as subscribed.
// */
// Observable<VolumeState> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeState.java
// public enum VolumeState {
//
// MUTED,
// UNMUTED;
//
// /**
// * Retrieves a {@link VolumeState} for the provided volume.
// *
// * @param volume The volume.
// * @return A {@link VolumeState} representing the provided volume.
// */
// public static VolumeState forVolume(final int volume) {
// if (volume < 1) {
// return MUTED;
// }
//
// return UNMUTED;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/PitchPresenter.java
import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.tuner.PitchPlayer;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeObserver;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeState;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
package com.chrynan.android_guitar_tuner.presenter;
public class PitchPresenter implements Presenter {
private static final int RETRY_COUNT_MAX = 3;
| private final PitchView view; |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/presenter/PitchPresenter.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/PitchPlayer.java
// public interface PitchPlayer {
//
// /**
// * Starts playing the provided frequency and returns a {@link Completable} that performs the
// * playing of the frequency.
// *
// * @param frequency The frequency to be played.
// * @return A {@link Completable} running the playing operation until unsubscribed.
// */
// Completable startPlaying(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeObserver.java
// public interface VolumeObserver {
//
// /**
// * Subscribes to the volume observer for volume states, either on an interval or changes to the
// * devices volume state.
// *
// * @return An {@link Observable<VolumeState>} providing the volume states as long as subscribed.
// */
// Observable<VolumeState> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeState.java
// public enum VolumeState {
//
// MUTED,
// UNMUTED;
//
// /**
// * Retrieves a {@link VolumeState} for the provided volume.
// *
// * @param volume The volume.
// * @return A {@link VolumeState} representing the provided volume.
// */
// public static VolumeState forVolume(final int volume) {
// if (volume < 1) {
// return MUTED;
// }
//
// return UNMUTED;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
| import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.tuner.PitchPlayer;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeObserver;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeState;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber; | package com.chrynan.android_guitar_tuner.presenter;
public class PitchPresenter implements Presenter {
private static final int RETRY_COUNT_MAX = 3;
private final PitchView view; | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/PitchPlayer.java
// public interface PitchPlayer {
//
// /**
// * Starts playing the provided frequency and returns a {@link Completable} that performs the
// * playing of the frequency.
// *
// * @param frequency The frequency to be played.
// * @return A {@link Completable} running the playing operation until unsubscribed.
// */
// Completable startPlaying(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeObserver.java
// public interface VolumeObserver {
//
// /**
// * Subscribes to the volume observer for volume states, either on an interval or changes to the
// * devices volume state.
// *
// * @return An {@link Observable<VolumeState>} providing the volume states as long as subscribed.
// */
// Observable<VolumeState> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeState.java
// public enum VolumeState {
//
// MUTED,
// UNMUTED;
//
// /**
// * Retrieves a {@link VolumeState} for the provided volume.
// *
// * @param volume The volume.
// * @return A {@link VolumeState} representing the provided volume.
// */
// public static VolumeState forVolume(final int volume) {
// if (volume < 1) {
// return MUTED;
// }
//
// return UNMUTED;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/PitchPresenter.java
import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.tuner.PitchPlayer;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeObserver;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeState;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
package com.chrynan.android_guitar_tuner.presenter;
public class PitchPresenter implements Presenter {
private static final int RETRY_COUNT_MAX = 3;
private final PitchView view; | private final PitchPlayer pitchPlayer; |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/presenter/PitchPresenter.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/PitchPlayer.java
// public interface PitchPlayer {
//
// /**
// * Starts playing the provided frequency and returns a {@link Completable} that performs the
// * playing of the frequency.
// *
// * @param frequency The frequency to be played.
// * @return A {@link Completable} running the playing operation until unsubscribed.
// */
// Completable startPlaying(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeObserver.java
// public interface VolumeObserver {
//
// /**
// * Subscribes to the volume observer for volume states, either on an interval or changes to the
// * devices volume state.
// *
// * @return An {@link Observable<VolumeState>} providing the volume states as long as subscribed.
// */
// Observable<VolumeState> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeState.java
// public enum VolumeState {
//
// MUTED,
// UNMUTED;
//
// /**
// * Retrieves a {@link VolumeState} for the provided volume.
// *
// * @param volume The volume.
// * @return A {@link VolumeState} representing the provided volume.
// */
// public static VolumeState forVolume(final int volume) {
// if (volume < 1) {
// return MUTED;
// }
//
// return UNMUTED;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
| import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.tuner.PitchPlayer;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeObserver;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeState;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber; | package com.chrynan.android_guitar_tuner.presenter;
public class PitchPresenter implements Presenter {
private static final int RETRY_COUNT_MAX = 3;
private final PitchView view;
private final PitchPlayer pitchPlayer; | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/PitchPlayer.java
// public interface PitchPlayer {
//
// /**
// * Starts playing the provided frequency and returns a {@link Completable} that performs the
// * playing of the frequency.
// *
// * @param frequency The frequency to be played.
// * @return A {@link Completable} running the playing operation until unsubscribed.
// */
// Completable startPlaying(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeObserver.java
// public interface VolumeObserver {
//
// /**
// * Subscribes to the volume observer for volume states, either on an interval or changes to the
// * devices volume state.
// *
// * @return An {@link Observable<VolumeState>} providing the volume states as long as subscribed.
// */
// Observable<VolumeState> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeState.java
// public enum VolumeState {
//
// MUTED,
// UNMUTED;
//
// /**
// * Retrieves a {@link VolumeState} for the provided volume.
// *
// * @param volume The volume.
// * @return A {@link VolumeState} representing the provided volume.
// */
// public static VolumeState forVolume(final int volume) {
// if (volume < 1) {
// return MUTED;
// }
//
// return UNMUTED;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/PitchPresenter.java
import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.tuner.PitchPlayer;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeObserver;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeState;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
package com.chrynan.android_guitar_tuner.presenter;
public class PitchPresenter implements Presenter {
private static final int RETRY_COUNT_MAX = 3;
private final PitchView view;
private final PitchPlayer pitchPlayer; | private final VolumeObserver volumeObserver; |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/presenter/PitchPresenter.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/PitchPlayer.java
// public interface PitchPlayer {
//
// /**
// * Starts playing the provided frequency and returns a {@link Completable} that performs the
// * playing of the frequency.
// *
// * @param frequency The frequency to be played.
// * @return A {@link Completable} running the playing operation until unsubscribed.
// */
// Completable startPlaying(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeObserver.java
// public interface VolumeObserver {
//
// /**
// * Subscribes to the volume observer for volume states, either on an interval or changes to the
// * devices volume state.
// *
// * @return An {@link Observable<VolumeState>} providing the volume states as long as subscribed.
// */
// Observable<VolumeState> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeState.java
// public enum VolumeState {
//
// MUTED,
// UNMUTED;
//
// /**
// * Retrieves a {@link VolumeState} for the provided volume.
// *
// * @param volume The volume.
// * @return A {@link VolumeState} representing the provided volume.
// */
// public static VolumeState forVolume(final int volume) {
// if (volume < 1) {
// return MUTED;
// }
//
// return UNMUTED;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
| import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.tuner.PitchPlayer;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeObserver;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeState;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber; |
boolean showAction = retryCount < RETRY_COUNT_MAX;
int description = showAction ? R.string.pitch_player_error_playing_note_description_with_action
: R.string.pitch_player_error_playing_note_description_without_action;
view.onErrorPlayingNote(
description,
showAction,
R.string.pitch_player_error_playing_note_action,
R.color.snack_bar_action_color
);
});
}
public void retryPlayingNote(final double noteFrequency) {
retryCount++;
startPlayingNote(noteFrequency);
}
public void stopPlayingNote() {
if (pitchPlayerDisposable != null) {
pitchPlayerDisposable.dispose();
}
}
public void startListeningToVolumeChanges() {
volumeDisposable = volumeObserver.startListening()
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(state -> { | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/PitchPlayer.java
// public interface PitchPlayer {
//
// /**
// * Starts playing the provided frequency and returns a {@link Completable} that performs the
// * playing of the frequency.
// *
// * @param frequency The frequency to be played.
// * @return A {@link Completable} running the playing operation until unsubscribed.
// */
// Completable startPlaying(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeObserver.java
// public interface VolumeObserver {
//
// /**
// * Subscribes to the volume observer for volume states, either on an interval or changes to the
// * devices volume state.
// *
// * @return An {@link Observable<VolumeState>} providing the volume states as long as subscribed.
// */
// Observable<VolumeState> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/volume/VolumeState.java
// public enum VolumeState {
//
// MUTED,
// UNMUTED;
//
// /**
// * Retrieves a {@link VolumeState} for the provided volume.
// *
// * @param volume The volume.
// * @return A {@link VolumeState} representing the provided volume.
// */
// public static VolumeState forVolume(final int volume) {
// if (volume < 1) {
// return MUTED;
// }
//
// return UNMUTED;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/PitchView.java
// public interface PitchView {
//
// void onUpdateVolumeState(@StringRes int volumeStateText, @ColorRes int textColor);
//
// void onErrorPlayingNote(@StringRes int errorDescription, boolean showAction, @StringRes int errorAction, @ColorRes int actionColor);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/PitchPresenter.java
import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.tuner.PitchPlayer;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeObserver;
import com.chrynan.android_guitar_tuner.tuner.volume.VolumeState;
import com.chrynan.android_guitar_tuner.ui.view.PitchView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
boolean showAction = retryCount < RETRY_COUNT_MAX;
int description = showAction ? R.string.pitch_player_error_playing_note_description_with_action
: R.string.pitch_player_error_playing_note_description_without_action;
view.onErrorPlayingNote(
description,
showAction,
R.string.pitch_player_error_playing_note_action,
R.color.snack_bar_action_color
);
});
}
public void retryPlayingNote(final double noteFrequency) {
retryCount++;
startPlayingNote(noteFrequency);
}
public void stopPlayingNote() {
if (pitchPlayerDisposable != null) {
pitchPlayerDisposable.dispose();
}
}
public void startListeningToVolumeChanges() {
volumeDisposable = volumeObserver.startListening()
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(state -> { | if (state == VolumeState.MUTED) { |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarPitchPlayer.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/converter/FrequencyConverter.java
// public interface FrequencyConverter {
//
// /**
// * Converts the provided frequency value into a float array representing the audio waveform
// * data with values in the range [-1, 1].
// *
// * @param frequency The provided frequency to convert.
// * @return The audio waveform buffer representing the provided frequency.
// */
// float[] convert(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/player/AudioPlayer.java
// public interface AudioPlayer {
//
// /**
// * Starts playing the buffer provided in the {@link #setBuffer(float[])} method to the audio output.
// */
// void play();
//
// /**
// * Stops playing to the audio output the buffer provided in the {@link #setBuffer(float[])} method.
// */
// void stop();
//
// /**
// * Releases all the internal resources held by this AudioPlayer. This should be called when the
// * AudioPlayer is no longer needed and after a call to {@link #stop()}. After this method is
// * called, a new AudioPlayer will have to be created to play again.
// */
// void release();
//
// /**
// * Sets the audio waveform data that will be played to the audio output.
// *
// * @param waveformBuffer The waveform data to be played.
// */
// void setBuffer(float waveformBuffer[]);
// }
| import com.chrynan.android_guitar_tuner.tuner.converter.FrequencyConverter;
import com.chrynan.android_guitar_tuner.tuner.player.AudioPlayer;
import io.reactivex.Completable; | package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link PitchPlayer} interface.
*/
public class GuitarPitchPlayer implements PitchPlayer {
private final AudioPlayer audioPlayer; | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/converter/FrequencyConverter.java
// public interface FrequencyConverter {
//
// /**
// * Converts the provided frequency value into a float array representing the audio waveform
// * data with values in the range [-1, 1].
// *
// * @param frequency The provided frequency to convert.
// * @return The audio waveform buffer representing the provided frequency.
// */
// float[] convert(double frequency);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/player/AudioPlayer.java
// public interface AudioPlayer {
//
// /**
// * Starts playing the buffer provided in the {@link #setBuffer(float[])} method to the audio output.
// */
// void play();
//
// /**
// * Stops playing to the audio output the buffer provided in the {@link #setBuffer(float[])} method.
// */
// void stop();
//
// /**
// * Releases all the internal resources held by this AudioPlayer. This should be called when the
// * AudioPlayer is no longer needed and after a call to {@link #stop()}. After this method is
// * called, a new AudioPlayer will have to be created to play again.
// */
// void release();
//
// /**
// * Sets the audio waveform data that will be played to the audio output.
// *
// * @param waveformBuffer The waveform data to be played.
// */
// void setBuffer(float waveformBuffer[]);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarPitchPlayer.java
import com.chrynan.android_guitar_tuner.tuner.converter.FrequencyConverter;
import com.chrynan.android_guitar_tuner.tuner.player.AudioPlayer;
import io.reactivex.Completable;
package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link PitchPlayer} interface.
*/
public class GuitarPitchPlayer implements PitchPlayer {
private final AudioPlayer audioPlayer; | private final FrequencyConverter frequencyConverter; |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/tuner/converter/SineWaveFrequencyConverter.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
| import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig; | package com.chrynan.android_guitar_tuner.tuner.converter;
/**
* An implementation of the {@link FrequencyConverter} interface that converts a provided frequency
* value into a perfect sinusoidal waveform array buffer.
*/
public class SineWaveFrequencyConverter implements FrequencyConverter {
private static final double TWO_PI = 2 * Math.PI;
private final int sampleRate;
private final int initialWriteBufferSize;
private final int outputFormatByteCount;
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/converter/SineWaveFrequencyConverter.java
import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig;
package com.chrynan.android_guitar_tuner.tuner.converter;
/**
* An implementation of the {@link FrequencyConverter} interface that converts a provided frequency
* value into a perfect sinusoidal waveform array buffer.
*/
public class SineWaveFrequencyConverter implements FrequencyConverter {
private static final double TWO_PI = 2 * Math.PI;
private final int sampleRate;
private final int initialWriteBufferSize;
private final int outputFormatByteCount;
| public SineWaveFrequencyConverter(final AudioConfig audioConfig) { |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/presenter/TunerPresenter.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/Tuner.java
// public interface Tuner {
//
// /**
// * Subscribes to the tuner for notes found as a result of a pitch detection algorithm.
// *
// * @return An {@link Observable<Note>} providing all the found {@link Note}s for as long as subscribed.
// */
// Observable<Note> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/FrequencyFinder.java
// public interface FrequencyFinder {
//
// /**
// * Retrieves a frequency for the provided note name.
// *
// * @param name The name of the note whose frequency is being retrieved.
// * @return The frequency representing the provided note name.
// */
// double getFrequency(NoteName name);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteName.java
// public enum NoteName {
//
// A("A"),
// A_SHARP("A♯"),
// B("B"),
// C("C"),
// C_SHARP("C♯"),
// D("D"),
// D_SHARP("D♯"),
// E("E"),
// F("F"),
// F_SHARP("F♯"),
// G("G"),
// G_SHARP("G♯"),
// UNDEFINED("Undefined");
//
// /**
// * Retrieves a {@link NoteName} object represented by the provided String name.
// *
// * @param name The String name.
// * @return A {@link NoteName} representing the provided String name.
// */
// public static NoteName forName(final String name) {
// if (name != null) {
// String updatedName = name.trim().toUpperCase().replace('#', '♯');
//
// try {
// for (NoteName noteName : values()) {
// if (noteName.getName().equals(updatedName)) {
// return noteName;
// }
// }
// } catch (IllegalArgumentException e) {
// // No operation
// }
// }
//
// return UNDEFINED;
// }
//
// private String name;
//
// NoteName(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/TunerView.java
// public interface TunerView {
//
// void onShowNote(String noteName, double frequency, float percentOffset);
//
// void onPlayNote(String noteName, double frequency, float x, float y);
// }
| import com.chrynan.android_guitar_tuner.tuner.Tuner;
import com.chrynan.android_guitar_tuner.tuner.note.FrequencyFinder;
import com.chrynan.android_guitar_tuner.tuner.note.NoteName;
import com.chrynan.android_guitar_tuner.ui.view.TunerView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber; | package com.chrynan.android_guitar_tuner.presenter;
public class TunerPresenter implements Presenter {
private final TunerView view; | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/Tuner.java
// public interface Tuner {
//
// /**
// * Subscribes to the tuner for notes found as a result of a pitch detection algorithm.
// *
// * @return An {@link Observable<Note>} providing all the found {@link Note}s for as long as subscribed.
// */
// Observable<Note> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/FrequencyFinder.java
// public interface FrequencyFinder {
//
// /**
// * Retrieves a frequency for the provided note name.
// *
// * @param name The name of the note whose frequency is being retrieved.
// * @return The frequency representing the provided note name.
// */
// double getFrequency(NoteName name);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteName.java
// public enum NoteName {
//
// A("A"),
// A_SHARP("A♯"),
// B("B"),
// C("C"),
// C_SHARP("C♯"),
// D("D"),
// D_SHARP("D♯"),
// E("E"),
// F("F"),
// F_SHARP("F♯"),
// G("G"),
// G_SHARP("G♯"),
// UNDEFINED("Undefined");
//
// /**
// * Retrieves a {@link NoteName} object represented by the provided String name.
// *
// * @param name The String name.
// * @return A {@link NoteName} representing the provided String name.
// */
// public static NoteName forName(final String name) {
// if (name != null) {
// String updatedName = name.trim().toUpperCase().replace('#', '♯');
//
// try {
// for (NoteName noteName : values()) {
// if (noteName.getName().equals(updatedName)) {
// return noteName;
// }
// }
// } catch (IllegalArgumentException e) {
// // No operation
// }
// }
//
// return UNDEFINED;
// }
//
// private String name;
//
// NoteName(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/TunerView.java
// public interface TunerView {
//
// void onShowNote(String noteName, double frequency, float percentOffset);
//
// void onPlayNote(String noteName, double frequency, float x, float y);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/TunerPresenter.java
import com.chrynan.android_guitar_tuner.tuner.Tuner;
import com.chrynan.android_guitar_tuner.tuner.note.FrequencyFinder;
import com.chrynan.android_guitar_tuner.tuner.note.NoteName;
import com.chrynan.android_guitar_tuner.ui.view.TunerView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
package com.chrynan.android_guitar_tuner.presenter;
public class TunerPresenter implements Presenter {
private final TunerView view; | private final Tuner tuner; |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/presenter/TunerPresenter.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/Tuner.java
// public interface Tuner {
//
// /**
// * Subscribes to the tuner for notes found as a result of a pitch detection algorithm.
// *
// * @return An {@link Observable<Note>} providing all the found {@link Note}s for as long as subscribed.
// */
// Observable<Note> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/FrequencyFinder.java
// public interface FrequencyFinder {
//
// /**
// * Retrieves a frequency for the provided note name.
// *
// * @param name The name of the note whose frequency is being retrieved.
// * @return The frequency representing the provided note name.
// */
// double getFrequency(NoteName name);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteName.java
// public enum NoteName {
//
// A("A"),
// A_SHARP("A♯"),
// B("B"),
// C("C"),
// C_SHARP("C♯"),
// D("D"),
// D_SHARP("D♯"),
// E("E"),
// F("F"),
// F_SHARP("F♯"),
// G("G"),
// G_SHARP("G♯"),
// UNDEFINED("Undefined");
//
// /**
// * Retrieves a {@link NoteName} object represented by the provided String name.
// *
// * @param name The String name.
// * @return A {@link NoteName} representing the provided String name.
// */
// public static NoteName forName(final String name) {
// if (name != null) {
// String updatedName = name.trim().toUpperCase().replace('#', '♯');
//
// try {
// for (NoteName noteName : values()) {
// if (noteName.getName().equals(updatedName)) {
// return noteName;
// }
// }
// } catch (IllegalArgumentException e) {
// // No operation
// }
// }
//
// return UNDEFINED;
// }
//
// private String name;
//
// NoteName(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/TunerView.java
// public interface TunerView {
//
// void onShowNote(String noteName, double frequency, float percentOffset);
//
// void onPlayNote(String noteName, double frequency, float x, float y);
// }
| import com.chrynan.android_guitar_tuner.tuner.Tuner;
import com.chrynan.android_guitar_tuner.tuner.note.FrequencyFinder;
import com.chrynan.android_guitar_tuner.tuner.note.NoteName;
import com.chrynan.android_guitar_tuner.ui.view.TunerView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber; | package com.chrynan.android_guitar_tuner.presenter;
public class TunerPresenter implements Presenter {
private final TunerView view;
private final Tuner tuner; | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/Tuner.java
// public interface Tuner {
//
// /**
// * Subscribes to the tuner for notes found as a result of a pitch detection algorithm.
// *
// * @return An {@link Observable<Note>} providing all the found {@link Note}s for as long as subscribed.
// */
// Observable<Note> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/FrequencyFinder.java
// public interface FrequencyFinder {
//
// /**
// * Retrieves a frequency for the provided note name.
// *
// * @param name The name of the note whose frequency is being retrieved.
// * @return The frequency representing the provided note name.
// */
// double getFrequency(NoteName name);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteName.java
// public enum NoteName {
//
// A("A"),
// A_SHARP("A♯"),
// B("B"),
// C("C"),
// C_SHARP("C♯"),
// D("D"),
// D_SHARP("D♯"),
// E("E"),
// F("F"),
// F_SHARP("F♯"),
// G("G"),
// G_SHARP("G♯"),
// UNDEFINED("Undefined");
//
// /**
// * Retrieves a {@link NoteName} object represented by the provided String name.
// *
// * @param name The String name.
// * @return A {@link NoteName} representing the provided String name.
// */
// public static NoteName forName(final String name) {
// if (name != null) {
// String updatedName = name.trim().toUpperCase().replace('#', '♯');
//
// try {
// for (NoteName noteName : values()) {
// if (noteName.getName().equals(updatedName)) {
// return noteName;
// }
// }
// } catch (IllegalArgumentException e) {
// // No operation
// }
// }
//
// return UNDEFINED;
// }
//
// private String name;
//
// NoteName(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/TunerView.java
// public interface TunerView {
//
// void onShowNote(String noteName, double frequency, float percentOffset);
//
// void onPlayNote(String noteName, double frequency, float x, float y);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/TunerPresenter.java
import com.chrynan.android_guitar_tuner.tuner.Tuner;
import com.chrynan.android_guitar_tuner.tuner.note.FrequencyFinder;
import com.chrynan.android_guitar_tuner.tuner.note.NoteName;
import com.chrynan.android_guitar_tuner.ui.view.TunerView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
package com.chrynan.android_guitar_tuner.presenter;
public class TunerPresenter implements Presenter {
private final TunerView view;
private final Tuner tuner; | private final FrequencyFinder frequencyFinder; |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/presenter/TunerPresenter.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/Tuner.java
// public interface Tuner {
//
// /**
// * Subscribes to the tuner for notes found as a result of a pitch detection algorithm.
// *
// * @return An {@link Observable<Note>} providing all the found {@link Note}s for as long as subscribed.
// */
// Observable<Note> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/FrequencyFinder.java
// public interface FrequencyFinder {
//
// /**
// * Retrieves a frequency for the provided note name.
// *
// * @param name The name of the note whose frequency is being retrieved.
// * @return The frequency representing the provided note name.
// */
// double getFrequency(NoteName name);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteName.java
// public enum NoteName {
//
// A("A"),
// A_SHARP("A♯"),
// B("B"),
// C("C"),
// C_SHARP("C♯"),
// D("D"),
// D_SHARP("D♯"),
// E("E"),
// F("F"),
// F_SHARP("F♯"),
// G("G"),
// G_SHARP("G♯"),
// UNDEFINED("Undefined");
//
// /**
// * Retrieves a {@link NoteName} object represented by the provided String name.
// *
// * @param name The String name.
// * @return A {@link NoteName} representing the provided String name.
// */
// public static NoteName forName(final String name) {
// if (name != null) {
// String updatedName = name.trim().toUpperCase().replace('#', '♯');
//
// try {
// for (NoteName noteName : values()) {
// if (noteName.getName().equals(updatedName)) {
// return noteName;
// }
// }
// } catch (IllegalArgumentException e) {
// // No operation
// }
// }
//
// return UNDEFINED;
// }
//
// private String name;
//
// NoteName(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/TunerView.java
// public interface TunerView {
//
// void onShowNote(String noteName, double frequency, float percentOffset);
//
// void onPlayNote(String noteName, double frequency, float x, float y);
// }
| import com.chrynan.android_guitar_tuner.tuner.Tuner;
import com.chrynan.android_guitar_tuner.tuner.note.FrequencyFinder;
import com.chrynan.android_guitar_tuner.tuner.note.NoteName;
import com.chrynan.android_guitar_tuner.ui.view.TunerView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber; | package com.chrynan.android_guitar_tuner.presenter;
public class TunerPresenter implements Presenter {
private final TunerView view;
private final Tuner tuner;
private final FrequencyFinder frequencyFinder;
private Disposable disposable;
public TunerPresenter(final TunerView view, final Tuner tuner, final FrequencyFinder frequencyFinder) {
this.view = view;
this.tuner = tuner;
this.frequencyFinder = frequencyFinder;
}
@Override
public void detachView() {
// No Operation
}
public void startListeningForNotes() {
disposable = tuner.startListening()
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(note -> view.onShowNote(note.getName(), note.getFrequency(), note.getPercentOffset()),
error -> Timber.e(error, "Error Starting to Listen to Notes."));
}
public void stopListeningForNotes() {
if (disposable != null) {
disposable.dispose();
}
}
public void notePressed(final String noteName, final float x, final float y) { | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/Tuner.java
// public interface Tuner {
//
// /**
// * Subscribes to the tuner for notes found as a result of a pitch detection algorithm.
// *
// * @return An {@link Observable<Note>} providing all the found {@link Note}s for as long as subscribed.
// */
// Observable<Note> startListening();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/FrequencyFinder.java
// public interface FrequencyFinder {
//
// /**
// * Retrieves a frequency for the provided note name.
// *
// * @param name The name of the note whose frequency is being retrieved.
// * @return The frequency representing the provided note name.
// */
// double getFrequency(NoteName name);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteName.java
// public enum NoteName {
//
// A("A"),
// A_SHARP("A♯"),
// B("B"),
// C("C"),
// C_SHARP("C♯"),
// D("D"),
// D_SHARP("D♯"),
// E("E"),
// F("F"),
// F_SHARP("F♯"),
// G("G"),
// G_SHARP("G♯"),
// UNDEFINED("Undefined");
//
// /**
// * Retrieves a {@link NoteName} object represented by the provided String name.
// *
// * @param name The String name.
// * @return A {@link NoteName} representing the provided String name.
// */
// public static NoteName forName(final String name) {
// if (name != null) {
// String updatedName = name.trim().toUpperCase().replace('#', '♯');
//
// try {
// for (NoteName noteName : values()) {
// if (noteName.getName().equals(updatedName)) {
// return noteName;
// }
// }
// } catch (IllegalArgumentException e) {
// // No operation
// }
// }
//
// return UNDEFINED;
// }
//
// private String name;
//
// NoteName(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/TunerView.java
// public interface TunerView {
//
// void onShowNote(String noteName, double frequency, float percentOffset);
//
// void onPlayNote(String noteName, double frequency, float x, float y);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/TunerPresenter.java
import com.chrynan.android_guitar_tuner.tuner.Tuner;
import com.chrynan.android_guitar_tuner.tuner.note.FrequencyFinder;
import com.chrynan.android_guitar_tuner.tuner.note.NoteName;
import com.chrynan.android_guitar_tuner.ui.view.TunerView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
package com.chrynan.android_guitar_tuner.presenter;
public class TunerPresenter implements Presenter {
private final TunerView view;
private final Tuner tuner;
private final FrequencyFinder frequencyFinder;
private Disposable disposable;
public TunerPresenter(final TunerView view, final Tuner tuner, final FrequencyFinder frequencyFinder) {
this.view = view;
this.tuner = tuner;
this.frequencyFinder = frequencyFinder;
}
@Override
public void detachView() {
// No Operation
}
public void startListeningForNotes() {
disposable = tuner.startListening()
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(note -> view.onShowNote(note.getName(), note.getFrequency(), note.getPercentOffset()),
error -> Timber.e(error, "Error Starting to Listen to Notes."));
}
public void stopListeningForNotes() {
if (disposable != null) {
disposable.dispose();
}
}
public void notePressed(final String noteName, final float x, final float y) { | view.onPlayNote(noteName, frequencyFinder.getFrequency(NoteName.forName(noteName)), x, y); |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/YINPitchDetector.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
| import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig; | package com.chrynan.android_guitar_tuner.tuner.detection;
/**
* A {@link PitchDetector} implementation that uses a YIN algorithm to determine the frequency of
* the provided waveform data. The YIN algorithm is similar to the Auto-correlation Function used
* for pitch detection but adds additional steps to better the accuracy of the results. Each step
* lowers the error rate further. The following implementation was inspired by
* <a href="https://github.com/JorenSix/TarsosDSP/blob/master/src/core/be/tarsos/dsp/pitch/Yin.java">TarsosDsp</a>
* and
* <a href="http://recherche.ircam.fr/equipes/pcm/cheveign/ps/2002_JASA_YIN_proof.pdf">this YIN paper</a>.
* The six steps in the YIN algorithm are (according to the YIN paper):
* <p>
* <ol>
* <li>Auto-correlation Method</li>
* <li>Difference Function</li>
* <li>Cumulative Mean Normalized Difference Function</li>
* <li>Absolute Threshold</li>
* <li>Parabolic Interpolation</li>
* <li>Best Local Estimate</li>
* </ol>
* </p>
* The first two steps, the Auto-correlation Method and the Difference Function, can seemingly be
* combined into a single difference function step according to the YIN paper.
*/
public class YINPitchDetector implements PitchDetector {
// According to the YIN Paper, the threshold should be between 0.10 and 0.15
private static final float ABSOLUTE_THRESHOLD = 0.125f;
private final double sampleRate;
private final float[] resultBuffer;
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/YINPitchDetector.java
import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig;
package com.chrynan.android_guitar_tuner.tuner.detection;
/**
* A {@link PitchDetector} implementation that uses a YIN algorithm to determine the frequency of
* the provided waveform data. The YIN algorithm is similar to the Auto-correlation Function used
* for pitch detection but adds additional steps to better the accuracy of the results. Each step
* lowers the error rate further. The following implementation was inspired by
* <a href="https://github.com/JorenSix/TarsosDSP/blob/master/src/core/be/tarsos/dsp/pitch/Yin.java">TarsosDsp</a>
* and
* <a href="http://recherche.ircam.fr/equipes/pcm/cheveign/ps/2002_JASA_YIN_proof.pdf">this YIN paper</a>.
* The six steps in the YIN algorithm are (according to the YIN paper):
* <p>
* <ol>
* <li>Auto-correlation Method</li>
* <li>Difference Function</li>
* <li>Cumulative Mean Normalized Difference Function</li>
* <li>Absolute Threshold</li>
* <li>Parabolic Interpolation</li>
* <li>Best Local Estimate</li>
* </ol>
* </p>
* The first two steps, the Auto-correlation Method and the Difference Function, can seemingly be
* combined into a single difference function step according to the YIN paper.
*/
public class YINPitchDetector implements PitchDetector {
// According to the YIN Paper, the threshold should be between 0.10 and 0.15
private static final float ABSOLUTE_THRESHOLD = 0.125f;
private final double sampleRate;
private final float[] resultBuffer;
| public YINPitchDetector(final AudioConfig audioConfig) { |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/tuner/player/AndroidAudioPlayer.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
| import android.media.AudioAttributes;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig; | package com.chrynan.android_guitar_tuner.tuner.player;
/**
* An Android implementation of the {@link AudioPlayer} interface that works with the Android
* {@link android.media.AudioTrack} object.
*/
public class AndroidAudioPlayer implements AudioPlayer {
private static final int LOOP_COUNT_INFINITE = -1;
private final AudioTrack audioTrack;
private final int outputByteCount;
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/player/AndroidAudioPlayer.java
import android.media.AudioAttributes;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig;
package com.chrynan.android_guitar_tuner.tuner.player;
/**
* An Android implementation of the {@link AudioPlayer} interface that works with the Android
* {@link android.media.AudioTrack} object.
*/
public class AndroidAudioPlayer implements AudioPlayer {
private static final int LOOP_COUNT_INFINITE = -1;
private final AudioTrack audioTrack;
private final int outputByteCount;
| public AndroidAudioPlayer(final AudioConfig audioConfig) { |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarTuner.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/PitchDetector.java
// public interface PitchDetector {
//
// /**
// * Retrieves a pitch frequency (note) using the provided array of values representing a sound
// * wave. Note that this method operates on the calling Thread. The calling Thread should be off
// * the main Thread.
// *
// * @param wave The array of 16 bit values representing the sound wave to be processed.
// * @return A double value representing the detected pitch.
// */
// double detect(float[] wave);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/MutableNote.java
// public class MutableNote implements NoteMutator {
//
// private String name;
// private double frequency;
// private float percentOffset;
//
// public MutableNote() {
// // Default constructor
// }
//
// MutableNote(final String name, final double frequency, final float percentOffset) {
// this.name = name;
// this.frequency = frequency;
// this.percentOffset = percentOffset;
//
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public double getFrequency() {
// return frequency;
// }
//
// @Override
// public float getPercentOffset() {
// return percentOffset;
// }
//
// @Override
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public void setFrequency(final double frequency) {
// this.frequency = frequency;
// }
//
// @Override
// public void setPercentOffset(final float percentOffset) {
// this.percentOffset = percentOffset;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// MutableNote note = (MutableNote) o;
// return Double.compare(note.frequency, frequency) == 0 &&
// Float.compare(note.percentOffset, percentOffset) == 0 &&
// Objects.equals(name, note.name);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, frequency, percentOffset);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/Note.java
// public interface Note {
//
// /**
// * Retrieves the name of the note.
// *
// * @return A String representing the name of the note.
// */
// String getName();
//
// /**
// * Retrieves the frequency value of the closest found note.
// *
// * @return A double value representing the frequency of the closest note.
// */
// double getFrequency();
//
// /**
// * Retrieves the percent offset from the closest found note and the actual found frequency.
// *
// * @return A float value representing the percent offset from the note.
// */
// float getPercentOffset();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteFinder.java
// public interface NoteFinder {
//
// /**
// * Sets the frequency of the note. This method must be called before calling the other methods.
// * Failure to do so may result in unspecified behavior.
// *
// * @param frequency The frequency of the note.
// */
// void setFrequency(double frequency);
//
// /**
// * Retrieves a String representation of the closest note to the provided frequency.
// *
// * @return The String note name.
// */
// String getNoteName();
//
// /**
// * Retrieves the percent difference between the closest found note and the provided frequency.
// * It is an offset in percentage between the closest note and the second closest note. A
// * negative value will indicate it is a lower pitch than the closest found note and a positive
// * value will indicate it is a higher pitch than the closest found note.
// *
// * @return The percent offset from the closest note.
// */
// float getPercentageDifference();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AudioRecorder.java
// public interface AudioRecorder {
//
// /**
// * Starts listening to audio data and prepares for a call to the {@link #readNext()} method.
// * Note that this method should be called before calling the {@link #readNext()} method to
// * prepare the recorder.
// */
// void startRecording();
//
// /**
// * Stops listening to audio data and cleans up any underlying resources used by the
// * implementation. Note that {@link #readNext()} should not be called after this method is
// * called without calling {@link #startRecording()} again.
// */
// void stopRecording();
//
// /**
// * Reads audio data into an array buffer and returns it. Note that the returned array may be
// * mutable depending on the implementation to provide better performance.
// *
// * @return A float array of audio data.
// */
// float[] readNext();
// }
| import com.chrynan.android_guitar_tuner.tuner.detection.PitchDetector;
import com.chrynan.android_guitar_tuner.tuner.note.MutableNote;
import com.chrynan.android_guitar_tuner.tuner.note.Note;
import com.chrynan.android_guitar_tuner.tuner.note.NoteFinder;
import com.chrynan.android_guitar_tuner.tuner.recorder.AudioRecorder;
import io.reactivex.Observable; | package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link Tuner} interface.
*/
public class GuitarTuner implements Tuner {
private final MutableNote note = new MutableNote();
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/PitchDetector.java
// public interface PitchDetector {
//
// /**
// * Retrieves a pitch frequency (note) using the provided array of values representing a sound
// * wave. Note that this method operates on the calling Thread. The calling Thread should be off
// * the main Thread.
// *
// * @param wave The array of 16 bit values representing the sound wave to be processed.
// * @return A double value representing the detected pitch.
// */
// double detect(float[] wave);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/MutableNote.java
// public class MutableNote implements NoteMutator {
//
// private String name;
// private double frequency;
// private float percentOffset;
//
// public MutableNote() {
// // Default constructor
// }
//
// MutableNote(final String name, final double frequency, final float percentOffset) {
// this.name = name;
// this.frequency = frequency;
// this.percentOffset = percentOffset;
//
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public double getFrequency() {
// return frequency;
// }
//
// @Override
// public float getPercentOffset() {
// return percentOffset;
// }
//
// @Override
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public void setFrequency(final double frequency) {
// this.frequency = frequency;
// }
//
// @Override
// public void setPercentOffset(final float percentOffset) {
// this.percentOffset = percentOffset;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// MutableNote note = (MutableNote) o;
// return Double.compare(note.frequency, frequency) == 0 &&
// Float.compare(note.percentOffset, percentOffset) == 0 &&
// Objects.equals(name, note.name);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, frequency, percentOffset);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/Note.java
// public interface Note {
//
// /**
// * Retrieves the name of the note.
// *
// * @return A String representing the name of the note.
// */
// String getName();
//
// /**
// * Retrieves the frequency value of the closest found note.
// *
// * @return A double value representing the frequency of the closest note.
// */
// double getFrequency();
//
// /**
// * Retrieves the percent offset from the closest found note and the actual found frequency.
// *
// * @return A float value representing the percent offset from the note.
// */
// float getPercentOffset();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteFinder.java
// public interface NoteFinder {
//
// /**
// * Sets the frequency of the note. This method must be called before calling the other methods.
// * Failure to do so may result in unspecified behavior.
// *
// * @param frequency The frequency of the note.
// */
// void setFrequency(double frequency);
//
// /**
// * Retrieves a String representation of the closest note to the provided frequency.
// *
// * @return The String note name.
// */
// String getNoteName();
//
// /**
// * Retrieves the percent difference between the closest found note and the provided frequency.
// * It is an offset in percentage between the closest note and the second closest note. A
// * negative value will indicate it is a lower pitch than the closest found note and a positive
// * value will indicate it is a higher pitch than the closest found note.
// *
// * @return The percent offset from the closest note.
// */
// float getPercentageDifference();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AudioRecorder.java
// public interface AudioRecorder {
//
// /**
// * Starts listening to audio data and prepares for a call to the {@link #readNext()} method.
// * Note that this method should be called before calling the {@link #readNext()} method to
// * prepare the recorder.
// */
// void startRecording();
//
// /**
// * Stops listening to audio data and cleans up any underlying resources used by the
// * implementation. Note that {@link #readNext()} should not be called after this method is
// * called without calling {@link #startRecording()} again.
// */
// void stopRecording();
//
// /**
// * Reads audio data into an array buffer and returns it. Note that the returned array may be
// * mutable depending on the implementation to provide better performance.
// *
// * @return A float array of audio data.
// */
// float[] readNext();
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarTuner.java
import com.chrynan.android_guitar_tuner.tuner.detection.PitchDetector;
import com.chrynan.android_guitar_tuner.tuner.note.MutableNote;
import com.chrynan.android_guitar_tuner.tuner.note.Note;
import com.chrynan.android_guitar_tuner.tuner.note.NoteFinder;
import com.chrynan.android_guitar_tuner.tuner.recorder.AudioRecorder;
import io.reactivex.Observable;
package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link Tuner} interface.
*/
public class GuitarTuner implements Tuner {
private final MutableNote note = new MutableNote();
| private final Observable<Note> observable; |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarTuner.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/PitchDetector.java
// public interface PitchDetector {
//
// /**
// * Retrieves a pitch frequency (note) using the provided array of values representing a sound
// * wave. Note that this method operates on the calling Thread. The calling Thread should be off
// * the main Thread.
// *
// * @param wave The array of 16 bit values representing the sound wave to be processed.
// * @return A double value representing the detected pitch.
// */
// double detect(float[] wave);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/MutableNote.java
// public class MutableNote implements NoteMutator {
//
// private String name;
// private double frequency;
// private float percentOffset;
//
// public MutableNote() {
// // Default constructor
// }
//
// MutableNote(final String name, final double frequency, final float percentOffset) {
// this.name = name;
// this.frequency = frequency;
// this.percentOffset = percentOffset;
//
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public double getFrequency() {
// return frequency;
// }
//
// @Override
// public float getPercentOffset() {
// return percentOffset;
// }
//
// @Override
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public void setFrequency(final double frequency) {
// this.frequency = frequency;
// }
//
// @Override
// public void setPercentOffset(final float percentOffset) {
// this.percentOffset = percentOffset;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// MutableNote note = (MutableNote) o;
// return Double.compare(note.frequency, frequency) == 0 &&
// Float.compare(note.percentOffset, percentOffset) == 0 &&
// Objects.equals(name, note.name);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, frequency, percentOffset);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/Note.java
// public interface Note {
//
// /**
// * Retrieves the name of the note.
// *
// * @return A String representing the name of the note.
// */
// String getName();
//
// /**
// * Retrieves the frequency value of the closest found note.
// *
// * @return A double value representing the frequency of the closest note.
// */
// double getFrequency();
//
// /**
// * Retrieves the percent offset from the closest found note and the actual found frequency.
// *
// * @return A float value representing the percent offset from the note.
// */
// float getPercentOffset();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteFinder.java
// public interface NoteFinder {
//
// /**
// * Sets the frequency of the note. This method must be called before calling the other methods.
// * Failure to do so may result in unspecified behavior.
// *
// * @param frequency The frequency of the note.
// */
// void setFrequency(double frequency);
//
// /**
// * Retrieves a String representation of the closest note to the provided frequency.
// *
// * @return The String note name.
// */
// String getNoteName();
//
// /**
// * Retrieves the percent difference between the closest found note and the provided frequency.
// * It is an offset in percentage between the closest note and the second closest note. A
// * negative value will indicate it is a lower pitch than the closest found note and a positive
// * value will indicate it is a higher pitch than the closest found note.
// *
// * @return The percent offset from the closest note.
// */
// float getPercentageDifference();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AudioRecorder.java
// public interface AudioRecorder {
//
// /**
// * Starts listening to audio data and prepares for a call to the {@link #readNext()} method.
// * Note that this method should be called before calling the {@link #readNext()} method to
// * prepare the recorder.
// */
// void startRecording();
//
// /**
// * Stops listening to audio data and cleans up any underlying resources used by the
// * implementation. Note that {@link #readNext()} should not be called after this method is
// * called without calling {@link #startRecording()} again.
// */
// void stopRecording();
//
// /**
// * Reads audio data into an array buffer and returns it. Note that the returned array may be
// * mutable depending on the implementation to provide better performance.
// *
// * @return A float array of audio data.
// */
// float[] readNext();
// }
| import com.chrynan.android_guitar_tuner.tuner.detection.PitchDetector;
import com.chrynan.android_guitar_tuner.tuner.note.MutableNote;
import com.chrynan.android_guitar_tuner.tuner.note.Note;
import com.chrynan.android_guitar_tuner.tuner.note.NoteFinder;
import com.chrynan.android_guitar_tuner.tuner.recorder.AudioRecorder;
import io.reactivex.Observable; | package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link Tuner} interface.
*/
public class GuitarTuner implements Tuner {
private final MutableNote note = new MutableNote();
private final Observable<Note> observable;
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/PitchDetector.java
// public interface PitchDetector {
//
// /**
// * Retrieves a pitch frequency (note) using the provided array of values representing a sound
// * wave. Note that this method operates on the calling Thread. The calling Thread should be off
// * the main Thread.
// *
// * @param wave The array of 16 bit values representing the sound wave to be processed.
// * @return A double value representing the detected pitch.
// */
// double detect(float[] wave);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/MutableNote.java
// public class MutableNote implements NoteMutator {
//
// private String name;
// private double frequency;
// private float percentOffset;
//
// public MutableNote() {
// // Default constructor
// }
//
// MutableNote(final String name, final double frequency, final float percentOffset) {
// this.name = name;
// this.frequency = frequency;
// this.percentOffset = percentOffset;
//
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public double getFrequency() {
// return frequency;
// }
//
// @Override
// public float getPercentOffset() {
// return percentOffset;
// }
//
// @Override
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public void setFrequency(final double frequency) {
// this.frequency = frequency;
// }
//
// @Override
// public void setPercentOffset(final float percentOffset) {
// this.percentOffset = percentOffset;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// MutableNote note = (MutableNote) o;
// return Double.compare(note.frequency, frequency) == 0 &&
// Float.compare(note.percentOffset, percentOffset) == 0 &&
// Objects.equals(name, note.name);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, frequency, percentOffset);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/Note.java
// public interface Note {
//
// /**
// * Retrieves the name of the note.
// *
// * @return A String representing the name of the note.
// */
// String getName();
//
// /**
// * Retrieves the frequency value of the closest found note.
// *
// * @return A double value representing the frequency of the closest note.
// */
// double getFrequency();
//
// /**
// * Retrieves the percent offset from the closest found note and the actual found frequency.
// *
// * @return A float value representing the percent offset from the note.
// */
// float getPercentOffset();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteFinder.java
// public interface NoteFinder {
//
// /**
// * Sets the frequency of the note. This method must be called before calling the other methods.
// * Failure to do so may result in unspecified behavior.
// *
// * @param frequency The frequency of the note.
// */
// void setFrequency(double frequency);
//
// /**
// * Retrieves a String representation of the closest note to the provided frequency.
// *
// * @return The String note name.
// */
// String getNoteName();
//
// /**
// * Retrieves the percent difference between the closest found note and the provided frequency.
// * It is an offset in percentage between the closest note and the second closest note. A
// * negative value will indicate it is a lower pitch than the closest found note and a positive
// * value will indicate it is a higher pitch than the closest found note.
// *
// * @return The percent offset from the closest note.
// */
// float getPercentageDifference();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AudioRecorder.java
// public interface AudioRecorder {
//
// /**
// * Starts listening to audio data and prepares for a call to the {@link #readNext()} method.
// * Note that this method should be called before calling the {@link #readNext()} method to
// * prepare the recorder.
// */
// void startRecording();
//
// /**
// * Stops listening to audio data and cleans up any underlying resources used by the
// * implementation. Note that {@link #readNext()} should not be called after this method is
// * called without calling {@link #startRecording()} again.
// */
// void stopRecording();
//
// /**
// * Reads audio data into an array buffer and returns it. Note that the returned array may be
// * mutable depending on the implementation to provide better performance.
// *
// * @return A float array of audio data.
// */
// float[] readNext();
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarTuner.java
import com.chrynan.android_guitar_tuner.tuner.detection.PitchDetector;
import com.chrynan.android_guitar_tuner.tuner.note.MutableNote;
import com.chrynan.android_guitar_tuner.tuner.note.Note;
import com.chrynan.android_guitar_tuner.tuner.note.NoteFinder;
import com.chrynan.android_guitar_tuner.tuner.recorder.AudioRecorder;
import io.reactivex.Observable;
package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link Tuner} interface.
*/
public class GuitarTuner implements Tuner {
private final MutableNote note = new MutableNote();
private final Observable<Note> observable;
| public GuitarTuner(final AudioRecorder audioRecorder, final PitchDetector detector, final NoteFinder finder) { |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarTuner.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/PitchDetector.java
// public interface PitchDetector {
//
// /**
// * Retrieves a pitch frequency (note) using the provided array of values representing a sound
// * wave. Note that this method operates on the calling Thread. The calling Thread should be off
// * the main Thread.
// *
// * @param wave The array of 16 bit values representing the sound wave to be processed.
// * @return A double value representing the detected pitch.
// */
// double detect(float[] wave);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/MutableNote.java
// public class MutableNote implements NoteMutator {
//
// private String name;
// private double frequency;
// private float percentOffset;
//
// public MutableNote() {
// // Default constructor
// }
//
// MutableNote(final String name, final double frequency, final float percentOffset) {
// this.name = name;
// this.frequency = frequency;
// this.percentOffset = percentOffset;
//
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public double getFrequency() {
// return frequency;
// }
//
// @Override
// public float getPercentOffset() {
// return percentOffset;
// }
//
// @Override
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public void setFrequency(final double frequency) {
// this.frequency = frequency;
// }
//
// @Override
// public void setPercentOffset(final float percentOffset) {
// this.percentOffset = percentOffset;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// MutableNote note = (MutableNote) o;
// return Double.compare(note.frequency, frequency) == 0 &&
// Float.compare(note.percentOffset, percentOffset) == 0 &&
// Objects.equals(name, note.name);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, frequency, percentOffset);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/Note.java
// public interface Note {
//
// /**
// * Retrieves the name of the note.
// *
// * @return A String representing the name of the note.
// */
// String getName();
//
// /**
// * Retrieves the frequency value of the closest found note.
// *
// * @return A double value representing the frequency of the closest note.
// */
// double getFrequency();
//
// /**
// * Retrieves the percent offset from the closest found note and the actual found frequency.
// *
// * @return A float value representing the percent offset from the note.
// */
// float getPercentOffset();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteFinder.java
// public interface NoteFinder {
//
// /**
// * Sets the frequency of the note. This method must be called before calling the other methods.
// * Failure to do so may result in unspecified behavior.
// *
// * @param frequency The frequency of the note.
// */
// void setFrequency(double frequency);
//
// /**
// * Retrieves a String representation of the closest note to the provided frequency.
// *
// * @return The String note name.
// */
// String getNoteName();
//
// /**
// * Retrieves the percent difference between the closest found note and the provided frequency.
// * It is an offset in percentage between the closest note and the second closest note. A
// * negative value will indicate it is a lower pitch than the closest found note and a positive
// * value will indicate it is a higher pitch than the closest found note.
// *
// * @return The percent offset from the closest note.
// */
// float getPercentageDifference();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AudioRecorder.java
// public interface AudioRecorder {
//
// /**
// * Starts listening to audio data and prepares for a call to the {@link #readNext()} method.
// * Note that this method should be called before calling the {@link #readNext()} method to
// * prepare the recorder.
// */
// void startRecording();
//
// /**
// * Stops listening to audio data and cleans up any underlying resources used by the
// * implementation. Note that {@link #readNext()} should not be called after this method is
// * called without calling {@link #startRecording()} again.
// */
// void stopRecording();
//
// /**
// * Reads audio data into an array buffer and returns it. Note that the returned array may be
// * mutable depending on the implementation to provide better performance.
// *
// * @return A float array of audio data.
// */
// float[] readNext();
// }
| import com.chrynan.android_guitar_tuner.tuner.detection.PitchDetector;
import com.chrynan.android_guitar_tuner.tuner.note.MutableNote;
import com.chrynan.android_guitar_tuner.tuner.note.Note;
import com.chrynan.android_guitar_tuner.tuner.note.NoteFinder;
import com.chrynan.android_guitar_tuner.tuner.recorder.AudioRecorder;
import io.reactivex.Observable; | package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link Tuner} interface.
*/
public class GuitarTuner implements Tuner {
private final MutableNote note = new MutableNote();
private final Observable<Note> observable;
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/PitchDetector.java
// public interface PitchDetector {
//
// /**
// * Retrieves a pitch frequency (note) using the provided array of values representing a sound
// * wave. Note that this method operates on the calling Thread. The calling Thread should be off
// * the main Thread.
// *
// * @param wave The array of 16 bit values representing the sound wave to be processed.
// * @return A double value representing the detected pitch.
// */
// double detect(float[] wave);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/MutableNote.java
// public class MutableNote implements NoteMutator {
//
// private String name;
// private double frequency;
// private float percentOffset;
//
// public MutableNote() {
// // Default constructor
// }
//
// MutableNote(final String name, final double frequency, final float percentOffset) {
// this.name = name;
// this.frequency = frequency;
// this.percentOffset = percentOffset;
//
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public double getFrequency() {
// return frequency;
// }
//
// @Override
// public float getPercentOffset() {
// return percentOffset;
// }
//
// @Override
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public void setFrequency(final double frequency) {
// this.frequency = frequency;
// }
//
// @Override
// public void setPercentOffset(final float percentOffset) {
// this.percentOffset = percentOffset;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// MutableNote note = (MutableNote) o;
// return Double.compare(note.frequency, frequency) == 0 &&
// Float.compare(note.percentOffset, percentOffset) == 0 &&
// Objects.equals(name, note.name);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, frequency, percentOffset);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/Note.java
// public interface Note {
//
// /**
// * Retrieves the name of the note.
// *
// * @return A String representing the name of the note.
// */
// String getName();
//
// /**
// * Retrieves the frequency value of the closest found note.
// *
// * @return A double value representing the frequency of the closest note.
// */
// double getFrequency();
//
// /**
// * Retrieves the percent offset from the closest found note and the actual found frequency.
// *
// * @return A float value representing the percent offset from the note.
// */
// float getPercentOffset();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteFinder.java
// public interface NoteFinder {
//
// /**
// * Sets the frequency of the note. This method must be called before calling the other methods.
// * Failure to do so may result in unspecified behavior.
// *
// * @param frequency The frequency of the note.
// */
// void setFrequency(double frequency);
//
// /**
// * Retrieves a String representation of the closest note to the provided frequency.
// *
// * @return The String note name.
// */
// String getNoteName();
//
// /**
// * Retrieves the percent difference between the closest found note and the provided frequency.
// * It is an offset in percentage between the closest note and the second closest note. A
// * negative value will indicate it is a lower pitch than the closest found note and a positive
// * value will indicate it is a higher pitch than the closest found note.
// *
// * @return The percent offset from the closest note.
// */
// float getPercentageDifference();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AudioRecorder.java
// public interface AudioRecorder {
//
// /**
// * Starts listening to audio data and prepares for a call to the {@link #readNext()} method.
// * Note that this method should be called before calling the {@link #readNext()} method to
// * prepare the recorder.
// */
// void startRecording();
//
// /**
// * Stops listening to audio data and cleans up any underlying resources used by the
// * implementation. Note that {@link #readNext()} should not be called after this method is
// * called without calling {@link #startRecording()} again.
// */
// void stopRecording();
//
// /**
// * Reads audio data into an array buffer and returns it. Note that the returned array may be
// * mutable depending on the implementation to provide better performance.
// *
// * @return A float array of audio data.
// */
// float[] readNext();
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarTuner.java
import com.chrynan.android_guitar_tuner.tuner.detection.PitchDetector;
import com.chrynan.android_guitar_tuner.tuner.note.MutableNote;
import com.chrynan.android_guitar_tuner.tuner.note.Note;
import com.chrynan.android_guitar_tuner.tuner.note.NoteFinder;
import com.chrynan.android_guitar_tuner.tuner.recorder.AudioRecorder;
import io.reactivex.Observable;
package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link Tuner} interface.
*/
public class GuitarTuner implements Tuner {
private final MutableNote note = new MutableNote();
private final Observable<Note> observable;
| public GuitarTuner(final AudioRecorder audioRecorder, final PitchDetector detector, final NoteFinder finder) { |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarTuner.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/PitchDetector.java
// public interface PitchDetector {
//
// /**
// * Retrieves a pitch frequency (note) using the provided array of values representing a sound
// * wave. Note that this method operates on the calling Thread. The calling Thread should be off
// * the main Thread.
// *
// * @param wave The array of 16 bit values representing the sound wave to be processed.
// * @return A double value representing the detected pitch.
// */
// double detect(float[] wave);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/MutableNote.java
// public class MutableNote implements NoteMutator {
//
// private String name;
// private double frequency;
// private float percentOffset;
//
// public MutableNote() {
// // Default constructor
// }
//
// MutableNote(final String name, final double frequency, final float percentOffset) {
// this.name = name;
// this.frequency = frequency;
// this.percentOffset = percentOffset;
//
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public double getFrequency() {
// return frequency;
// }
//
// @Override
// public float getPercentOffset() {
// return percentOffset;
// }
//
// @Override
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public void setFrequency(final double frequency) {
// this.frequency = frequency;
// }
//
// @Override
// public void setPercentOffset(final float percentOffset) {
// this.percentOffset = percentOffset;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// MutableNote note = (MutableNote) o;
// return Double.compare(note.frequency, frequency) == 0 &&
// Float.compare(note.percentOffset, percentOffset) == 0 &&
// Objects.equals(name, note.name);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, frequency, percentOffset);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/Note.java
// public interface Note {
//
// /**
// * Retrieves the name of the note.
// *
// * @return A String representing the name of the note.
// */
// String getName();
//
// /**
// * Retrieves the frequency value of the closest found note.
// *
// * @return A double value representing the frequency of the closest note.
// */
// double getFrequency();
//
// /**
// * Retrieves the percent offset from the closest found note and the actual found frequency.
// *
// * @return A float value representing the percent offset from the note.
// */
// float getPercentOffset();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteFinder.java
// public interface NoteFinder {
//
// /**
// * Sets the frequency of the note. This method must be called before calling the other methods.
// * Failure to do so may result in unspecified behavior.
// *
// * @param frequency The frequency of the note.
// */
// void setFrequency(double frequency);
//
// /**
// * Retrieves a String representation of the closest note to the provided frequency.
// *
// * @return The String note name.
// */
// String getNoteName();
//
// /**
// * Retrieves the percent difference between the closest found note and the provided frequency.
// * It is an offset in percentage between the closest note and the second closest note. A
// * negative value will indicate it is a lower pitch than the closest found note and a positive
// * value will indicate it is a higher pitch than the closest found note.
// *
// * @return The percent offset from the closest note.
// */
// float getPercentageDifference();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AudioRecorder.java
// public interface AudioRecorder {
//
// /**
// * Starts listening to audio data and prepares for a call to the {@link #readNext()} method.
// * Note that this method should be called before calling the {@link #readNext()} method to
// * prepare the recorder.
// */
// void startRecording();
//
// /**
// * Stops listening to audio data and cleans up any underlying resources used by the
// * implementation. Note that {@link #readNext()} should not be called after this method is
// * called without calling {@link #startRecording()} again.
// */
// void stopRecording();
//
// /**
// * Reads audio data into an array buffer and returns it. Note that the returned array may be
// * mutable depending on the implementation to provide better performance.
// *
// * @return A float array of audio data.
// */
// float[] readNext();
// }
| import com.chrynan.android_guitar_tuner.tuner.detection.PitchDetector;
import com.chrynan.android_guitar_tuner.tuner.note.MutableNote;
import com.chrynan.android_guitar_tuner.tuner.note.Note;
import com.chrynan.android_guitar_tuner.tuner.note.NoteFinder;
import com.chrynan.android_guitar_tuner.tuner.recorder.AudioRecorder;
import io.reactivex.Observable; | package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link Tuner} interface.
*/
public class GuitarTuner implements Tuner {
private final MutableNote note = new MutableNote();
private final Observable<Note> observable;
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/detection/PitchDetector.java
// public interface PitchDetector {
//
// /**
// * Retrieves a pitch frequency (note) using the provided array of values representing a sound
// * wave. Note that this method operates on the calling Thread. The calling Thread should be off
// * the main Thread.
// *
// * @param wave The array of 16 bit values representing the sound wave to be processed.
// * @return A double value representing the detected pitch.
// */
// double detect(float[] wave);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/MutableNote.java
// public class MutableNote implements NoteMutator {
//
// private String name;
// private double frequency;
// private float percentOffset;
//
// public MutableNote() {
// // Default constructor
// }
//
// MutableNote(final String name, final double frequency, final float percentOffset) {
// this.name = name;
// this.frequency = frequency;
// this.percentOffset = percentOffset;
//
// }
//
// @Override
// public String getName() {
// return name;
// }
//
// @Override
// public double getFrequency() {
// return frequency;
// }
//
// @Override
// public float getPercentOffset() {
// return percentOffset;
// }
//
// @Override
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public void setFrequency(final double frequency) {
// this.frequency = frequency;
// }
//
// @Override
// public void setPercentOffset(final float percentOffset) {
// this.percentOffset = percentOffset;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// MutableNote note = (MutableNote) o;
// return Double.compare(note.frequency, frequency) == 0 &&
// Float.compare(note.percentOffset, percentOffset) == 0 &&
// Objects.equals(name, note.name);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, frequency, percentOffset);
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/Note.java
// public interface Note {
//
// /**
// * Retrieves the name of the note.
// *
// * @return A String representing the name of the note.
// */
// String getName();
//
// /**
// * Retrieves the frequency value of the closest found note.
// *
// * @return A double value representing the frequency of the closest note.
// */
// double getFrequency();
//
// /**
// * Retrieves the percent offset from the closest found note and the actual found frequency.
// *
// * @return A float value representing the percent offset from the note.
// */
// float getPercentOffset();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/note/NoteFinder.java
// public interface NoteFinder {
//
// /**
// * Sets the frequency of the note. This method must be called before calling the other methods.
// * Failure to do so may result in unspecified behavior.
// *
// * @param frequency The frequency of the note.
// */
// void setFrequency(double frequency);
//
// /**
// * Retrieves a String representation of the closest note to the provided frequency.
// *
// * @return The String note name.
// */
// String getNoteName();
//
// /**
// * Retrieves the percent difference between the closest found note and the provided frequency.
// * It is an offset in percentage between the closest note and the second closest note. A
// * negative value will indicate it is a lower pitch than the closest found note and a positive
// * value will indicate it is a higher pitch than the closest found note.
// *
// * @return The percent offset from the closest note.
// */
// float getPercentageDifference();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AudioRecorder.java
// public interface AudioRecorder {
//
// /**
// * Starts listening to audio data and prepares for a call to the {@link #readNext()} method.
// * Note that this method should be called before calling the {@link #readNext()} method to
// * prepare the recorder.
// */
// void startRecording();
//
// /**
// * Stops listening to audio data and cleans up any underlying resources used by the
// * implementation. Note that {@link #readNext()} should not be called after this method is
// * called without calling {@link #startRecording()} again.
// */
// void stopRecording();
//
// /**
// * Reads audio data into an array buffer and returns it. Note that the returned array may be
// * mutable depending on the implementation to provide better performance.
// *
// * @return A float array of audio data.
// */
// float[] readNext();
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/GuitarTuner.java
import com.chrynan.android_guitar_tuner.tuner.detection.PitchDetector;
import com.chrynan.android_guitar_tuner.tuner.note.MutableNote;
import com.chrynan.android_guitar_tuner.tuner.note.Note;
import com.chrynan.android_guitar_tuner.tuner.note.NoteFinder;
import com.chrynan.android_guitar_tuner.tuner.recorder.AudioRecorder;
import io.reactivex.Observable;
package com.chrynan.android_guitar_tuner.tuner;
/**
* An implementation of the {@link Tuner} interface.
*/
public class GuitarTuner implements Tuner {
private final MutableNote note = new MutableNote();
private final Observable<Note> observable;
| public GuitarTuner(final AudioRecorder audioRecorder, final PitchDetector detector, final NoteFinder finder) { |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/GuitarTunerApplication.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = ApplicationModule.class)
// public interface ApplicationComponent {
//
// @ApplicationContext
// Context getApplicationContext();
//
// void inject(GuitarTunerApplication application);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final Application application;
//
// public ApplicationModule(final Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// @ApplicationContext
// Context provideApplicationContext() {
// return application;
// }
// }
| import android.app.Application;
import com.chrynan.android_guitar_tuner.di.component.ApplicationComponent;
import com.chrynan.android_guitar_tuner.di.component.DaggerApplicationComponent;
import com.chrynan.android_guitar_tuner.di.module.ApplicationModule;
import timber.log.Timber; | package com.chrynan.android_guitar_tuner;
public class GuitarTunerApplication extends Application {
private static ApplicationComponent applicationComponent;
public static ApplicationComponent getApplicationComponent() {
return applicationComponent;
}
@Override
public void onCreate() {
super.onCreate();
// Setup Logging
if (BuildConfig.DEBUG) {
// Uses the default Timber Debug Tree to output logs to LogCat
Timber.plant(new Timber.DebugTree());
}
// Setup the Dagger Application Component
applicationComponent = DaggerApplicationComponent.builder() | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = ApplicationModule.class)
// public interface ApplicationComponent {
//
// @ApplicationContext
// Context getApplicationContext();
//
// void inject(GuitarTunerApplication application);
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
//
// private final Application application;
//
// public ApplicationModule(final Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// @ApplicationContext
// Context provideApplicationContext() {
// return application;
// }
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/GuitarTunerApplication.java
import android.app.Application;
import com.chrynan.android_guitar_tuner.di.component.ApplicationComponent;
import com.chrynan.android_guitar_tuner.di.component.DaggerApplicationComponent;
import com.chrynan.android_guitar_tuner.di.module.ApplicationModule;
import timber.log.Timber;
package com.chrynan.android_guitar_tuner;
public class GuitarTunerApplication extends Application {
private static ApplicationComponent applicationComponent;
public static ApplicationComponent getApplicationComponent() {
return applicationComponent;
}
@Override
public void onCreate() {
super.onCreate();
// Setup Logging
if (BuildConfig.DEBUG) {
// Uses the default Timber Debug Tree to output logs to LogCat
Timber.plant(new Timber.DebugTree());
}
// Setup the Dagger Application Component
applicationComponent = DaggerApplicationComponent.builder() | .applicationModule(new ApplicationModule(this)) |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AndroidAudioRecorder.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/converter/ArrayConverter.java
// public interface ArrayConverter {
//
// /**
// * Converts the provided byte array to a corresponding float array.
// *
// * @param array The byte array to be converted.
// * @param convertedArray The float array representing the original byte array but as float values.
// */
// void convert(final byte[] array, final float[] convertedArray);
//
// /**
// * Converts the provided short array to a corresponding float array.
// *
// * @param array The short array to be converted.
// * @param convertedArray The float array representing the original short array but as float values.
// */
// void convert(final short[] array, final float[] convertedArray);
// }
| import android.media.AudioRecord;
import android.os.Build;
import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig;
import com.chrynan.android_guitar_tuner.tuner.converter.ArrayConverter; | package com.chrynan.android_guitar_tuner.tuner.recorder;
/**
* An Android implementation of the {@link AudioRecorder} interface that works with the Android
* {@link android.media.AudioRecord} object.
*/
public class AndroidAudioRecorder implements AudioRecorder {
private final ArrayConverter converter;
private final AudioRecord audioRecorder;
private final int readSize;
private final short[] buffer;
private final float[] floatBuffer;
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/converter/ArrayConverter.java
// public interface ArrayConverter {
//
// /**
// * Converts the provided byte array to a corresponding float array.
// *
// * @param array The byte array to be converted.
// * @param convertedArray The float array representing the original byte array but as float values.
// */
// void convert(final byte[] array, final float[] convertedArray);
//
// /**
// * Converts the provided short array to a corresponding float array.
// *
// * @param array The short array to be converted.
// * @param convertedArray The float array representing the original short array but as float values.
// */
// void convert(final short[] array, final float[] convertedArray);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/recorder/AndroidAudioRecorder.java
import android.media.AudioRecord;
import android.os.Build;
import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig;
import com.chrynan.android_guitar_tuner.tuner.converter.ArrayConverter;
package com.chrynan.android_guitar_tuner.tuner.recorder;
/**
* An Android implementation of the {@link AudioRecorder} interface that works with the Android
* {@link android.media.AudioRecord} object.
*/
public class AndroidAudioRecorder implements AudioRecorder {
private final ArrayConverter converter;
private final AudioRecord audioRecorder;
private final int readSize;
private final short[] buffer;
private final float[] floatBuffer;
| public AndroidAudioRecorder(final AudioConfig audioConfig, final ArrayConverter converter) { |
chRyNaN/Android-Guitar-Tuner | app/src/test/java/com/chrynan/android_guitar_tuner/tuner/detection/YINPitchDetectorTest.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
| import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig;
import org.junit.Before;
import org.junit.Rule;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule; | package com.chrynan.android_guitar_tuner.tuner.detection;
/**
* A class that tests the accuracy of a {@link YINPitchDetector} class.
*/
public class YINPitchDetectorTest {
private static final int SAMPLE_RATE = 44100;
private static final int READ_SIZE = 10000;
@Rule
public MockitoRule mockitoRule = MockitoJUnit.rule();
private YINPitchDetector detector;
@Before
public void setupDetector() {
// Mock the AudioConfig interface | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/tuner/config/AudioConfig.java
// public interface AudioConfig {
//
// /**
// * The sample rate that the Audio Recorder is using, in hertz. Note that this value is device
// * dependent.
// *
// * @return The sample rate of the audio recording.
// */
// int getSampleRate();
//
// /**
// * The size of the underlying input waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getInputBufferSize();
//
// /**
// * The size of the underlying output waveform buffer array used by the Audio Recorder. This should be
// * larger than the value returned by {@link #getReadSize()}. This value should only be used to
// * create an instance of an Audio Recorder and when reading or performing operations on the
// * waveform buffer array, {@link #getReadSize()} should be used. Note that an implementation of
// * this method should return a valid value for the device.
// *
// * @return The size of the underlying waveform buffer array.
// */
// int getOutputBufferSize();
//
// /**
// * The size of the input array of data that should be read from the buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values read from the underlying waveform buffer array.
// */
// int getReadSize();
//
// /**
// * The size of the array of data that should be written to the output buffer. Use this value when
// * processing the buffer of waveform data.
// *
// * @return The size of values written to the underlying waveform buffer array.
// */
// int getWriteSize();
//
// /**
// * The input channel to retrieve the input data.
// *
// * @return The input channel
// */
// int getInputChannel();
//
// /**
// * The output channel to output the data. For example, a value representing Stereo.
// *
// * @return The output channel.
// */
// int getOutputChannel();
//
// /**
// * The input audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getInputFormat();
//
// /**
// * The output audio format of the buffer array (ex: float or short).
// *
// * @return The format of the buffer array.
// */
// int getOutputFormat();
//
// /**
// * The amount of bytes to represent a single piece of output data. For instance, 16-bit PCM data
// * can be represented by two bytes.
// *
// * @return The amount of bytes needed to represent the output data.
// */
// int getOutputFormatByteCount();
//
// /**
// * The input source of the audio data.
// *
// * @return The input source.
// */
// int getInputSource();
// }
// Path: app/src/test/java/com/chrynan/android_guitar_tuner/tuner/detection/YINPitchDetectorTest.java
import com.chrynan.android_guitar_tuner.tuner.config.AudioConfig;
import org.junit.Before;
import org.junit.Rule;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
package com.chrynan.android_guitar_tuner.tuner.detection;
/**
* A class that tests the accuracy of a {@link YINPitchDetector} class.
*/
public class YINPitchDetectorTest {
private static final int SAMPLE_RATE = 44100;
private static final int READ_SIZE = 10000;
@Rule
public MockitoRule mockitoRule = MockitoJUnit.rule();
private YINPitchDetector detector;
@Before
public void setupDetector() {
// Mock the AudioConfig interface | AudioConfig config = Mockito.mock(AudioConfig.class); |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/di/module/AppInfoViewModule.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/AppInfoPresenter.java
// public class AppInfoPresenter implements Presenter {
//
// @ApplicationContext
// private final Context context;
// private final AppInfoView view;
// private final SimpleDateFormat simpleDateFormat;
//
// public AppInfoPresenter(@ApplicationContext final Context context, final AppInfoView view) {
// this.context = context;
// this.view = view;
// this.simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm a", Locale.getDefault());
// }
//
// public void getAppInformation() {
// try {
// PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
// AppInfo appInfo = new AppInfo(packageInfo);
// Resources res = context.getResources();
//
// view.showAppName(appInfo.getAppName());
// view.showPackageName(appInfo.getPackageName());
// view.showAPKLocation(appInfo.getApkLocation());
// view.showVersionName(appInfo.getVersionName());
// view.showVersionCode(String.valueOf(appInfo.getVersionCode()));
// view.showFirstInstallDate(simpleDateFormat.format(new Date(appInfo.getFirstInstallTime())));
// view.showLastUpdatedDate(simpleDateFormat.format(new Date(appInfo.getLastUpdatedTime())));
//
// AndroidApiLevel minVersion = appInfo.getMinAndroidApiLevel();
// AndroidApiLevel targetVersion = appInfo.getTargetAndroidApiLevel();
// AndroidApiLevel deviceVersion = appInfo.getDeviceAndroidApiLevel();
//
// view.showMinSDKVersion(res.getString(R.string.app_info_text_api_level, minVersion.getAndroidVersion().getName(), minVersion.getVersionCode()));
// view.showTargetSDKVersion(res.getString(R.string.app_info_text_api_level, targetVersion.getAndroidVersion().getName(), targetVersion.getVersionCode()));
// view.showDeviceSDKVersion(res.getString(R.string.app_info_text_api_level, deviceVersion.getAndroidVersion().getName(), deviceVersion.getVersionCode()));
// } catch (PackageManager.NameNotFoundException e) {
// Timber.e(e, "Error Retrieving PackageManager or PackageInfo.");
// // TODO Display defaults/error
// }
// }
//
// @Override
// public void detachView() {
// // No Operation
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/AppInfoView.java
// public interface AppInfoView {
//
// void showAppName(String appName);
//
// void showPackageName(String packageName);
//
// void showAPKLocation(String location);
//
// void showFirstInstallDate(String firstInstall);
//
// void showLastUpdatedDate(String lastUpdated);
//
// void showVersionName(String versionName);
//
// void showVersionCode(String versionCode);
//
// void showMinSDKVersion(String minSDKVersion);
//
// void showTargetSDKVersion(String targetSDKVersion);
//
// void showDeviceSDKVersion(String deviceSDKVersion);
// }
| import android.content.Context;
import com.chrynan.android_guitar_tuner.di.ActivityScope;
import com.chrynan.android_guitar_tuner.di.ApplicationContext;
import com.chrynan.android_guitar_tuner.presenter.AppInfoPresenter;
import com.chrynan.android_guitar_tuner.ui.view.AppInfoView;
import dagger.Module;
import dagger.Provides; | package com.chrynan.android_guitar_tuner.di.module;
/**
* A Dagger {@link Module} used for dependency injection in an {@link AppInfoView} implementation.
*/
@Module
public class AppInfoViewModule {
| // Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/AppInfoPresenter.java
// public class AppInfoPresenter implements Presenter {
//
// @ApplicationContext
// private final Context context;
// private final AppInfoView view;
// private final SimpleDateFormat simpleDateFormat;
//
// public AppInfoPresenter(@ApplicationContext final Context context, final AppInfoView view) {
// this.context = context;
// this.view = view;
// this.simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm a", Locale.getDefault());
// }
//
// public void getAppInformation() {
// try {
// PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
// AppInfo appInfo = new AppInfo(packageInfo);
// Resources res = context.getResources();
//
// view.showAppName(appInfo.getAppName());
// view.showPackageName(appInfo.getPackageName());
// view.showAPKLocation(appInfo.getApkLocation());
// view.showVersionName(appInfo.getVersionName());
// view.showVersionCode(String.valueOf(appInfo.getVersionCode()));
// view.showFirstInstallDate(simpleDateFormat.format(new Date(appInfo.getFirstInstallTime())));
// view.showLastUpdatedDate(simpleDateFormat.format(new Date(appInfo.getLastUpdatedTime())));
//
// AndroidApiLevel minVersion = appInfo.getMinAndroidApiLevel();
// AndroidApiLevel targetVersion = appInfo.getTargetAndroidApiLevel();
// AndroidApiLevel deviceVersion = appInfo.getDeviceAndroidApiLevel();
//
// view.showMinSDKVersion(res.getString(R.string.app_info_text_api_level, minVersion.getAndroidVersion().getName(), minVersion.getVersionCode()));
// view.showTargetSDKVersion(res.getString(R.string.app_info_text_api_level, targetVersion.getAndroidVersion().getName(), targetVersion.getVersionCode()));
// view.showDeviceSDKVersion(res.getString(R.string.app_info_text_api_level, deviceVersion.getAndroidVersion().getName(), deviceVersion.getVersionCode()));
// } catch (PackageManager.NameNotFoundException e) {
// Timber.e(e, "Error Retrieving PackageManager or PackageInfo.");
// // TODO Display defaults/error
// }
// }
//
// @Override
// public void detachView() {
// // No Operation
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/AppInfoView.java
// public interface AppInfoView {
//
// void showAppName(String appName);
//
// void showPackageName(String packageName);
//
// void showAPKLocation(String location);
//
// void showFirstInstallDate(String firstInstall);
//
// void showLastUpdatedDate(String lastUpdated);
//
// void showVersionName(String versionName);
//
// void showVersionCode(String versionCode);
//
// void showMinSDKVersion(String minSDKVersion);
//
// void showTargetSDKVersion(String targetSDKVersion);
//
// void showDeviceSDKVersion(String deviceSDKVersion);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/module/AppInfoViewModule.java
import android.content.Context;
import com.chrynan.android_guitar_tuner.di.ActivityScope;
import com.chrynan.android_guitar_tuner.di.ApplicationContext;
import com.chrynan.android_guitar_tuner.presenter.AppInfoPresenter;
import com.chrynan.android_guitar_tuner.ui.view.AppInfoView;
import dagger.Module;
import dagger.Provides;
package com.chrynan.android_guitar_tuner.di.module;
/**
* A Dagger {@link Module} used for dependency injection in an {@link AppInfoView} implementation.
*/
@Module
public class AppInfoViewModule {
| private final AppInfoView view; |
chRyNaN/Android-Guitar-Tuner | app/src/main/java/com/chrynan/android_guitar_tuner/di/module/AppInfoViewModule.java | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/AppInfoPresenter.java
// public class AppInfoPresenter implements Presenter {
//
// @ApplicationContext
// private final Context context;
// private final AppInfoView view;
// private final SimpleDateFormat simpleDateFormat;
//
// public AppInfoPresenter(@ApplicationContext final Context context, final AppInfoView view) {
// this.context = context;
// this.view = view;
// this.simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm a", Locale.getDefault());
// }
//
// public void getAppInformation() {
// try {
// PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
// AppInfo appInfo = new AppInfo(packageInfo);
// Resources res = context.getResources();
//
// view.showAppName(appInfo.getAppName());
// view.showPackageName(appInfo.getPackageName());
// view.showAPKLocation(appInfo.getApkLocation());
// view.showVersionName(appInfo.getVersionName());
// view.showVersionCode(String.valueOf(appInfo.getVersionCode()));
// view.showFirstInstallDate(simpleDateFormat.format(new Date(appInfo.getFirstInstallTime())));
// view.showLastUpdatedDate(simpleDateFormat.format(new Date(appInfo.getLastUpdatedTime())));
//
// AndroidApiLevel minVersion = appInfo.getMinAndroidApiLevel();
// AndroidApiLevel targetVersion = appInfo.getTargetAndroidApiLevel();
// AndroidApiLevel deviceVersion = appInfo.getDeviceAndroidApiLevel();
//
// view.showMinSDKVersion(res.getString(R.string.app_info_text_api_level, minVersion.getAndroidVersion().getName(), minVersion.getVersionCode()));
// view.showTargetSDKVersion(res.getString(R.string.app_info_text_api_level, targetVersion.getAndroidVersion().getName(), targetVersion.getVersionCode()));
// view.showDeviceSDKVersion(res.getString(R.string.app_info_text_api_level, deviceVersion.getAndroidVersion().getName(), deviceVersion.getVersionCode()));
// } catch (PackageManager.NameNotFoundException e) {
// Timber.e(e, "Error Retrieving PackageManager or PackageInfo.");
// // TODO Display defaults/error
// }
// }
//
// @Override
// public void detachView() {
// // No Operation
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/AppInfoView.java
// public interface AppInfoView {
//
// void showAppName(String appName);
//
// void showPackageName(String packageName);
//
// void showAPKLocation(String location);
//
// void showFirstInstallDate(String firstInstall);
//
// void showLastUpdatedDate(String lastUpdated);
//
// void showVersionName(String versionName);
//
// void showVersionCode(String versionCode);
//
// void showMinSDKVersion(String minSDKVersion);
//
// void showTargetSDKVersion(String targetSDKVersion);
//
// void showDeviceSDKVersion(String deviceSDKVersion);
// }
| import android.content.Context;
import com.chrynan.android_guitar_tuner.di.ActivityScope;
import com.chrynan.android_guitar_tuner.di.ApplicationContext;
import com.chrynan.android_guitar_tuner.presenter.AppInfoPresenter;
import com.chrynan.android_guitar_tuner.ui.view.AppInfoView;
import dagger.Module;
import dagger.Provides; | package com.chrynan.android_guitar_tuner.di.module;
/**
* A Dagger {@link Module} used for dependency injection in an {@link AppInfoView} implementation.
*/
@Module
public class AppInfoViewModule {
private final AppInfoView view;
public AppInfoViewModule(final AppInfoView view) {
this.view = view;
}
@Provides
@ActivityScope | // Path: app/src/main/java/com/chrynan/android_guitar_tuner/presenter/AppInfoPresenter.java
// public class AppInfoPresenter implements Presenter {
//
// @ApplicationContext
// private final Context context;
// private final AppInfoView view;
// private final SimpleDateFormat simpleDateFormat;
//
// public AppInfoPresenter(@ApplicationContext final Context context, final AppInfoView view) {
// this.context = context;
// this.view = view;
// this.simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm a", Locale.getDefault());
// }
//
// public void getAppInformation() {
// try {
// PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
// AppInfo appInfo = new AppInfo(packageInfo);
// Resources res = context.getResources();
//
// view.showAppName(appInfo.getAppName());
// view.showPackageName(appInfo.getPackageName());
// view.showAPKLocation(appInfo.getApkLocation());
// view.showVersionName(appInfo.getVersionName());
// view.showVersionCode(String.valueOf(appInfo.getVersionCode()));
// view.showFirstInstallDate(simpleDateFormat.format(new Date(appInfo.getFirstInstallTime())));
// view.showLastUpdatedDate(simpleDateFormat.format(new Date(appInfo.getLastUpdatedTime())));
//
// AndroidApiLevel minVersion = appInfo.getMinAndroidApiLevel();
// AndroidApiLevel targetVersion = appInfo.getTargetAndroidApiLevel();
// AndroidApiLevel deviceVersion = appInfo.getDeviceAndroidApiLevel();
//
// view.showMinSDKVersion(res.getString(R.string.app_info_text_api_level, minVersion.getAndroidVersion().getName(), minVersion.getVersionCode()));
// view.showTargetSDKVersion(res.getString(R.string.app_info_text_api_level, targetVersion.getAndroidVersion().getName(), targetVersion.getVersionCode()));
// view.showDeviceSDKVersion(res.getString(R.string.app_info_text_api_level, deviceVersion.getAndroidVersion().getName(), deviceVersion.getVersionCode()));
// } catch (PackageManager.NameNotFoundException e) {
// Timber.e(e, "Error Retrieving PackageManager or PackageInfo.");
// // TODO Display defaults/error
// }
// }
//
// @Override
// public void detachView() {
// // No Operation
// }
// }
//
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/ui/view/AppInfoView.java
// public interface AppInfoView {
//
// void showAppName(String appName);
//
// void showPackageName(String packageName);
//
// void showAPKLocation(String location);
//
// void showFirstInstallDate(String firstInstall);
//
// void showLastUpdatedDate(String lastUpdated);
//
// void showVersionName(String versionName);
//
// void showVersionCode(String versionCode);
//
// void showMinSDKVersion(String minSDKVersion);
//
// void showTargetSDKVersion(String targetSDKVersion);
//
// void showDeviceSDKVersion(String deviceSDKVersion);
// }
// Path: app/src/main/java/com/chrynan/android_guitar_tuner/di/module/AppInfoViewModule.java
import android.content.Context;
import com.chrynan.android_guitar_tuner.di.ActivityScope;
import com.chrynan.android_guitar_tuner.di.ApplicationContext;
import com.chrynan.android_guitar_tuner.presenter.AppInfoPresenter;
import com.chrynan.android_guitar_tuner.ui.view.AppInfoView;
import dagger.Module;
import dagger.Provides;
package com.chrynan.android_guitar_tuner.di.module;
/**
* A Dagger {@link Module} used for dependency injection in an {@link AppInfoView} implementation.
*/
@Module
public class AppInfoViewModule {
private final AppInfoView view;
public AppInfoViewModule(final AppInfoView view) {
this.view = view;
}
@Provides
@ActivityScope | AppInfoPresenter provideAppInfoPresenter(@ApplicationContext Context context) { |
DHager/jhllib | src/main/java/com/technofovea/hllib/DirectoryItem.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; |
public HlPackage getParentPackage() {
return parentPackage;
}
public boolean isClosed() {
return (parentPackage.isClosed());
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof DirectoryItem)) {
return false;
}
DirectoryItem other = (DirectoryItem) obj;
if (!parentPackage.equals(other.parentPackage)) {
return false;
}
if (!pointer.equals(other.pointer)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return pointer.hashCode() + parentPackage.hashCode();
}
public List<DirectoryItem> getChildren() { | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/main/java/com/technofovea/hllib/DirectoryItem.java
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public HlPackage getParentPackage() {
return parentPackage;
}
public boolean isClosed() {
return (parentPackage.isClosed());
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof DirectoryItem)) {
return false;
}
DirectoryItem other = (DirectoryItem) obj;
if (!parentPackage.equals(other.parentPackage)) {
return false;
}
if (!pointer.equals(other.pointer)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return pointer.hashCode() + parentPackage.hashCode();
}
public List<DirectoryItem> getChildren() { | ManagedLibrary lib = HlLib.getLibrary(); |
DHager/jhllib | src/main/java/com/technofovea/hllib/DirectoryItem.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | return false;
}
DirectoryItem other = (DirectoryItem) obj;
if (!parentPackage.equals(other.parentPackage)) {
return false;
}
if (!pointer.equals(other.pointer)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return pointer.hashCode() + parentPackage.hashCode();
}
public List<DirectoryItem> getChildren() {
ManagedLibrary lib = HlLib.getLibrary();
List<DirectoryItem> children = new ArrayList<DirectoryItem>();
if (isFolder()) {
for (int i = 0; i < HlLib.getLibrary().folderGetCount(this); i++) {
DirectoryItem child = lib.folderGetItem(this, i);
children.add(child);
}
}
return children;
}
public boolean isFile() { | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/main/java/com/technofovea/hllib/DirectoryItem.java
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return false;
}
DirectoryItem other = (DirectoryItem) obj;
if (!parentPackage.equals(other.parentPackage)) {
return false;
}
if (!pointer.equals(other.pointer)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return pointer.hashCode() + parentPackage.hashCode();
}
public List<DirectoryItem> getChildren() {
ManagedLibrary lib = HlLib.getLibrary();
List<DirectoryItem> children = new ArrayList<DirectoryItem>();
if (isFolder()) {
for (int i = 0; i < HlLib.getLibrary().folderGetCount(this); i++) {
DirectoryItem child = lib.folderGetItem(this, i);
children.add(child);
}
}
return children;
}
public boolean isFile() { | return (HlLib.getLibrary().itemGetType(this) == DirectoryItemType.FILE); |
DHager/jhllib | src/main/java/com/technofovea/hllib/DirectoryItem.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | }
public boolean isFile() {
return (HlLib.getLibrary().itemGetType(this) == DirectoryItemType.FILE);
}
public boolean isFolder() {
return (HlLib.getLibrary().itemGetType(this) == DirectoryItemType.FOLDER);
}
public String getName() {
return (HlLib.getLibrary().itemGetName(this));
}
public String getPath() {
return (HlLib.getLibrary().itemGetPath(this));
}
public Memory getData() {
logger.debug("Getting data to memory for file {}", this.getName());
if (!isFile()) {
return null;
}
ManagedLibrary lib = HlLib.getLibrary();
long actual_size = lib.itemGetSizeEx(this);
HlStream stream = lib.fileCreateStream(this);
try { | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/main/java/com/technofovea/hllib/DirectoryItem.java
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
public boolean isFile() {
return (HlLib.getLibrary().itemGetType(this) == DirectoryItemType.FILE);
}
public boolean isFolder() {
return (HlLib.getLibrary().itemGetType(this) == DirectoryItemType.FOLDER);
}
public String getName() {
return (HlLib.getLibrary().itemGetName(this));
}
public String getPath() {
return (HlLib.getLibrary().itemGetPath(this));
}
public Memory getData() {
logger.debug("Getting data to memory for file {}", this.getName());
if (!isFile()) {
return null;
}
ManagedLibrary lib = HlLib.getLibrary();
long actual_size = lib.itemGetSizeEx(this);
HlStream stream = lib.fileCreateStream(this);
try { | FileMode streamMode = new FileMode(); |
DHager/jhllib | src/main/java/com/technofovea/hllib/InvocationManager.java | // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedCalls.java
// public interface ManagedCalls {
//
// public int itemGetSize(DirectoryItem item);
//
// public int itemGetSizeOnDisk(DirectoryItem item);
//
// public long itemGetSizeEx(DirectoryItem item);
//
// public long itemGetSizeOnDiskEx(DirectoryItem item);
//
// public String itemGetPath(DirectoryItem item);
//
// public HlPackage getCurrentlyBoundPackage();
//
// public HlPackage createPackage(PackageType ePackageType);
//
// public PackageType getPackageType(File f);
//
// /**
// * Replaces packageClose() and packageDelete() with a single call, primarily
// * to make it easier to handle the safe marking of HlPackage and DirectoryItem
// * objects as invalid.
// * @param pkg The package to remove and close.
// */
// public void packageRemove(HlPackage pkg);
//
// public void packageRemoveAll();
//
// public boolean packageGetExtractable(DirectoryItem file);
//
// public int packageGetFileSize(DirectoryItem file);
//
// public int packageGetFileSizeOnDisk(DirectoryItem file);
//
// public HlStream packageCreateStream(DirectoryItem file);
//
// public HlStream fileCreateStream(DirectoryItem item);
// }
| import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedCalls;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package com.technofovea.hllib;
class InvocationManager implements InvocationHandler {
private static final Logger logger = LoggerFactory.getLogger(InvocationManager.class);
| // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedCalls.java
// public interface ManagedCalls {
//
// public int itemGetSize(DirectoryItem item);
//
// public int itemGetSizeOnDisk(DirectoryItem item);
//
// public long itemGetSizeEx(DirectoryItem item);
//
// public long itemGetSizeOnDiskEx(DirectoryItem item);
//
// public String itemGetPath(DirectoryItem item);
//
// public HlPackage getCurrentlyBoundPackage();
//
// public HlPackage createPackage(PackageType ePackageType);
//
// public PackageType getPackageType(File f);
//
// /**
// * Replaces packageClose() and packageDelete() with a single call, primarily
// * to make it easier to handle the safe marking of HlPackage and DirectoryItem
// * objects as invalid.
// * @param pkg The package to remove and close.
// */
// public void packageRemove(HlPackage pkg);
//
// public void packageRemoveAll();
//
// public boolean packageGetExtractable(DirectoryItem file);
//
// public int packageGetFileSize(DirectoryItem file);
//
// public int packageGetFileSizeOnDisk(DirectoryItem file);
//
// public HlStream packageCreateStream(DirectoryItem file);
//
// public HlStream fileCreateStream(DirectoryItem item);
// }
// Path: src/main/java/com/technofovea/hllib/InvocationManager.java
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedCalls;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.technofovea.hllib;
class InvocationManager implements InvocationHandler {
private static final Logger logger = LoggerFactory.getLogger(InvocationManager.class);
| FullLibrary delegate; |
DHager/jhllib | src/main/java/com/technofovea/hllib/InvocationManager.java | // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedCalls.java
// public interface ManagedCalls {
//
// public int itemGetSize(DirectoryItem item);
//
// public int itemGetSizeOnDisk(DirectoryItem item);
//
// public long itemGetSizeEx(DirectoryItem item);
//
// public long itemGetSizeOnDiskEx(DirectoryItem item);
//
// public String itemGetPath(DirectoryItem item);
//
// public HlPackage getCurrentlyBoundPackage();
//
// public HlPackage createPackage(PackageType ePackageType);
//
// public PackageType getPackageType(File f);
//
// /**
// * Replaces packageClose() and packageDelete() with a single call, primarily
// * to make it easier to handle the safe marking of HlPackage and DirectoryItem
// * objects as invalid.
// * @param pkg The package to remove and close.
// */
// public void packageRemove(HlPackage pkg);
//
// public void packageRemoveAll();
//
// public boolean packageGetExtractable(DirectoryItem file);
//
// public int packageGetFileSize(DirectoryItem file);
//
// public int packageGetFileSizeOnDisk(DirectoryItem file);
//
// public HlStream packageCreateStream(DirectoryItem file);
//
// public HlStream fileCreateStream(DirectoryItem item);
// }
| import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedCalls;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package com.technofovea.hllib;
class InvocationManager implements InvocationHandler {
private static final Logger logger = LoggerFactory.getLogger(InvocationManager.class);
FullLibrary delegate;
ManagedCallImpl lackey;
InvocationManager(FullLibrary target) {
super();
this.delegate = target;
lackey = new ManagedCallImpl(this.delegate);
}
@Override
protected void finalize() throws Throwable {
delegate.shutdown();
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (args == null) {
args = new Object[0];
}
logger.trace("New invocation: "+method.getName());
// Depending on what comes in, normally target the libarary instance or
// else retarget to our managed call implementation.
Object target = delegate;
Object result = null;
// Anything declared in ManagedLibrary or sub-interfaces is something we
// must intercept and re-target. | // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedCalls.java
// public interface ManagedCalls {
//
// public int itemGetSize(DirectoryItem item);
//
// public int itemGetSizeOnDisk(DirectoryItem item);
//
// public long itemGetSizeEx(DirectoryItem item);
//
// public long itemGetSizeOnDiskEx(DirectoryItem item);
//
// public String itemGetPath(DirectoryItem item);
//
// public HlPackage getCurrentlyBoundPackage();
//
// public HlPackage createPackage(PackageType ePackageType);
//
// public PackageType getPackageType(File f);
//
// /**
// * Replaces packageClose() and packageDelete() with a single call, primarily
// * to make it easier to handle the safe marking of HlPackage and DirectoryItem
// * objects as invalid.
// * @param pkg The package to remove and close.
// */
// public void packageRemove(HlPackage pkg);
//
// public void packageRemoveAll();
//
// public boolean packageGetExtractable(DirectoryItem file);
//
// public int packageGetFileSize(DirectoryItem file);
//
// public int packageGetFileSizeOnDisk(DirectoryItem file);
//
// public HlStream packageCreateStream(DirectoryItem file);
//
// public HlStream fileCreateStream(DirectoryItem item);
// }
// Path: src/main/java/com/technofovea/hllib/InvocationManager.java
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedCalls;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.technofovea.hllib;
class InvocationManager implements InvocationHandler {
private static final Logger logger = LoggerFactory.getLogger(InvocationManager.class);
FullLibrary delegate;
ManagedCallImpl lackey;
InvocationManager(FullLibrary target) {
super();
this.delegate = target;
lackey = new ManagedCallImpl(this.delegate);
}
@Override
protected void finalize() throws Throwable {
delegate.shutdown();
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (args == null) {
args = new Object[0];
}
logger.trace("New invocation: "+method.getName());
// Depending on what comes in, normally target the libarary instance or
// else retarget to our managed call implementation.
Object target = delegate;
Object result = null;
// Anything declared in ManagedLibrary or sub-interfaces is something we
// must intercept and re-target. | if (ManagedCalls.class.isAssignableFrom(method.getDeclaringClass())) { |
DHager/jhllib | src/main/java/com/technofovea/hllib/TestRun.java | // Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary; | package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class TestRun {
public static void main(String[] args){
System.out.println("Attempting to load HlLib..."); | // Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/main/java/com/technofovea/hllib/TestRun.java
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class TestRun {
public static void main(String[] args){
System.out.println("Attempting to load HlLib..."); | ManagedLibrary lib = HlLib.getLibrary(); |
DHager/jhllib | src/main/java/com/technofovea/hllib/TestRun.java | // Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary; | package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class TestRun {
public static void main(String[] args){
System.out.println("Attempting to load HlLib...");
ManagedLibrary lib = HlLib.getLibrary();
System.out.println("Retrieving version..."); | // Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/main/java/com/technofovea/hllib/TestRun.java
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class TestRun {
public static void main(String[] args){
System.out.println("Attempting to load HlLib...");
ManagedLibrary lib = HlLib.getLibrary();
System.out.println("Retrieving version..."); | String version = lib.getString(HlOption.VERSION); |
DHager/jhllib | src/main/java/com/technofovea/hllib/ManagedCallImpl.java | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedCalls.java
// public interface ManagedCalls {
//
// public int itemGetSize(DirectoryItem item);
//
// public int itemGetSizeOnDisk(DirectoryItem item);
//
// public long itemGetSizeEx(DirectoryItem item);
//
// public long itemGetSizeOnDiskEx(DirectoryItem item);
//
// public String itemGetPath(DirectoryItem item);
//
// public HlPackage getCurrentlyBoundPackage();
//
// public HlPackage createPackage(PackageType ePackageType);
//
// public PackageType getPackageType(File f);
//
// /**
// * Replaces packageClose() and packageDelete() with a single call, primarily
// * to make it easier to handle the safe marking of HlPackage and DirectoryItem
// * objects as invalid.
// * @param pkg The package to remove and close.
// */
// public void packageRemove(HlPackage pkg);
//
// public void packageRemoveAll();
//
// public boolean packageGetExtractable(DirectoryItem file);
//
// public int packageGetFileSize(DirectoryItem file);
//
// public int packageGetFileSizeOnDisk(DirectoryItem file);
//
// public HlStream packageCreateStream(DirectoryItem file);
//
// public HlStream fileCreateStream(DirectoryItem item);
// }
| import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedCalls;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; |
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
class ManagedCallImpl implements ManagedCalls {
private static final Logger logger = LoggerFactory.getLogger(DirectoryItem.class);
static final int PATH_BUFFER_SIZE = 512;
byte[] pathBuffer = new byte[PATH_BUFFER_SIZE]; | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedCalls.java
// public interface ManagedCalls {
//
// public int itemGetSize(DirectoryItem item);
//
// public int itemGetSizeOnDisk(DirectoryItem item);
//
// public long itemGetSizeEx(DirectoryItem item);
//
// public long itemGetSizeOnDiskEx(DirectoryItem item);
//
// public String itemGetPath(DirectoryItem item);
//
// public HlPackage getCurrentlyBoundPackage();
//
// public HlPackage createPackage(PackageType ePackageType);
//
// public PackageType getPackageType(File f);
//
// /**
// * Replaces packageClose() and packageDelete() with a single call, primarily
// * to make it easier to handle the safe marking of HlPackage and DirectoryItem
// * objects as invalid.
// * @param pkg The package to remove and close.
// */
// public void packageRemove(HlPackage pkg);
//
// public void packageRemoveAll();
//
// public boolean packageGetExtractable(DirectoryItem file);
//
// public int packageGetFileSize(DirectoryItem file);
//
// public int packageGetFileSizeOnDisk(DirectoryItem file);
//
// public HlStream packageCreateStream(DirectoryItem file);
//
// public HlStream fileCreateStream(DirectoryItem item);
// }
// Path: src/main/java/com/technofovea/hllib/ManagedCallImpl.java
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedCalls;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
class ManagedCallImpl implements ManagedCalls {
private static final Logger logger = LoggerFactory.getLogger(DirectoryItem.class);
static final int PATH_BUFFER_SIZE = 512;
byte[] pathBuffer = new byte[PATH_BUFFER_SIZE]; | FullLibrary lib; |
DHager/jhllib | src/main/java/com/technofovea/hllib/ManagedCallImpl.java | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedCalls.java
// public interface ManagedCalls {
//
// public int itemGetSize(DirectoryItem item);
//
// public int itemGetSizeOnDisk(DirectoryItem item);
//
// public long itemGetSizeEx(DirectoryItem item);
//
// public long itemGetSizeOnDiskEx(DirectoryItem item);
//
// public String itemGetPath(DirectoryItem item);
//
// public HlPackage getCurrentlyBoundPackage();
//
// public HlPackage createPackage(PackageType ePackageType);
//
// public PackageType getPackageType(File f);
//
// /**
// * Replaces packageClose() and packageDelete() with a single call, primarily
// * to make it easier to handle the safe marking of HlPackage and DirectoryItem
// * objects as invalid.
// * @param pkg The package to remove and close.
// */
// public void packageRemove(HlPackage pkg);
//
// public void packageRemoveAll();
//
// public boolean packageGetExtractable(DirectoryItem file);
//
// public int packageGetFileSize(DirectoryItem file);
//
// public int packageGetFileSizeOnDisk(DirectoryItem file);
//
// public HlStream packageCreateStream(DirectoryItem file);
//
// public HlStream fileCreateStream(DirectoryItem item);
// }
| import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedCalls;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | }
}
public long itemGetSizeEx(DirectoryItem item) {
LongByReference temp = new LongByReference();
boolean success = lib.itemGetSizeEx(item, temp);
if (success) {
return temp.getValue();
} else {
logger.error("Failed getting size for DirectoryItem: {}", this.itemGetPath(item));
return -1;
}
}
public long itemGetSizeOnDiskEx(DirectoryItem item) {
LongByReference temp = new LongByReference();
boolean success = lib.itemGetSizeOnDiskEx(item, temp);
if (success) {
return temp.getValue();
} else {
logger.error("Failed getting size-on-disk for DirectoryItem: {} ", this.itemGetPath(item));
return -1;
}
}
public String itemGetPath(DirectoryItem item) {
lib.itemGetPath(item, pathBuffer, pathBuffer.length);
return Native.toString(pathBuffer);
}
| // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedCalls.java
// public interface ManagedCalls {
//
// public int itemGetSize(DirectoryItem item);
//
// public int itemGetSizeOnDisk(DirectoryItem item);
//
// public long itemGetSizeEx(DirectoryItem item);
//
// public long itemGetSizeOnDiskEx(DirectoryItem item);
//
// public String itemGetPath(DirectoryItem item);
//
// public HlPackage getCurrentlyBoundPackage();
//
// public HlPackage createPackage(PackageType ePackageType);
//
// public PackageType getPackageType(File f);
//
// /**
// * Replaces packageClose() and packageDelete() with a single call, primarily
// * to make it easier to handle the safe marking of HlPackage and DirectoryItem
// * objects as invalid.
// * @param pkg The package to remove and close.
// */
// public void packageRemove(HlPackage pkg);
//
// public void packageRemoveAll();
//
// public boolean packageGetExtractable(DirectoryItem file);
//
// public int packageGetFileSize(DirectoryItem file);
//
// public int packageGetFileSizeOnDisk(DirectoryItem file);
//
// public HlStream packageCreateStream(DirectoryItem file);
//
// public HlStream fileCreateStream(DirectoryItem item);
// }
// Path: src/main/java/com/technofovea/hllib/ManagedCallImpl.java
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedCalls;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
}
public long itemGetSizeEx(DirectoryItem item) {
LongByReference temp = new LongByReference();
boolean success = lib.itemGetSizeEx(item, temp);
if (success) {
return temp.getValue();
} else {
logger.error("Failed getting size for DirectoryItem: {}", this.itemGetPath(item));
return -1;
}
}
public long itemGetSizeOnDiskEx(DirectoryItem item) {
LongByReference temp = new LongByReference();
boolean success = lib.itemGetSizeOnDiskEx(item, temp);
if (success) {
return temp.getValue();
} else {
logger.error("Failed getting size-on-disk for DirectoryItem: {} ", this.itemGetPath(item));
return -1;
}
}
public String itemGetPath(DirectoryItem item) {
lib.itemGetPath(item, pathBuffer, pathBuffer.length);
return Native.toString(pathBuffer);
}
| public HlPackage createPackage(PackageType ePackageType) { |
DHager/jhllib | src/main/java/com/technofovea/hllib/datatypes/Attribute.java | // Path: src/main/java/com/technofovea/hllib/enums/HlAttributeType.java
// public enum HlAttributeType implements JnaEnum<HlAttributeType> {
//
// INVALID,
// BOOLEAN,
// INTEGER,
// UNSIGNED_INTEGER,
// FLOAT,
// STRING;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public HlAttributeType getForValue(int i) {
// for(HlAttributeType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
//
//
// }
| import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.technofovea.hllib.enums.HlAttributeType; |
package com.technofovea.hllib.datatypes;
/**
* This class is used to retrieve "Attribute" values from HLLib. It's a bit
* tricky.
*
* Generally speaking you should only need to use the following methods:
* getType()
* getJavaName()
* getJavaData()
*
* @author Darien Hager
*/
public class Attribute extends Structure implements Structure.ByReference {
public static class AttributeUnion extends Union {
/*
public boolean Boolean = false;
public int Integer = 0;
public int UnsignedInteger = 0;
public float Float = 0;
public byte[] String = new byte[252];
*/
//public BooleanStruct b = new BooleanStruct();
public boolean b = false;
public int i = 0;
public UnsignedStruct ui = new UnsignedStruct();
public float f = 0;
public byte[] s = new byte[256];
}
public int attribTypeId; // Ordinal of corresponding HlAttributeType
//public HlAttributeTypeHolder attrib;
//public int attribId;
public byte[] nameBuf = new byte[252];
public AttributeUnion Value = new AttributeUnion();
| // Path: src/main/java/com/technofovea/hllib/enums/HlAttributeType.java
// public enum HlAttributeType implements JnaEnum<HlAttributeType> {
//
// INVALID,
// BOOLEAN,
// INTEGER,
// UNSIGNED_INTEGER,
// FLOAT,
// STRING;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public HlAttributeType getForValue(int i) {
// for(HlAttributeType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
//
//
// }
// Path: src/main/java/com/technofovea/hllib/datatypes/Attribute.java
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.technofovea.hllib.enums.HlAttributeType;
package com.technofovea.hllib.datatypes;
/**
* This class is used to retrieve "Attribute" values from HLLib. It's a bit
* tricky.
*
* Generally speaking you should only need to use the following methods:
* getType()
* getJavaName()
* getJavaData()
*
* @author Darien Hager
*/
public class Attribute extends Structure implements Structure.ByReference {
public static class AttributeUnion extends Union {
/*
public boolean Boolean = false;
public int Integer = 0;
public int UnsignedInteger = 0;
public float Float = 0;
public byte[] String = new byte[252];
*/
//public BooleanStruct b = new BooleanStruct();
public boolean b = false;
public int i = 0;
public UnsignedStruct ui = new UnsignedStruct();
public float f = 0;
public byte[] s = new byte[256];
}
public int attribTypeId; // Ordinal of corresponding HlAttributeType
//public HlAttributeTypeHolder attrib;
//public int attribId;
public byte[] nameBuf = new byte[252];
public AttributeUnion Value = new AttributeUnion();
| private void doRead(HlAttributeType type) { |
DHager/jhllib | src/main/java/com/technofovea/hllib/HlLib.java | // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.FunctionMapper;
import com.sun.jna.NativeLibrary;
import com.technofovea.hllib.methods.FullLibrary;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package com.technofovea.hllib;
/**
* This class provides access to the singleton libary interface with the HlLib
* DLL. It is possible to either request the raw interface, or the safer proxied
* "managed" interface. These are not separate instances, just different levels
* of safety for accessing the singleton.
*
* @author Darien Hager
*/
public class HlLib {
public static final String LIBRARY_NAME = "hllib";
public static final String ARCH_PROPERTY = "sun.arch.data.model";
public static final String ARCH_32 = "32";
public static final String ARCH_64 = "64";
public static final String ARCH_32_SUFFIX = "_32";
public static final String ARCH_64_SUFFIX = "_64";
private static final Logger logger = LoggerFactory.getLogger(HlLib.class);
public static final String LIBRARY_VERSION = "2.4.0"; | // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/main/java/com/technofovea/hllib/HlLib.java
import com.sun.jna.FunctionMapper;
import com.sun.jna.NativeLibrary;
import com.technofovea.hllib.methods.FullLibrary;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.technofovea.hllib;
/**
* This class provides access to the singleton libary interface with the HlLib
* DLL. It is possible to either request the raw interface, or the safer proxied
* "managed" interface. These are not separate instances, just different levels
* of safety for accessing the singleton.
*
* @author Darien Hager
*/
public class HlLib {
public static final String LIBRARY_NAME = "hllib";
public static final String ARCH_PROPERTY = "sun.arch.data.model";
public static final String ARCH_32 = "32";
public static final String ARCH_64 = "64";
public static final String ARCH_32_SUFFIX = "_32";
public static final String ARCH_64_SUFFIX = "_64";
private static final Logger logger = LoggerFactory.getLogger(HlLib.class);
public static final String LIBRARY_VERSION = "2.4.0"; | static ManagedLibrary instance = null; |
DHager/jhllib | src/main/java/com/technofovea/hllib/HlLib.java | // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.FunctionMapper;
import com.sun.jna.NativeLibrary;
import com.technofovea.hllib.methods.FullLibrary;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package com.technofovea.hllib;
/**
* This class provides access to the singleton libary interface with the HlLib
* DLL. It is possible to either request the raw interface, or the safer proxied
* "managed" interface. These are not separate instances, just different levels
* of safety for accessing the singleton.
*
* @author Darien Hager
*/
public class HlLib {
public static final String LIBRARY_NAME = "hllib";
public static final String ARCH_PROPERTY = "sun.arch.data.model";
public static final String ARCH_32 = "32";
public static final String ARCH_64 = "64";
public static final String ARCH_32_SUFFIX = "_32";
public static final String ARCH_64_SUFFIX = "_64";
private static final Logger logger = LoggerFactory.getLogger(HlLib.class);
public static final String LIBRARY_VERSION = "2.4.0";
static ManagedLibrary instance = null; | // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/main/java/com/technofovea/hllib/HlLib.java
import com.sun.jna.FunctionMapper;
import com.sun.jna.NativeLibrary;
import com.technofovea.hllib.methods.FullLibrary;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.technofovea.hllib;
/**
* This class provides access to the singleton libary interface with the HlLib
* DLL. It is possible to either request the raw interface, or the safer proxied
* "managed" interface. These are not separate instances, just different levels
* of safety for accessing the singleton.
*
* @author Darien Hager
*/
public class HlLib {
public static final String LIBRARY_NAME = "hllib";
public static final String ARCH_PROPERTY = "sun.arch.data.model";
public static final String ARCH_32 = "32";
public static final String ARCH_64 = "64";
public static final String ARCH_32_SUFFIX = "_32";
public static final String ARCH_64_SUFFIX = "_64";
private static final Logger logger = LoggerFactory.getLogger(HlLib.class);
public static final String LIBRARY_VERSION = "2.4.0";
static ManagedLibrary instance = null; | static FullLibrary rawInstance; |
DHager/jhllib | src/main/java/com/technofovea/hllib/HlLib.java | // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.FunctionMapper;
import com.sun.jna.NativeLibrary;
import com.technofovea.hllib.methods.FullLibrary;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | options.put(Library.OPTION_TYPE_MAPPER, new HlTypeMapper());
options.put(Library.OPTION_FUNCTION_MAPPER, func_mapper);
logger.debug("Detecting architecture from property {}", ARCH_PROPERTY);
String arch = System.getProperty(ARCH_PROPERTY);
final String libName;
if (ARCH_32.equals(arch)) {
libName = LIBRARY_NAME + ARCH_32_SUFFIX;
} else if (ARCH_64.equals(arch)) {
libName = LIBRARY_NAME + ARCH_64_SUFFIX;
} else {
logger.warn("Unable to determine architecture (32-bit vs 64-bit) for HlLib. Defaulting to 32bit.");
libName = LIBRARY_NAME + ARCH_32_SUFFIX;
}
logger.info("Loading native library: {}", libName);
rawInstance = (FullLibrary) Native.loadLibrary(libName, FullLibrary.class, options);
logger.debug("Calling library initialization function");
rawInstance.initialize();
logger.debug("Creating dynamic proxy for library access");
handler = new InvocationManager(rawInstance);
ManagedLibrary proxy = (ManagedLibrary) Proxy.newProxyInstance(
FullLibrary.class.getClassLoader(),
new Class[]{ManagedLibrary.class},
handler);
instance = proxy;
| // Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/main/java/com/technofovea/hllib/HlLib.java
import com.sun.jna.FunctionMapper;
import com.sun.jna.NativeLibrary;
import com.technofovea.hllib.methods.FullLibrary;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
options.put(Library.OPTION_TYPE_MAPPER, new HlTypeMapper());
options.put(Library.OPTION_FUNCTION_MAPPER, func_mapper);
logger.debug("Detecting architecture from property {}", ARCH_PROPERTY);
String arch = System.getProperty(ARCH_PROPERTY);
final String libName;
if (ARCH_32.equals(arch)) {
libName = LIBRARY_NAME + ARCH_32_SUFFIX;
} else if (ARCH_64.equals(arch)) {
libName = LIBRARY_NAME + ARCH_64_SUFFIX;
} else {
logger.warn("Unable to determine architecture (32-bit vs 64-bit) for HlLib. Defaulting to 32bit.");
libName = LIBRARY_NAME + ARCH_32_SUFFIX;
}
logger.info("Loading native library: {}", libName);
rawInstance = (FullLibrary) Native.loadLibrary(libName, FullLibrary.class, options);
logger.debug("Calling library initialization function");
rawInstance.initialize();
logger.debug("Creating dynamic proxy for library access");
handler = new InvocationManager(rawInstance);
ManagedLibrary proxy = (ManagedLibrary) Proxy.newProxyInstance(
FullLibrary.class.getClassLoader(),
new Class[]{ManagedLibrary.class},
handler);
instance = proxy;
| String version = instance.getString(HlOption.VERSION); |
DHager/jhllib | src/test/java/com/technofovea/hllib/PointerInvalidationTest.java | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; | package com.technofovea.hllib;
/**
* @author Darien Hager
*/
public class PointerInvalidationTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Before
public void setup() throws Exception {
Assert.assertTrue(HlLib.handler.lackey.openPackages.size() == 0);
Assert.assertTrue(HlPackage.cache.map.size() == 0);
}
@After
public void teardown() throws Exception {
Assert.assertTrue(HlLib.handler.lackey.openPackages.size() == 0);
Assert.assertTrue(HlPackage.cache.map.size() == 0);
}
@Test(expected = IllegalStateException.class)
public void packageRootFailure() throws Exception {
File target = new File(GcfFinder.getTestGcf().toURI()); | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/PointerInvalidationTest.java
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
* @author Darien Hager
*/
public class PointerInvalidationTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Before
public void setup() throws Exception {
Assert.assertTrue(HlLib.handler.lackey.openPackages.size() == 0);
Assert.assertTrue(HlPackage.cache.map.size() == 0);
}
@After
public void teardown() throws Exception {
Assert.assertTrue(HlLib.handler.lackey.openPackages.size() == 0);
Assert.assertTrue(HlPackage.cache.map.size() == 0);
}
@Test(expected = IllegalStateException.class)
public void packageRootFailure() throws Exception {
File target = new File(GcfFinder.getTestGcf().toURI()); | FileMode fm = new FileMode(); |
DHager/jhllib | src/test/java/com/technofovea/hllib/PointerInvalidationTest.java | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; | package com.technofovea.hllib;
/**
* @author Darien Hager
*/
public class PointerInvalidationTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Before
public void setup() throws Exception {
Assert.assertTrue(HlLib.handler.lackey.openPackages.size() == 0);
Assert.assertTrue(HlPackage.cache.map.size() == 0);
}
@After
public void teardown() throws Exception {
Assert.assertTrue(HlLib.handler.lackey.openPackages.size() == 0);
Assert.assertTrue(HlPackage.cache.map.size() == 0);
}
@Test(expected = IllegalStateException.class)
public void packageRootFailure() throws Exception {
File target = new File(GcfFinder.getTestGcf().toURI());
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
| // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/PointerInvalidationTest.java
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
* @author Darien Hager
*/
public class PointerInvalidationTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Before
public void setup() throws Exception {
Assert.assertTrue(HlLib.handler.lackey.openPackages.size() == 0);
Assert.assertTrue(HlPackage.cache.map.size() == 0);
}
@After
public void teardown() throws Exception {
Assert.assertTrue(HlLib.handler.lackey.openPackages.size() == 0);
Assert.assertTrue(HlPackage.cache.map.size() == 0);
}
@Test(expected = IllegalStateException.class)
public void packageRootFailure() throws Exception {
File target = new File(GcfFinder.getTestGcf().toURI());
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
| PackageType pt = fixture.getPackageType(target); |
DHager/jhllib | src/test/java/com/technofovea/hllib/ExtractTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class ExtractTest {
private static final String TEST_FILE = "root\\readme.txt";
private static final int TEST_FILE_SIZE = 39818;
private static final String TEST_FILE_START = "Half-Life\r\nVersion 1.1.1.1\r\nReadme File"; | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/ExtractTest.java
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class ExtractTest {
private static final String TEST_FILE = "root\\readme.txt";
private static final int TEST_FILE_SIZE = 39818;
private static final String TEST_FILE_START = "Half-Life\r\nVersion 1.1.1.1\r\nReadme File"; | static ManagedLibrary fixture; |
DHager/jhllib | src/test/java/com/technofovea/hllib/ExtractTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class ExtractTest {
private static final String TEST_FILE = "root\\readme.txt";
private static final int TEST_FILE_SIZE = 39818;
private static final String TEST_FILE_START = "Half-Life\r\nVersion 1.1.1.1\r\nReadme File";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Test
public void extractReadme() throws Exception {
URL testurl = GcfFinder.getTestGcf();
File target = new File(testurl.toURI());
| // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/ExtractTest.java
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class ExtractTest {
private static final String TEST_FILE = "root\\readme.txt";
private static final int TEST_FILE_SIZE = 39818;
private static final String TEST_FILE_START = "Half-Life\r\nVersion 1.1.1.1\r\nReadme File";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Test
public void extractReadme() throws Exception {
URL testurl = GcfFinder.getTestGcf();
File target = new File(testurl.toURI());
| PackageType pt = fixture.getPackageType(target); |
DHager/jhllib | src/test/java/com/technofovea/hllib/ExtractTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class ExtractTest {
private static final String TEST_FILE = "root\\readme.txt";
private static final int TEST_FILE_SIZE = 39818;
private static final String TEST_FILE_START = "Half-Life\r\nVersion 1.1.1.1\r\nReadme File";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Test
public void extractReadme() throws Exception {
URL testurl = GcfFinder.getTestGcf();
File target = new File(testurl.toURI());
PackageType pt = fixture.getPackageType(target);
HlPackage pkg = fixture.createPackage(pt);
if (pkg == null) { | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/ExtractTest.java
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class ExtractTest {
private static final String TEST_FILE = "root\\readme.txt";
private static final int TEST_FILE_SIZE = 39818;
private static final String TEST_FILE_START = "Half-Life\r\nVersion 1.1.1.1\r\nReadme File";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Test
public void extractReadme() throws Exception {
URL testurl = GcfFinder.getTestGcf();
File target = new File(testurl.toURI());
PackageType pt = fixture.getPackageType(target);
HlPackage pkg = fixture.createPackage(pt);
if (pkg == null) { | String err = fixture.getString(HlOption.ERROR); |
DHager/jhllib | src/test/java/com/technofovea/hllib/ExtractTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class ExtractTest {
private static final String TEST_FILE = "root\\readme.txt";
private static final int TEST_FILE_SIZE = 39818;
private static final String TEST_FILE_START = "Half-Life\r\nVersion 1.1.1.1\r\nReadme File";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Test
public void extractReadme() throws Exception {
URL testurl = GcfFinder.getTestGcf();
File target = new File(testurl.toURI());
PackageType pt = fixture.getPackageType(target);
HlPackage pkg = fixture.createPackage(pt);
if (pkg == null) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("Unable to create package (" + pt.toString() + ") for binding to file: " + err);
}
boolean r_bind = fixture.bindPackage(pkg);
if (!r_bind) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("Could not bind package to file: " + err);
}
| // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/ExtractTest.java
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class ExtractTest {
private static final String TEST_FILE = "root\\readme.txt";
private static final int TEST_FILE_SIZE = 39818;
private static final String TEST_FILE_START = "Half-Life\r\nVersion 1.1.1.1\r\nReadme File";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
@Test
public void extractReadme() throws Exception {
URL testurl = GcfFinder.getTestGcf();
File target = new File(testurl.toURI());
PackageType pt = fixture.getPackageType(target);
HlPackage pkg = fixture.createPackage(pt);
if (pkg == null) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("Unable to create package (" + pt.toString() + ") for binding to file: " + err);
}
boolean r_bind = fixture.bindPackage(pkg);
if (!r_bind) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("Could not bind package to file: " + err);
}
| FileMode fm = new FileMode(); |
DHager/jhllib | src/test/java/com/technofovea/hllib/ExtractTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; |
URL testurl = GcfFinder.getTestGcf();
File target = new File(testurl.toURI());
PackageType pt = fixture.getPackageType(target);
HlPackage pkg = fixture.createPackage(pt);
if (pkg == null) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("Unable to create package (" + pt.toString() + ") for binding to file: " + err);
}
boolean r_bind = fixture.bindPackage(pkg);
if (!r_bind) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("Could not bind package to file: " + err);
}
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ, true);
fm.set(FileMode.INDEX_MODE_VOLATILE);
fm.set(FileMode.INDEX_MODE_QUICK_FILEMAPPING);
boolean r_open = fixture.packageOpenFile(target.getAbsolutePath(), fm);
if (!r_open) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("An error occurred opening the file for reading " + target.getAbsolutePath() + " : " + err);
}
DirectoryItem root = fixture.packageGetRoot(); | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/ExtractTest.java
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
URL testurl = GcfFinder.getTestGcf();
File target = new File(testurl.toURI());
PackageType pt = fixture.getPackageType(target);
HlPackage pkg = fixture.createPackage(pt);
if (pkg == null) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("Unable to create package (" + pt.toString() + ") for binding to file: " + err);
}
boolean r_bind = fixture.bindPackage(pkg);
if (!r_bind) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("Could not bind package to file: " + err);
}
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ, true);
fm.set(FileMode.INDEX_MODE_VOLATILE);
fm.set(FileMode.INDEX_MODE_QUICK_FILEMAPPING);
boolean r_open = fixture.packageOpenFile(target.getAbsolutePath(), fm);
if (!r_open) {
String err = fixture.getString(HlOption.ERROR);
throw new HlLibException("An error occurred opening the file for reading " + target.getAbsolutePath() + " : " + err);
}
DirectoryItem root = fixture.packageGetRoot(); | assert (fixture.itemGetType(root).equals(DirectoryItemType.FOLDER)); |
DHager/jhllib | src/test/java/com/technofovea/hllib/ExtractTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | targetNode = child;
break;
}
}
}
Assert.assertNotNull(targetNode);
Assert.assertEquals(pkg, targetNode.parentPackage);
int extractable = fixture.fileGetExtractable(targetNode);
Assert.assertTrue(extractable > 0);
int actual_size = fixture.itemGetSize(targetNode);
Assert.assertEquals(TEST_FILE_SIZE, actual_size);
//Pointer stream = fixture.fileCreateStream(targetNode);
HlStream stream = fixture.fileCreateStream(targetNode);
Assert.assertNotNull(stream);
Assert.assertEquals(targetNode.parentPackage, stream.parentPackage);
FileMode streamMode = new FileMode();
streamMode.set(FileMode.INDEX_MODE_READ);
boolean r_streamopen = fixture.streamOpen(stream, streamMode);
Assert.assertTrue(r_streamopen);
| // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/HlOption.java
// public enum HlOption implements JnaEnum<HlOption> {
//
// VERSION,
// ERROR,
// ERROR_SYSTEM,
// ERROR_SHORT_FORMATED,
// ERROR_LONG_FORMATED,
// PROC_OPEN,
// PROC_CLOSE,
// PROC_READ,
// PROC_WRITE,
// PROC_SEEK,
// PROC_TELL,
// PROC_SIZE,
// PROC_EXTRACT_ITEM_START,
// PROC_EXTRACT_ITEM_END,
// PROC_EXTRACT_FILE_PROGRESS,
// PROC_VALIDATE_FILE_PROGRESS,
// OVERWRITE_FILES,
// PACKAGE_BOUND,
// PACKAGE_ID,
// PACKAGE_SIZE,
// PACKAGE_TOTAL_ALLOCATIONS,
// PACKAGE_TOTAL_MEMORY_ALLOCATED,
// PACKAGE_TOTAL_MEMORY_USED,
// READ_ENCRYPTED,
// FORCE_DEFRAGMENT,
// PROC_DEFRAGMENT_PROGRESS,
// PROC_DEFRAGMENT_PROGRESS_EX,;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
//
// public HlOption getForValue(int i) {
// for (HlOption o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/StreamType.java
// public enum StreamType implements JnaEnum<StreamType> {
//
// NONE,
// FILE,
// GCF,
// MAPPING,
// MEMORY,
// PROC,
// NULL;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public StreamType getForValue(int i) {
// for (StreamType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/ExtractTest.java
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.HlOption;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.enums.StreamType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
targetNode = child;
break;
}
}
}
Assert.assertNotNull(targetNode);
Assert.assertEquals(pkg, targetNode.parentPackage);
int extractable = fixture.fileGetExtractable(targetNode);
Assert.assertTrue(extractable > 0);
int actual_size = fixture.itemGetSize(targetNode);
Assert.assertEquals(TEST_FILE_SIZE, actual_size);
//Pointer stream = fixture.fileCreateStream(targetNode);
HlStream stream = fixture.fileCreateStream(targetNode);
Assert.assertNotNull(stream);
Assert.assertEquals(targetNode.parentPackage, stream.parentPackage);
FileMode streamMode = new FileMode();
streamMode.set(FileMode.INDEX_MODE_READ);
boolean r_streamopen = fixture.streamOpen(stream, streamMode);
Assert.assertTrue(r_streamopen);
| StreamType type = fixture.streamGetType(stream); |
DHager/jhllib | src/test/java/com/technofovea/hllib/FileListingTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; |
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
| // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/FileListingTest.java
import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
| static ManagedLibrary fixture; |
DHager/jhllib | src/test/java/com/technofovea/hllib/FileListingTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; |
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private void buildList(ManagedLibrary lib, DirectoryItem folder, Set<String> store){
List<DirectoryItem> children = folder.getChildren();
for(DirectoryItem child:children){ | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/FileListingTest.java
import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private void buildList(ManagedLibrary lib, DirectoryItem folder, Set<String> store){
List<DirectoryItem> children = folder.getChildren();
for(DirectoryItem child:children){ | if(lib.itemGetType(child) == DirectoryItemType.FOLDER){ |
DHager/jhllib | src/test/java/com/technofovea/hllib/FileListingTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; |
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private void buildList(ManagedLibrary lib, DirectoryItem folder, Set<String> store){
List<DirectoryItem> children = folder.getChildren();
for(DirectoryItem child:children){
if(lib.itemGetType(child) == DirectoryItemType.FOLDER){
buildList(lib, child, store);
}else{
store.add(lib.itemGetPath(child));
}
}
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception{ | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/FileListingTest.java
import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private void buildList(ManagedLibrary lib, DirectoryItem folder, Set<String> store){
List<DirectoryItem> children = folder.getChildren();
for(DirectoryItem child:children){
if(lib.itemGetType(child) == DirectoryItemType.FOLDER){
buildList(lib, child, store);
}else{
store.add(lib.itemGetPath(child));
}
}
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception{ | FileMode fm = new FileMode(); |
DHager/jhllib | src/test/java/com/technofovea/hllib/FileListingTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; |
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private void buildList(ManagedLibrary lib, DirectoryItem folder, Set<String> store){
List<DirectoryItem> children = folder.getChildren();
for(DirectoryItem child:children){
if(lib.itemGetType(child) == DirectoryItemType.FOLDER){
buildList(lib, child, store);
}else{
store.add(lib.itemGetPath(child));
}
}
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception{
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
| // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/FileListingTest.java
import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private void buildList(ManagedLibrary lib, DirectoryItem folder, Set<String> store){
List<DirectoryItem> children = folder.getChildren();
for(DirectoryItem child:children){
if(lib.itemGetType(child) == DirectoryItemType.FOLDER){
buildList(lib, child, store);
}else{
store.add(lib.itemGetPath(child));
}
}
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception{
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
| PackageType pt = lib.getPackageTypeFromName(target.getAbsolutePath()); |
DHager/jhllib | src/test/java/com/technofovea/hllib/FileListingTest.java | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; |
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private void buildList(ManagedLibrary lib, DirectoryItem folder, Set<String> store){
List<DirectoryItem> children = folder.getChildren();
for(DirectoryItem child:children){
if(lib.itemGetType(child) == DirectoryItemType.FOLDER){
buildList(lib, child, store);
}else{
store.add(lib.itemGetPath(child));
}
}
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception{
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
PackageType pt = lib.getPackageTypeFromName(target.getAbsolutePath());
if (pt == PackageType.NONE) {
FileInputStream fis = new FileInputStream(target); | // Path: src/main/java/com/technofovea/hllib/enums/DirectoryItemType.java
// public enum DirectoryItemType implements JnaEnum<DirectoryItemType> {
//
//
// NONE,
// FOLDER,
// FILE;
//
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal()+start;
// }
//
//
// public DirectoryItemType getForValue(int i) {
// for(DirectoryItemType o : this.values()){
// if(o.getIntValue() == i){
// return o;
// }
// }
// return null;
// }
//
//
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/FileListingTest.java
import com.sun.jna.Memory;
import com.technofovea.hllib.enums.DirectoryItemType;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FileListingTest {
private static final String TEST_BSP = "utest.bsp";
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private void buildList(ManagedLibrary lib, DirectoryItem folder, Set<String> store){
List<DirectoryItem> children = folder.getChildren();
for(DirectoryItem child:children){
if(lib.itemGetType(child) == DirectoryItemType.FOLDER){
buildList(lib, child, store);
}else{
store.add(lib.itemGetPath(child));
}
}
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception{
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
PackageType pt = lib.getPackageTypeFromName(target.getAbsolutePath());
if (pt == PackageType.NONE) {
FileInputStream fis = new FileInputStream(target); | byte[] testHeader = new byte[FullLibrary.HL_DEFAULT_PACKAGE_TEST_BUFFER_SIZE]; |
DHager/jhllib | src/test/java/com/technofovea/hllib/FindingTest.java | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FindType.java
// public class FindType extends BitSet implements NativeMapped{
//
// public static final int HL_FIND_FILES= 0;
// public static final int HL_FIND_FOLDERS= 1;
// public static final int HL_FIND_NO_RECURSE= 2;
// public static final int HL_FIND_CASE_SENSITIVE= 3;
// public static final int HL_FIND_MODE_STRING= 4;
// public static final int HL_FIND_MODE_SUBSTRING= 5;
//
// public int toInt(){
// int val =0;
// for(int i = 0; i < this.length(); i++){
// if(this.get(i)){
// val += (1<<i);
// }
// }
// return val;
// }
//
// public void fromInt(int intValue){
// this.clear();
// int max = 0;
// while(1<<max < intValue){
// max++;
// }
//
// for(int i=max; i > 0; i--){
// int part = 1<<i;
// if(part <= intValue){
// intValue -= part;
// this.set(i,true);
// }
// }
// }
//
//
// public Object toNative() {
// return this.toInt();
// }
//
// public Object fromNative(Object arg0, FromNativeContext arg1) {
// Integer i = (Integer)arg0;
// FindType fm = new FindType();
// fm.fromInt(i);
// return fm;
// }
//
// public Class nativeType() {
// return Integer.class;
// }
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.masks.FindType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FindingTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception { | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FindType.java
// public class FindType extends BitSet implements NativeMapped{
//
// public static final int HL_FIND_FILES= 0;
// public static final int HL_FIND_FOLDERS= 1;
// public static final int HL_FIND_NO_RECURSE= 2;
// public static final int HL_FIND_CASE_SENSITIVE= 3;
// public static final int HL_FIND_MODE_STRING= 4;
// public static final int HL_FIND_MODE_SUBSTRING= 5;
//
// public int toInt(){
// int val =0;
// for(int i = 0; i < this.length(); i++){
// if(this.get(i)){
// val += (1<<i);
// }
// }
// return val;
// }
//
// public void fromInt(int intValue){
// this.clear();
// int max = 0;
// while(1<<max < intValue){
// max++;
// }
//
// for(int i=max; i > 0; i--){
// int part = 1<<i;
// if(part <= intValue){
// intValue -= part;
// this.set(i,true);
// }
// }
// }
//
//
// public Object toNative() {
// return this.toInt();
// }
//
// public Object fromNative(Object arg0, FromNativeContext arg1) {
// Integer i = (Integer)arg0;
// FindType fm = new FindType();
// fm.fromInt(i);
// return fm;
// }
//
// public Class nativeType() {
// return Integer.class;
// }
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/FindingTest.java
import com.sun.jna.Memory;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.masks.FindType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FindingTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception { | FileMode fm = new FileMode(); |
DHager/jhllib | src/test/java/com/technofovea/hllib/FindingTest.java | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FindType.java
// public class FindType extends BitSet implements NativeMapped{
//
// public static final int HL_FIND_FILES= 0;
// public static final int HL_FIND_FOLDERS= 1;
// public static final int HL_FIND_NO_RECURSE= 2;
// public static final int HL_FIND_CASE_SENSITIVE= 3;
// public static final int HL_FIND_MODE_STRING= 4;
// public static final int HL_FIND_MODE_SUBSTRING= 5;
//
// public int toInt(){
// int val =0;
// for(int i = 0; i < this.length(); i++){
// if(this.get(i)){
// val += (1<<i);
// }
// }
// return val;
// }
//
// public void fromInt(int intValue){
// this.clear();
// int max = 0;
// while(1<<max < intValue){
// max++;
// }
//
// for(int i=max; i > 0; i--){
// int part = 1<<i;
// if(part <= intValue){
// intValue -= part;
// this.set(i,true);
// }
// }
// }
//
//
// public Object toNative() {
// return this.toInt();
// }
//
// public Object fromNative(Object arg0, FromNativeContext arg1) {
// Integer i = (Integer)arg0;
// FindType fm = new FindType();
// fm.fromInt(i);
// return fm;
// }
//
// public Class nativeType() {
// return Integer.class;
// }
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.masks.FindType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FindingTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception {
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
| // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FindType.java
// public class FindType extends BitSet implements NativeMapped{
//
// public static final int HL_FIND_FILES= 0;
// public static final int HL_FIND_FOLDERS= 1;
// public static final int HL_FIND_NO_RECURSE= 2;
// public static final int HL_FIND_CASE_SENSITIVE= 3;
// public static final int HL_FIND_MODE_STRING= 4;
// public static final int HL_FIND_MODE_SUBSTRING= 5;
//
// public int toInt(){
// int val =0;
// for(int i = 0; i < this.length(); i++){
// if(this.get(i)){
// val += (1<<i);
// }
// }
// return val;
// }
//
// public void fromInt(int intValue){
// this.clear();
// int max = 0;
// while(1<<max < intValue){
// max++;
// }
//
// for(int i=max; i > 0; i--){
// int part = 1<<i;
// if(part <= intValue){
// intValue -= part;
// this.set(i,true);
// }
// }
// }
//
//
// public Object toNative() {
// return this.toInt();
// }
//
// public Object fromNative(Object arg0, FromNativeContext arg1) {
// Integer i = (Integer)arg0;
// FindType fm = new FindType();
// fm.fromInt(i);
// return fm;
// }
//
// public Class nativeType() {
// return Integer.class;
// }
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/FindingTest.java
import com.sun.jna.Memory;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.masks.FindType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FindingTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception {
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
| PackageType pt = lib.getPackageTypeFromName(target.getAbsolutePath()); |
DHager/jhllib | src/test/java/com/technofovea/hllib/FindingTest.java | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FindType.java
// public class FindType extends BitSet implements NativeMapped{
//
// public static final int HL_FIND_FILES= 0;
// public static final int HL_FIND_FOLDERS= 1;
// public static final int HL_FIND_NO_RECURSE= 2;
// public static final int HL_FIND_CASE_SENSITIVE= 3;
// public static final int HL_FIND_MODE_STRING= 4;
// public static final int HL_FIND_MODE_SUBSTRING= 5;
//
// public int toInt(){
// int val =0;
// for(int i = 0; i < this.length(); i++){
// if(this.get(i)){
// val += (1<<i);
// }
// }
// return val;
// }
//
// public void fromInt(int intValue){
// this.clear();
// int max = 0;
// while(1<<max < intValue){
// max++;
// }
//
// for(int i=max; i > 0; i--){
// int part = 1<<i;
// if(part <= intValue){
// intValue -= part;
// this.set(i,true);
// }
// }
// }
//
//
// public Object toNative() {
// return this.toInt();
// }
//
// public Object fromNative(Object arg0, FromNativeContext arg1) {
// Integer i = (Integer)arg0;
// FindType fm = new FindType();
// fm.fromInt(i);
// return fm;
// }
//
// public Class nativeType() {
// return Integer.class;
// }
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.masks.FindType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FindingTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception {
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
PackageType pt = lib.getPackageTypeFromName(target.getAbsolutePath());
if (pt == PackageType.NONE) {
FileInputStream fis = new FileInputStream(target); | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FindType.java
// public class FindType extends BitSet implements NativeMapped{
//
// public static final int HL_FIND_FILES= 0;
// public static final int HL_FIND_FOLDERS= 1;
// public static final int HL_FIND_NO_RECURSE= 2;
// public static final int HL_FIND_CASE_SENSITIVE= 3;
// public static final int HL_FIND_MODE_STRING= 4;
// public static final int HL_FIND_MODE_SUBSTRING= 5;
//
// public int toInt(){
// int val =0;
// for(int i = 0; i < this.length(); i++){
// if(this.get(i)){
// val += (1<<i);
// }
// }
// return val;
// }
//
// public void fromInt(int intValue){
// this.clear();
// int max = 0;
// while(1<<max < intValue){
// max++;
// }
//
// for(int i=max; i > 0; i--){
// int part = 1<<i;
// if(part <= intValue){
// intValue -= part;
// this.set(i,true);
// }
// }
// }
//
//
// public Object toNative() {
// return this.toInt();
// }
//
// public Object fromNative(Object arg0, FromNativeContext arg1) {
// Integer i = (Integer)arg0;
// FindType fm = new FindType();
// fm.fromInt(i);
// return fm;
// }
//
// public Class nativeType() {
// return Integer.class;
// }
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/FindingTest.java
import com.sun.jna.Memory;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.masks.FindType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
package com.technofovea.hllib;
/**
*
* @author Darien Hager
*/
public class FindingTest {
static ManagedLibrary fixture;
@BeforeClass
public static void BeforeClass() throws Exception {
DllPathFinder.setJnaPathPath();
fixture = HlLib.getLibrary();
}
private HlPackage openFile(ManagedLibrary lib, File target) throws Exception {
FileMode fm = new FileMode();
fm.set(FileMode.INDEX_MODE_READ);
PackageType pt = lib.getPackageTypeFromName(target.getAbsolutePath());
if (pt == PackageType.NONE) {
FileInputStream fis = new FileInputStream(target); | byte[] testHeader = new byte[FullLibrary.HL_DEFAULT_PACKAGE_TEST_BUFFER_SIZE]; |
DHager/jhllib | src/test/java/com/technofovea/hllib/FindingTest.java | // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FindType.java
// public class FindType extends BitSet implements NativeMapped{
//
// public static final int HL_FIND_FILES= 0;
// public static final int HL_FIND_FOLDERS= 1;
// public static final int HL_FIND_NO_RECURSE= 2;
// public static final int HL_FIND_CASE_SENSITIVE= 3;
// public static final int HL_FIND_MODE_STRING= 4;
// public static final int HL_FIND_MODE_SUBSTRING= 5;
//
// public int toInt(){
// int val =0;
// for(int i = 0; i < this.length(); i++){
// if(this.get(i)){
// val += (1<<i);
// }
// }
// return val;
// }
//
// public void fromInt(int intValue){
// this.clear();
// int max = 0;
// while(1<<max < intValue){
// max++;
// }
//
// for(int i=max; i > 0; i--){
// int part = 1<<i;
// if(part <= intValue){
// intValue -= part;
// this.set(i,true);
// }
// }
// }
//
//
// public Object toNative() {
// return this.toInt();
// }
//
// public Object fromNative(Object arg0, FromNativeContext arg1) {
// Integer i = (Integer)arg0;
// FindType fm = new FindType();
// fm.fromInt(i);
// return fm;
// }
//
// public Class nativeType() {
// return Integer.class;
// }
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
| import com.sun.jna.Memory;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.masks.FindType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test; |
boolean r_open = lib.packageOpenFile(target.getAbsolutePath(), fm);
Assert.assertTrue(r_open);
return pkg;
}
@Test
public void testGcfListing() throws Exception {
URL testurl = GcfFinder.getTestGcf();
File testfile = new File(testurl.toURI());
HlPackage pkg = openFile(fixture, testfile);
String[] existingItems = new String[]{
"root\\valve\\cl_dlls\\GameUI.dll",
"root\\valve\\cl_dlls\\particleman.dll",
};
String[] absentItems = new String[]{
"root\\valve\\cl_dlls\\MissingFile.txt",
"root\\valve\\particleman.dll",
"root\\PARTICLEMAN.DLL",
"PARTICLEMAN.DLL",
};
DirectoryItem root = fixture.packageGetRoot();
| // Path: src/main/java/com/technofovea/hllib/enums/PackageType.java
// public enum PackageType implements JnaEnum<PackageType> {
//
// NONE,
// BSP,
// GCF,
// PAK,
// VBSP,
// WAD,
// XZP,
// ZIP,
// NCF,
// VPK;
//
// private static int start = 0;
//
// public int getIntValue() {
// return this.ordinal() + start;
// }
//
// public PackageType getForValue(
// int i) {
// for (PackageType o : this.values()) {
// if (o.getIntValue() == i) {
// return o;
// }
//
// }
// return null;
// }
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FileMode.java
// public class FileMode extends MappedMask{
//
// public static final int INDEX_MODE_READ= 0;
// public static final int INDEX_MODE_WRITE= 1;
// public static final int INDEX_MODE_CREATE= 2;
// public static final int INDEX_MODE_VOLATILE= 3;
// public static final int INDEX_MODE_NO_FILEMAPPING= 4;
// public static final int INDEX_MODE_QUICK_FILEMAPPING= 5;
//
// }
//
// Path: src/main/java/com/technofovea/hllib/masks/FindType.java
// public class FindType extends BitSet implements NativeMapped{
//
// public static final int HL_FIND_FILES= 0;
// public static final int HL_FIND_FOLDERS= 1;
// public static final int HL_FIND_NO_RECURSE= 2;
// public static final int HL_FIND_CASE_SENSITIVE= 3;
// public static final int HL_FIND_MODE_STRING= 4;
// public static final int HL_FIND_MODE_SUBSTRING= 5;
//
// public int toInt(){
// int val =0;
// for(int i = 0; i < this.length(); i++){
// if(this.get(i)){
// val += (1<<i);
// }
// }
// return val;
// }
//
// public void fromInt(int intValue){
// this.clear();
// int max = 0;
// while(1<<max < intValue){
// max++;
// }
//
// for(int i=max; i > 0; i--){
// int part = 1<<i;
// if(part <= intValue){
// intValue -= part;
// this.set(i,true);
// }
// }
// }
//
//
// public Object toNative() {
// return this.toInt();
// }
//
// public Object fromNative(Object arg0, FromNativeContext arg1) {
// Integer i = (Integer)arg0;
// FindType fm = new FindType();
// fm.fromInt(i);
// return fm;
// }
//
// public Class nativeType() {
// return Integer.class;
// }
//
//
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/FullLibrary.java
// public interface FullLibrary extends BasicLibrary {
//
// /**
// * Called to initialize the DLL library.
// */
// public void initialize();
//
// /**
// * Called to shut down the DLL library.
// */
// public void shutdown();
//
// public boolean itemGetSize(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeEx(DirectoryItem item, LongByReference size);
//
// public boolean itemGetSizeOnDisk(DirectoryItem item, IntByReference size);
//
// public boolean itemGetSizeOnDiskEx(DirectoryItem item, LongByReference size);
//
// public void itemGetPath(DirectoryItem item, byte[] buffer, int bufsize);
//
// public boolean createPackage(PackageType ePackageType, IntByReference packageId);
//
// public void packageClose();
//
// public void deletePackage(HlPackage pkg);
//
// public boolean packageGetExtractable(DirectoryItem file, ByteByReference extractable);
//
// public boolean packageGetFileSize(DirectoryItem file, IntByReference size);
//
// public boolean packageGetFileSizeOnDisk(DirectoryItem file, IntByReference size);
//
// public boolean packageCreateStream(DirectoryItem file, PointerByReference stream);
//
// public boolean fileCreateStream(DirectoryItem item, PointerByReference stream);
// }
//
// Path: src/main/java/com/technofovea/hllib/methods/ManagedLibrary.java
// public interface ManagedLibrary extends BasicLibrary, ManagedCalls{
//
// }
// Path: src/test/java/com/technofovea/hllib/FindingTest.java
import com.sun.jna.Memory;
import com.technofovea.hllib.enums.PackageType;
import com.technofovea.hllib.masks.FileMode;
import com.technofovea.hllib.masks.FindType;
import com.technofovea.hllib.methods.FullLibrary;
import com.technofovea.hllib.methods.ManagedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
boolean r_open = lib.packageOpenFile(target.getAbsolutePath(), fm);
Assert.assertTrue(r_open);
return pkg;
}
@Test
public void testGcfListing() throws Exception {
URL testurl = GcfFinder.getTestGcf();
File testfile = new File(testurl.toURI());
HlPackage pkg = openFile(fixture, testfile);
String[] existingItems = new String[]{
"root\\valve\\cl_dlls\\GameUI.dll",
"root\\valve\\cl_dlls\\particleman.dll",
};
String[] absentItems = new String[]{
"root\\valve\\cl_dlls\\MissingFile.txt",
"root\\valve\\particleman.dll",
"root\\PARTICLEMAN.DLL",
"PARTICLEMAN.DLL",
};
DirectoryItem root = fixture.packageGetRoot();
| FindType ft = new FindType(); |
hsyyid/EssentialCmds | src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/TPAHereExecutor.java | // Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAHereEvent.java
// public class TPAHereEvent extends AbstractEvent implements Cancellable
// {
// private boolean cancelled = false;
//
// private Player sender;
// private Player recipient;
//
// public Player getSender()
// {
// return sender;
// }
//
// public Player getRecipient()
// {
// return recipient;
// }
//
// public boolean isCancelled()
// {
// return cancelled;
// }
//
// public void setCancelled(boolean cancel)
// {
// cancelled = cancel;
// }
//
// public TPAHereEvent(Player sender, Player recipient)
// {
// this.sender = sender;
// this.recipient = recipient;
// }
//
// @Override
// public Cause getCause()
// {
// return Cause.of(NamedCause.source(this.sender));
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
//
// /**
// * The command to execute on an Async scheduler thread.
// *
// * <p>
// * <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
// * calls back on the main thread.
// * </p>
// *
// * @param src The {@link CommandSource}
// * @param args The arguments.
// */
// public abstract void executeAsync(CommandSource src, CommandContext args);
//
// @Override
// public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
// Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
// return CommandResult.success();
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
| import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAHereEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments; | /*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class TPAHereExecutor extends AsyncCommandExecutorBase
{ | // Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAHereEvent.java
// public class TPAHereEvent extends AbstractEvent implements Cancellable
// {
// private boolean cancelled = false;
//
// private Player sender;
// private Player recipient;
//
// public Player getSender()
// {
// return sender;
// }
//
// public Player getRecipient()
// {
// return recipient;
// }
//
// public boolean isCancelled()
// {
// return cancelled;
// }
//
// public void setCancelled(boolean cancel)
// {
// cancelled = cancel;
// }
//
// public TPAHereEvent(Player sender, Player recipient)
// {
// this.sender = sender;
// this.recipient = recipient;
// }
//
// @Override
// public Cause getCause()
// {
// return Cause.of(NamedCause.source(this.sender));
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
//
// /**
// * The command to execute on an Async scheduler thread.
// *
// * <p>
// * <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
// * calls back on the main thread.
// * </p>
// *
// * @param src The {@link CommandSource}
// * @param args The arguments.
// */
// public abstract void executeAsync(CommandSource src, CommandContext args);
//
// @Override
// public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
// Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
// return CommandResult.success();
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
// Path: src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/TPAHereExecutor.java
import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAHereEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
/*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class TPAHereExecutor extends AsyncCommandExecutorBase
{ | private Game game = getEssentialCmds().getGame(); |
hsyyid/EssentialCmds | src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/TPAHereExecutor.java | // Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAHereEvent.java
// public class TPAHereEvent extends AbstractEvent implements Cancellable
// {
// private boolean cancelled = false;
//
// private Player sender;
// private Player recipient;
//
// public Player getSender()
// {
// return sender;
// }
//
// public Player getRecipient()
// {
// return recipient;
// }
//
// public boolean isCancelled()
// {
// return cancelled;
// }
//
// public void setCancelled(boolean cancel)
// {
// cancelled = cancel;
// }
//
// public TPAHereEvent(Player sender, Player recipient)
// {
// this.sender = sender;
// this.recipient = recipient;
// }
//
// @Override
// public Cause getCause()
// {
// return Cause.of(NamedCause.source(this.sender));
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
//
// /**
// * The command to execute on an Async scheduler thread.
// *
// * <p>
// * <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
// * calls back on the main thread.
// * </p>
// *
// * @param src The {@link CommandSource}
// * @param args The arguments.
// */
// public abstract void executeAsync(CommandSource src, CommandContext args);
//
// @Override
// public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
// Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
// return CommandResult.success();
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
| import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAHereEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments; | /*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class TPAHereExecutor extends AsyncCommandExecutorBase
{
private Game game = getEssentialCmds().getGame();
@Override
public void executeAsync(CommandSource src, CommandContext ctx)
{
Player recipient = ctx.<Player> getOne("player").get();
if (src instanceof Player)
{
Player player = (Player) src;
if (recipient == player)
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot teleport to yourself!"));
}
else
{
src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Requested for " + recipient.getName() + " to be teleported to you")); | // Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAHereEvent.java
// public class TPAHereEvent extends AbstractEvent implements Cancellable
// {
// private boolean cancelled = false;
//
// private Player sender;
// private Player recipient;
//
// public Player getSender()
// {
// return sender;
// }
//
// public Player getRecipient()
// {
// return recipient;
// }
//
// public boolean isCancelled()
// {
// return cancelled;
// }
//
// public void setCancelled(boolean cancel)
// {
// cancelled = cancel;
// }
//
// public TPAHereEvent(Player sender, Player recipient)
// {
// this.sender = sender;
// this.recipient = recipient;
// }
//
// @Override
// public Cause getCause()
// {
// return Cause.of(NamedCause.source(this.sender));
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
//
// /**
// * The command to execute on an Async scheduler thread.
// *
// * <p>
// * <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
// * calls back on the main thread.
// * </p>
// *
// * @param src The {@link CommandSource}
// * @param args The arguments.
// */
// public abstract void executeAsync(CommandSource src, CommandContext args);
//
// @Override
// public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
// Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
// return CommandResult.success();
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
// Path: src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/TPAHereExecutor.java
import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAHereEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
/*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class TPAHereExecutor extends AsyncCommandExecutorBase
{
private Game game = getEssentialCmds().getGame();
@Override
public void executeAsync(CommandSource src, CommandContext ctx)
{
Player recipient = ctx.<Player> getOne("player").get();
if (src instanceof Player)
{
Player player = (Player) src;
if (recipient == player)
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot teleport to yourself!"));
}
else
{
src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Requested for " + recipient.getName() + " to be teleported to you")); | game.getEventManager().post(new TPAHereEvent(player, recipient)); |
hsyyid/EssentialCmds | src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/SudoExecutor.java | // Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
| import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.internal.CommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandManager;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource; | /*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class SudoExecutor extends CommandExecutorBase
{ | // Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
// Path: src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/SudoExecutor.java
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.internal.CommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandManager;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
/*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class SudoExecutor extends CommandExecutorBase
{ | Game game = getEssentialCmds().getGame(); |
hsyyid/EssentialCmds | src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/TPAExecutor.java | // Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAEvent.java
// public class TPAEvent extends AbstractEvent implements Cancellable
// {
// private boolean cancelled = false;
//
// private Player sender;
// private Player recipient;
//
// public Player getSender()
// {
// return sender;
// }
//
// public Player getRecipient()
// {
// return recipient;
// }
//
// public boolean isCancelled()
// {
// return cancelled;
// }
//
// public void setCancelled(boolean cancel)
// {
// cancelled = cancel;
// }
//
// public TPAEvent(Player sender, Player recipient)
// {
// this.sender = sender;
// this.recipient = recipient;
// }
//
// @Override
// public Cause getCause()
// {
// return Cause.of(NamedCause.source(this.sender));
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
//
// /**
// * The command to execute on an Async scheduler thread.
// *
// * <p>
// * <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
// * calls back on the main thread.
// * </p>
// *
// * @param src The {@link CommandSource}
// * @param args The arguments.
// */
// public abstract void executeAsync(CommandSource src, CommandContext args);
//
// @Override
// public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
// Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
// return CommandResult.success();
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
| import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments; | /*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class TPAExecutor extends AsyncCommandExecutorBase
{ | // Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAEvent.java
// public class TPAEvent extends AbstractEvent implements Cancellable
// {
// private boolean cancelled = false;
//
// private Player sender;
// private Player recipient;
//
// public Player getSender()
// {
// return sender;
// }
//
// public Player getRecipient()
// {
// return recipient;
// }
//
// public boolean isCancelled()
// {
// return cancelled;
// }
//
// public void setCancelled(boolean cancel)
// {
// cancelled = cancel;
// }
//
// public TPAEvent(Player sender, Player recipient)
// {
// this.sender = sender;
// this.recipient = recipient;
// }
//
// @Override
// public Cause getCause()
// {
// return Cause.of(NamedCause.source(this.sender));
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
//
// /**
// * The command to execute on an Async scheduler thread.
// *
// * <p>
// * <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
// * calls back on the main thread.
// * </p>
// *
// * @param src The {@link CommandSource}
// * @param args The arguments.
// */
// public abstract void executeAsync(CommandSource src, CommandContext args);
//
// @Override
// public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
// Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
// return CommandResult.success();
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
// Path: src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/TPAExecutor.java
import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
/*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class TPAExecutor extends AsyncCommandExecutorBase
{ | private Game game = getEssentialCmds().getGame(); |
hsyyid/EssentialCmds | src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/TPAExecutor.java | // Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAEvent.java
// public class TPAEvent extends AbstractEvent implements Cancellable
// {
// private boolean cancelled = false;
//
// private Player sender;
// private Player recipient;
//
// public Player getSender()
// {
// return sender;
// }
//
// public Player getRecipient()
// {
// return recipient;
// }
//
// public boolean isCancelled()
// {
// return cancelled;
// }
//
// public void setCancelled(boolean cancel)
// {
// cancelled = cancel;
// }
//
// public TPAEvent(Player sender, Player recipient)
// {
// this.sender = sender;
// this.recipient = recipient;
// }
//
// @Override
// public Cause getCause()
// {
// return Cause.of(NamedCause.source(this.sender));
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
//
// /**
// * The command to execute on an Async scheduler thread.
// *
// * <p>
// * <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
// * calls back on the main thread.
// * </p>
// *
// * @param src The {@link CommandSource}
// * @param args The arguments.
// */
// public abstract void executeAsync(CommandSource src, CommandContext args);
//
// @Override
// public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
// Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
// return CommandResult.success();
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
| import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments; | /*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class TPAExecutor extends AsyncCommandExecutorBase
{
private Game game = getEssentialCmds().getGame();
@Override
public void executeAsync(CommandSource src, CommandContext ctx)
{
Player recipient = ctx.<Player> getOne("player").get();
if (src instanceof Player)
{
Player player = (Player) src;
if (recipient == player)
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot teleport to yourself!"));
}
else
{
src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Requested to be teleported to " + recipient.getName() + ".")); | // Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAEvent.java
// public class TPAEvent extends AbstractEvent implements Cancellable
// {
// private boolean cancelled = false;
//
// private Player sender;
// private Player recipient;
//
// public Player getSender()
// {
// return sender;
// }
//
// public Player getRecipient()
// {
// return recipient;
// }
//
// public boolean isCancelled()
// {
// return cancelled;
// }
//
// public void setCancelled(boolean cancel)
// {
// cancelled = cancel;
// }
//
// public TPAEvent(Player sender, Player recipient)
// {
// this.sender = sender;
// this.recipient = recipient;
// }
//
// @Override
// public Cause getCause()
// {
// return Cause.of(NamedCause.source(this.sender));
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
//
// /**
// * The command to execute on an Async scheduler thread.
// *
// * <p>
// * <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
// * calls back on the main thread.
// * </p>
// *
// * @param src The {@link CommandSource}
// * @param args The arguments.
// */
// public abstract void executeAsync(CommandSource src, CommandContext args);
//
// @Override
// public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
// Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
// return CommandResult.success();
// }
// }
//
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
// Path: src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/TPAExecutor.java
import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
/*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class TPAExecutor extends AsyncCommandExecutorBase
{
private Game game = getEssentialCmds().getGame();
@Override
public void executeAsync(CommandSource src, CommandContext ctx)
{
Player recipient = ctx.<Player> getOne("player").get();
if (src instanceof Player)
{
Player player = (Player) src;
if (recipient == player)
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot teleport to yourself!"));
}
else
{
src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Requested to be teleported to " + recipient.getName() + ".")); | game.getEventManager().post(new TPAEvent(player, recipient)); |
hsyyid/EssentialCmds | src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/SkullExecutor.java | // Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
| import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.type.SkullTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import java.util.Optional;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.internal.CommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult; | /*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class SkullExecutor extends CommandExecutorBase
{ | // Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// return essentialCmds;
// }
// Path: src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/SkullExecutor.java
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.type.SkullTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import java.util.Optional;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.internal.CommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
/*
* This file is part of EssentialCmds, licensed under the MIT License (MIT).
*
* Copyright (c) 2015 - 2015 HassanS6000
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.github.hsyyid.essentialcmds.cmdexecutors;
public class SkullExecutor extends CommandExecutorBase
{ | private Game game = getEssentialCmds().getGame(); |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/manager/UserManagerImpl.java | // Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/dao/UserDao.java
// public interface UserDao {
//
// public User getUser(String id);
//
// public List<User> getAllUser();
//
// public void addUser(User user);
//
// public boolean delUser(String id);
//
// public boolean updateUser(User user);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/entity/User.java
// @Entity
// @Table(name = "T_USER")
// public class User implements Serializable {
//
// @Id
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid")
// @Column(length = 32)
// private String id;
//
// @Column(length = 32)
// private String userName;
//
// @Column(length = 32)
// private String age;
//
// Date birthday;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getAge() {
// return age;
// }
//
// public void setAge(String age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
//
//
//
// }
| import com.tgb.dao.UserDao;
import com.tgb.entity.User;
import java.util.List;
import com.helpinput.annotation.Parent; | /**
* thanks langgufu for static demo source(http://langgufu.iteye.com/blog/2088355)
*/
package com.tgb.manager;
public class UserManagerImpl implements UserManager {
private UserDao userDao;
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
@Override | // Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/dao/UserDao.java
// public interface UserDao {
//
// public User getUser(String id);
//
// public List<User> getAllUser();
//
// public void addUser(User user);
//
// public boolean delUser(String id);
//
// public boolean updateUser(User user);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/entity/User.java
// @Entity
// @Table(name = "T_USER")
// public class User implements Serializable {
//
// @Id
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid")
// @Column(length = 32)
// private String id;
//
// @Column(length = 32)
// private String userName;
//
// @Column(length = 32)
// private String age;
//
// Date birthday;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getAge() {
// return age;
// }
//
// public void setAge(String age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
//
//
//
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/manager/UserManagerImpl.java
import com.tgb.dao.UserDao;
import com.tgb.entity.User;
import java.util.List;
import com.helpinput.annotation.Parent;
/**
* thanks langgufu for static demo source(http://langgufu.iteye.com/blog/2088355)
*/
package com.tgb.manager;
public class UserManagerImpl implements UserManager {
private UserDao userDao;
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
@Override | public User getUser(String id) { |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/context/refreshers/CommonRefresher.java | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/ScanedType.java
// public enum ScanedType {
// SAME(0), NEW(1), DELETED(2);
//
// private int value;
//
// ScanedType(int value) {
// this.value = value;
// }
//
// public int getValue() {
// return this.value;
// }
//
// }
| import java.util.Map;
import org.springframework.context.ApplicationContext;
import com.helpinput.spring.ScanedType; | package com.script.context.refreshers;
public class CommonRefresher extends com.helpinput.spring.refresher.CommonRefresher{
@Override | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/ScanedType.java
// public enum ScanedType {
// SAME(0), NEW(1), DELETED(2);
//
// private int value;
//
// ScanedType(int value) {
// this.value = value;
// }
//
// public int getValue() {
// return this.value;
// }
//
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/context/refreshers/CommonRefresher.java
import java.util.Map;
import org.springframework.context.ApplicationContext;
import com.helpinput.spring.ScanedType;
package com.script.context.refreshers;
public class CommonRefresher extends com.helpinput.spring.refresher.CommonRefresher{
@Override | public void refresh(ApplicationContext context, Map<Class<?>, ScanedType> refreshedClass) { |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/holder/ContextHolder.java | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/BeanRegistInterceptor.java
// public interface BeanRegistInterceptor {
// BeanDefinition beforeRegist(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf,
// BeanDefinitionBuilder builder);
//
// boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf);
//
// boolean getCondition(Class<?> clz);
//
// }
| import com.helpinput.spring.registinerceptor.BeanRegistInterceptor; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-6
*/
package com.helpinput.holder;
public class ContextHolder {
public static SafeHolder<String> refreshers = new SafeHolder<>();
| // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/BeanRegistInterceptor.java
// public interface BeanRegistInterceptor {
// BeanDefinition beforeRegist(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf,
// BeanDefinitionBuilder builder);
//
// boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf);
//
// boolean getCondition(Class<?> clz);
//
// }
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/holder/ContextHolder.java
import com.helpinput.spring.registinerceptor.BeanRegistInterceptor;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-6
*/
package com.helpinput.holder;
public class ContextHolder {
public static SafeHolder<String> refreshers = new SafeHolder<>();
| public static SafeHolder<BeanRegistInterceptor> beanRegistIntercpterHolder = new SafeHolder<>(); |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/web/UserController.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/entity/User.java
// @Entity
// @Table(name = "T_USER")
// public class User implements Serializable {
//
// @Id
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid")
// @Column(length = 32)
// private String id;
//
// @Column(length = 32)
// private String userName;
//
// @Column(length = 32)
// private String age;
//
// Date birthday;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getAge() {
// return age;
// }
//
// public void setAge(String age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
//
//
//
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/manager/UserManager.java
// public interface UserManager {
//
// public User getUser(String id);
//
// public List<User> getAllUser();
//
// public void addUser(User user);
//
// public boolean delUser(String id);
//
// public boolean updateUser(User user);
// }
| import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.tgb.entity.User;
import com.tgb.manager.UserManager; | /**
* thanks langgufu for static demo source(http://langgufu.iteye.com/blog/2088355)
*/
package com.tgb.web;
@Controller
@RequestMapping("/user")
public class UserController { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/entity/User.java
// @Entity
// @Table(name = "T_USER")
// public class User implements Serializable {
//
// @Id
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid")
// @Column(length = 32)
// private String id;
//
// @Column(length = 32)
// private String userName;
//
// @Column(length = 32)
// private String age;
//
// Date birthday;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getAge() {
// return age;
// }
//
// public void setAge(String age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
//
//
//
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/manager/UserManager.java
// public interface UserManager {
//
// public User getUser(String id);
//
// public List<User> getAllUser();
//
// public void addUser(User user);
//
// public boolean delUser(String id);
//
// public boolean updateUser(User user);
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/web/UserController.java
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.tgb.entity.User;
import com.tgb.manager.UserManager;
/**
* thanks langgufu for static demo source(http://langgufu.iteye.com/blog/2088355)
*/
package com.tgb.web;
@Controller
@RequestMapping("/user")
public class UserController { | static Logger logger = LoggerBase.logger; |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/web/UserController.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/entity/User.java
// @Entity
// @Table(name = "T_USER")
// public class User implements Serializable {
//
// @Id
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid")
// @Column(length = 32)
// private String id;
//
// @Column(length = 32)
// private String userName;
//
// @Column(length = 32)
// private String age;
//
// Date birthday;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getAge() {
// return age;
// }
//
// public void setAge(String age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
//
//
//
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/manager/UserManager.java
// public interface UserManager {
//
// public User getUser(String id);
//
// public List<User> getAllUser();
//
// public void addUser(User user);
//
// public boolean delUser(String id);
//
// public boolean updateUser(User user);
// }
| import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.tgb.entity.User;
import com.tgb.manager.UserManager; | /**
* thanks langgufu for static demo source(http://langgufu.iteye.com/blog/2088355)
*/
package com.tgb.web;
@Controller
@RequestMapping("/user")
public class UserController {
static Logger logger = LoggerBase.logger;
@Resource(name = "userManager") | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/entity/User.java
// @Entity
// @Table(name = "T_USER")
// public class User implements Serializable {
//
// @Id
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid")
// @Column(length = 32)
// private String id;
//
// @Column(length = 32)
// private String userName;
//
// @Column(length = 32)
// private String age;
//
// Date birthday;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getAge() {
// return age;
// }
//
// public void setAge(String age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
//
//
//
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/manager/UserManager.java
// public interface UserManager {
//
// public User getUser(String id);
//
// public List<User> getAllUser();
//
// public void addUser(User user);
//
// public boolean delUser(String id);
//
// public boolean updateUser(User user);
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/web/UserController.java
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.tgb.entity.User;
import com.tgb.manager.UserManager;
/**
* thanks langgufu for static demo source(http://langgufu.iteye.com/blog/2088355)
*/
package com.tgb.web;
@Controller
@RequestMapping("/user")
public class UserController {
static Logger logger = LoggerBase.logger;
@Resource(name = "userManager") | private UserManager userManager; |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/web/UserController.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/entity/User.java
// @Entity
// @Table(name = "T_USER")
// public class User implements Serializable {
//
// @Id
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid")
// @Column(length = 32)
// private String id;
//
// @Column(length = 32)
// private String userName;
//
// @Column(length = 32)
// private String age;
//
// Date birthday;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getAge() {
// return age;
// }
//
// public void setAge(String age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
//
//
//
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/manager/UserManager.java
// public interface UserManager {
//
// public User getUser(String id);
//
// public List<User> getAllUser();
//
// public void addUser(User user);
//
// public boolean delUser(String id);
//
// public boolean updateUser(User user);
// }
| import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.tgb.entity.User;
import com.tgb.manager.UserManager; | /**
* thanks langgufu for static demo source(http://langgufu.iteye.com/blog/2088355)
*/
package com.tgb.web;
@Controller
@RequestMapping("/user")
public class UserController {
static Logger logger = LoggerBase.logger;
@Resource(name = "userManager")
private UserManager userManager;
@RequestMapping("/getAllUser")
public String getAllUser(HttpServletRequest request) {
request.setAttribute("userList", userManager.getAllUser());
return "/index";
}
@RequestMapping("/getUser")
public String getUser(String id, HttpServletRequest request) {
request.setAttribute("user", userManager.getUser(id));
return "/editUser";
}
@RequestMapping("/toAddUser")
public String toAddUser() {
return "/addUser";
}
@RequestMapping("/addUser") | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/entity/User.java
// @Entity
// @Table(name = "T_USER")
// public class User implements Serializable {
//
// @Id
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid")
// @Column(length = 32)
// private String id;
//
// @Column(length = 32)
// private String userName;
//
// @Column(length = 32)
// private String age;
//
// Date birthday;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getAge() {
// return age;
// }
//
// public void setAge(String age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
//
//
//
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/manager/UserManager.java
// public interface UserManager {
//
// public User getUser(String id);
//
// public List<User> getAllUser();
//
// public void addUser(User user);
//
// public boolean delUser(String id);
//
// public boolean updateUser(User user);
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/web/UserController.java
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.tgb.entity.User;
import com.tgb.manager.UserManager;
/**
* thanks langgufu for static demo source(http://langgufu.iteye.com/blog/2088355)
*/
package com.tgb.web;
@Controller
@RequestMapping("/user")
public class UserController {
static Logger logger = LoggerBase.logger;
@Resource(name = "userManager")
private UserManager userManager;
@RequestMapping("/getAllUser")
public String getAllUser(HttpServletRequest request) {
request.setAttribute("userList", userManager.getAllUser());
return "/index";
}
@RequestMapping("/getUser")
public String getUser(String id, HttpServletRequest request) {
request.setAttribute("user", userManager.getUser(id));
return "/editUser";
}
@RequestMapping("/toAddUser")
public String toAddUser() {
return "/addUser";
}
@RequestMapping("/addUser") | public String addUser(User user, HttpServletRequest request) { |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/interceptor/TeacherIntercepptor.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
| import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.helpinput.annotation.Mapping;
import com.helpinput.annotation.MappingExclude;
import com.helpinput.core.LoggerBase; | package com.script.interceptor;
/**
* 动态拦截器
* dyanmic interceptor
*/
@Mapping({ "/teacher/*" })
@MappingExclude("/login")
public class TeacherIntercepptor implements HandlerInterceptor { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/interceptor/TeacherIntercepptor.java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.helpinput.annotation.Mapping;
import com.helpinput.annotation.MappingExclude;
import com.helpinput.core.LoggerBase;
package com.script.interceptor;
/**
* 动态拦截器
* dyanmic interceptor
*/
@Mapping({ "/teacher/*" })
@MappingExclude("/login")
public class TeacherIntercepptor implements HandlerInterceptor { | static Logger logger = LoggerBase.logger; |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/manager/TeacherManagerImpl.java | // Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/dao/TeacherDao.java
// public interface TeacherDao {
//
// public Teacher getTeacher(String id);
//
// public List<Teacher> getAllTeacher();
//
// public void addTeacher(Teacher teacher);
//
// public boolean delTeacher(String id);
//
// public boolean updateTeacher(Teacher teacher);
// }
| import java.util.List;
import javax.annotation.Resource;
import com.helpinput.annotation.Parent;
import com.script.dao.TeacherDao;
import com.script.entity.Teacher; | package com.script.manager;
@Parent("transactionProxy")
public class TeacherManagerImpl implements TeacherManager {
@Resource | // Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/dao/TeacherDao.java
// public interface TeacherDao {
//
// public Teacher getTeacher(String id);
//
// public List<Teacher> getAllTeacher();
//
// public void addTeacher(Teacher teacher);
//
// public boolean delTeacher(String id);
//
// public boolean updateTeacher(Teacher teacher);
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/manager/TeacherManagerImpl.java
import java.util.List;
import javax.annotation.Resource;
import com.helpinput.annotation.Parent;
import com.script.dao.TeacherDao;
import com.script.entity.Teacher;
package com.script.manager;
@Parent("transactionProxy")
public class TeacherManagerImpl implements TeacherManager {
@Resource | private TeacherDao teacherDao; |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/settings/IntervalSetting.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/settings/Options.java
// public class Options {
// public static volatile Long scanInterval = 6000L;
// }
| import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import com.helpinput.core.LoggerBase;
import com.helpinput.settings.Options; | package com.script.settings;
public class IntervalSetting {
static Logger logger = LoggerBase.logger;
//can overide the source monitor interval dynamic
@PostConstruct
public void setInteval() { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/settings/Options.java
// public class Options {
// public static volatile Long scanInterval = 6000L;
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/settings/IntervalSetting.java
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import com.helpinput.core.LoggerBase;
import com.helpinput.settings.Options;
package com.script.settings;
public class IntervalSetting {
static Logger logger = LoggerBase.logger;
//can overide the source monitor interval dynamic
@PostConstruct
public void setInteval() { | Options.scanInterval = 6000L; |
niaoge/spring-dynamic | 1-hi-utils/src/main/java/com/helpinput/maps/ConcurrentCaseInsensitiveHashMap.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
| import java.util.Map;
import org.slf4j.Logger;
import com.helpinput.core.LoggerBase; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-10
*/
package com.helpinput.maps;
public class ConcurrentCaseInsensitiveHashMap<V> extends ConcurrentMap<V> {
private static final long serialVersionUID = 1L; | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/ConcurrentCaseInsensitiveHashMap.java
import java.util.Map;
import org.slf4j.Logger;
import com.helpinput.core.LoggerBase;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-10
*/
package com.helpinput.maps;
public class ConcurrentCaseInsensitiveHashMap<V> extends ConcurrentMap<V> {
private static final long serialVersionUID = 1L; | public static Logger logger=LoggerBase.logger; |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/interceptor/UserIntercepptor.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
| import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.helpinput.annotation.Mapping;
import com.helpinput.annotation.MappingExclude;
import com.helpinput.core.LoggerBase; | package com.tgb.interceptor;
@Mapping({ "/user/*" })
@MappingExclude("/login")
public class UserIntercepptor implements HandlerInterceptor { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/src/com/tgb/interceptor/UserIntercepptor.java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.helpinput.annotation.Mapping;
import com.helpinput.annotation.MappingExclude;
import com.helpinput.core.LoggerBase;
package com.tgb.interceptor;
@Mapping({ "/user/*" })
@MappingExclude("/login")
public class UserIntercepptor implements HandlerInterceptor { | static Logger logger = LoggerBase.logger; |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/propertyeditors/GLClassEditor.java | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/support/ClassLoaderHolder.java
// public class ClassLoaderHolder {
// public static HiGroovyClassLoader gcl = new HiGroovyClassLoader();
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
| import com.helpinput.core.LoggerBase;
import java.beans.PropertyEditorSupport;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import com.helpinput.annotation.TargetType;
import com.helpinput.spring.support.ClassLoaderHolder;
import org.slf4j.Logger; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-6
*/
package com.helpinput.propertyeditors;
@TargetType(Class.class)
public class GLClassEditor extends PropertyEditorSupport { | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/support/ClassLoaderHolder.java
// public class ClassLoaderHolder {
// public static HiGroovyClassLoader gcl = new HiGroovyClassLoader();
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/propertyeditors/GLClassEditor.java
import com.helpinput.core.LoggerBase;
import java.beans.PropertyEditorSupport;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import com.helpinput.annotation.TargetType;
import com.helpinput.spring.support.ClassLoaderHolder;
import org.slf4j.Logger;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-6
*/
package com.helpinput.propertyeditors;
@TargetType(Class.class)
public class GLClassEditor extends PropertyEditorSupport { | static Logger logger = LoggerBase.logger; |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/propertyeditors/GLClassEditor.java | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/support/ClassLoaderHolder.java
// public class ClassLoaderHolder {
// public static HiGroovyClassLoader gcl = new HiGroovyClassLoader();
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
| import com.helpinput.core.LoggerBase;
import java.beans.PropertyEditorSupport;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import com.helpinput.annotation.TargetType;
import com.helpinput.spring.support.ClassLoaderHolder;
import org.slf4j.Logger; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-6
*/
package com.helpinput.propertyeditors;
@TargetType(Class.class)
public class GLClassEditor extends PropertyEditorSupport {
static Logger logger = LoggerBase.logger;
private final ClassLoader classLoader;
public GLClassEditor() {
this(null);
}
public GLClassEditor(ClassLoader classLoader) {
this.classLoader = (classLoader != null ? classLoader : GLClassEditor.class.getClassLoader());
}
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
Class<?> result;
try {
result = ClassUtils.resolveClassName(text.trim(), this.classLoader);
}
catch (IllegalArgumentException e) {
//for sessionFactory annotatedClasses | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/support/ClassLoaderHolder.java
// public class ClassLoaderHolder {
// public static HiGroovyClassLoader gcl = new HiGroovyClassLoader();
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/propertyeditors/GLClassEditor.java
import com.helpinput.core.LoggerBase;
import java.beans.PropertyEditorSupport;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import com.helpinput.annotation.TargetType;
import com.helpinput.spring.support.ClassLoaderHolder;
import org.slf4j.Logger;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-6
*/
package com.helpinput.propertyeditors;
@TargetType(Class.class)
public class GLClassEditor extends PropertyEditorSupport {
static Logger logger = LoggerBase.logger;
private final ClassLoader classLoader;
public GLClassEditor() {
this(null);
}
public GLClassEditor(ClassLoader classLoader) {
this.classLoader = (classLoader != null ? classLoader : GLClassEditor.class.getClassLoader());
}
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
Class<?> result;
try {
result = ClassUtils.resolveClassName(text.trim(), this.classLoader);
}
catch (IllegalArgumentException e) {
//for sessionFactory annotatedClasses | result = ClassUtils.resolveClassName(text.trim(), ClassLoaderHolder.gcl); |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/AbstractBeanRegistInterceptor.java | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/Consts.java
// public static final String application_scope = "application";
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/Consts.java
// public static final String singleton_scope = "singleton";
| import static com.helpinput.spring.Consts.singleton_scope;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import static com.helpinput.spring.Consts.application_scope; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-7
*/
package com.helpinput.spring.registinerceptor;
public abstract class AbstractBeanRegistInterceptor implements BeanRegistInterceptor {
protected String beanNameSuffix = "$$$$";
@Override
public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
if (getCondition(clz)) {
String refBeanName = beanName + beanNameSuffix; | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/Consts.java
// public static final String application_scope = "application";
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/Consts.java
// public static final String singleton_scope = "singleton";
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/AbstractBeanRegistInterceptor.java
import static com.helpinput.spring.Consts.singleton_scope;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import static com.helpinput.spring.Consts.application_scope;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-7
*/
package com.helpinput.spring.registinerceptor;
public abstract class AbstractBeanRegistInterceptor implements BeanRegistInterceptor {
protected String beanNameSuffix = "$$$$";
@Override
public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
if (getCondition(clz)) {
String refBeanName = beanName + beanNameSuffix; | if (application_scope.equals(scope)) |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/AbstractBeanRegistInterceptor.java | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/Consts.java
// public static final String application_scope = "application";
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/Consts.java
// public static final String singleton_scope = "singleton";
| import static com.helpinput.spring.Consts.singleton_scope;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import static com.helpinput.spring.Consts.application_scope; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-7
*/
package com.helpinput.spring.registinerceptor;
public abstract class AbstractBeanRegistInterceptor implements BeanRegistInterceptor {
protected String beanNameSuffix = "$$$$";
@Override
public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
if (getCondition(clz)) {
String refBeanName = beanName + beanNameSuffix;
if (application_scope.equals(scope))
dlbf.destroyScopedBean(refBeanName); | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/Consts.java
// public static final String application_scope = "application";
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/Consts.java
// public static final String singleton_scope = "singleton";
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/AbstractBeanRegistInterceptor.java
import static com.helpinput.spring.Consts.singleton_scope;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import static com.helpinput.spring.Consts.application_scope;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-7-7
*/
package com.helpinput.spring.registinerceptor;
public abstract class AbstractBeanRegistInterceptor implements BeanRegistInterceptor {
protected String beanNameSuffix = "$$$$";
@Override
public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
if (getCondition(clz)) {
String refBeanName = beanName + beanNameSuffix;
if (application_scope.equals(scope))
dlbf.destroyScopedBean(refBeanName); | else if (singleton_scope.equals(scope)) |
niaoge/spring-dynamic | 2-hi-spring-dynamic/override/org/hibernate/annotations/common/util/ReflectHelper.java | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/support/ClassLoaderHolder.java
// public class ClassLoaderHolder {
// public static HiGroovyClassLoader gcl = new HiGroovyClassLoader();
//
// }
| import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.hibernate.annotations.common.AssertionFailure;
import com.helpinput.spring.support.ClassLoaderHolder; | Method hashCode;
try {
hashCode = extractHashCodeMethod( clazz );
}
catch ( NoSuchMethodException nsme ) {
return false; //its an interface so we can't really tell anything...
}
return !OBJECT_HASHCODE.equals( hashCode );
}
/**
* Perform resolution of a class name.
* <p/>
* Here we first check the context classloader, if one, before delegating to
* {@link Class#forName(String, boolean, ClassLoader)} using the caller's classloader
*
* @param name The class name
* @param caller The class from which this call originated (in order to access that class's loader).
* @return The class reference.
* @throws ClassNotFoundException From {@link Class#forName(String, boolean, ClassLoader)}.
*/
public static Class classForName(String name, Class caller) throws ClassNotFoundException {
try {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
if ( contextClassLoader != null ) {
return contextClassLoader.loadClass( name );
}
}
catch ( Throwable ignore ) {
} | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/support/ClassLoaderHolder.java
// public class ClassLoaderHolder {
// public static HiGroovyClassLoader gcl = new HiGroovyClassLoader();
//
// }
// Path: 2-hi-spring-dynamic/override/org/hibernate/annotations/common/util/ReflectHelper.java
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.hibernate.annotations.common.AssertionFailure;
import com.helpinput.spring.support.ClassLoaderHolder;
Method hashCode;
try {
hashCode = extractHashCodeMethod( clazz );
}
catch ( NoSuchMethodException nsme ) {
return false; //its an interface so we can't really tell anything...
}
return !OBJECT_HASHCODE.equals( hashCode );
}
/**
* Perform resolution of a class name.
* <p/>
* Here we first check the context classloader, if one, before delegating to
* {@link Class#forName(String, boolean, ClassLoader)} using the caller's classloader
*
* @param name The class name
* @param caller The class from which this call originated (in order to access that class's loader).
* @return The class reference.
* @throws ClassNotFoundException From {@link Class#forName(String, boolean, ClassLoader)}.
*/
public static Class classForName(String name, Class caller) throws ClassNotFoundException {
try {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
if ( contextClassLoader != null ) {
return contextClassLoader.loadClass( name );
}
}
catch ( Throwable ignore ) {
} | return Class.forName( name, true, ClassLoaderHolder.gcl ); |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/servlet/mvc/EnhanceDispachServlet.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/holder/ContextHolder.java
// public class ContextHolder {
// public static SafeHolder<String> refreshers = new SafeHolder<>();
//
// public static SafeHolder<BeanRegistInterceptor> beanRegistIntercpterHolder = new SafeHolder<>();
//
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/mvc/UrlInterceptorBeanRegistInterceptor.java
// public class UrlInterceptorBeanRegistInterceptor implements BeanRegistInterceptor {
// static Logger logger = LoggerBase.logger;
//
// @Override
// public BeanDefinition beforeRegist(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf,
// BeanDefinitionBuilder builder) {
// if (getCondition(clz)) {
// String refDefname = beanName + "$$$$";
//
// RootBeanDefinition refDef = new RootBeanDefinition();
// refDef.setBeanClass(clz);
// refDef.setScope(scope);
// dlbf.registerBeanDefinition(refDefname, refDef);
//
// RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition(MappedInterceptor.class);
// mappedInterceptorDef.setScope(scope);
//
// ManagedList<String> includePatterns = null;
// ManagedList<String> excludePatterns = null;
// Object interceptorBean;
//
// Mapping mapAnn = clz.getAnnotation(Mapping.class);
// if (mapAnn != null) {
// String[] includes = mapAnn.value();
// if (Utils.hasLength(includes)) {
// includePatterns = new ManagedList<>(includes.length);
// for (String s : includes)
// includePatterns.add(s);
// }
// }
//
// MappingExclude unMapAnn = clz.getAnnotation(MappingExclude.class);
// if (unMapAnn != null) {
// String[] excludes = unMapAnn.value();
// if (Utils.hasLength(excludes)) {
// excludePatterns = new ManagedList<>(excludes.length);
// for (String s : excludes)
// excludePatterns.add(s);
// }
// }
//
// interceptorBean = new RuntimeBeanReference(refDefname);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, includePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, excludePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, interceptorBean);
// return mappedInterceptorDef;
// }
// return null;
// }
//
// @Override
// public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// public boolean getCondition(Class<?> clz) {
// return HandlerInterceptor.class.isAssignableFrom(clz);
// }
//
// }
| import com.helpinput.holder.ContextHolder;
import com.helpinput.spring.registinerceptor.mvc.UrlInterceptorBeanRegistInterceptor;
import org.slf4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import com.helpinput.core.LoggerBase; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-20
*/
package com.helpinput.spring.servlet.mvc;
@SuppressWarnings("serial")
public class EnhanceDispachServlet extends DispatcherServlet { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/holder/ContextHolder.java
// public class ContextHolder {
// public static SafeHolder<String> refreshers = new SafeHolder<>();
//
// public static SafeHolder<BeanRegistInterceptor> beanRegistIntercpterHolder = new SafeHolder<>();
//
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/mvc/UrlInterceptorBeanRegistInterceptor.java
// public class UrlInterceptorBeanRegistInterceptor implements BeanRegistInterceptor {
// static Logger logger = LoggerBase.logger;
//
// @Override
// public BeanDefinition beforeRegist(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf,
// BeanDefinitionBuilder builder) {
// if (getCondition(clz)) {
// String refDefname = beanName + "$$$$";
//
// RootBeanDefinition refDef = new RootBeanDefinition();
// refDef.setBeanClass(clz);
// refDef.setScope(scope);
// dlbf.registerBeanDefinition(refDefname, refDef);
//
// RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition(MappedInterceptor.class);
// mappedInterceptorDef.setScope(scope);
//
// ManagedList<String> includePatterns = null;
// ManagedList<String> excludePatterns = null;
// Object interceptorBean;
//
// Mapping mapAnn = clz.getAnnotation(Mapping.class);
// if (mapAnn != null) {
// String[] includes = mapAnn.value();
// if (Utils.hasLength(includes)) {
// includePatterns = new ManagedList<>(includes.length);
// for (String s : includes)
// includePatterns.add(s);
// }
// }
//
// MappingExclude unMapAnn = clz.getAnnotation(MappingExclude.class);
// if (unMapAnn != null) {
// String[] excludes = unMapAnn.value();
// if (Utils.hasLength(excludes)) {
// excludePatterns = new ManagedList<>(excludes.length);
// for (String s : excludes)
// excludePatterns.add(s);
// }
// }
//
// interceptorBean = new RuntimeBeanReference(refDefname);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, includePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, excludePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, interceptorBean);
// return mappedInterceptorDef;
// }
// return null;
// }
//
// @Override
// public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// public boolean getCondition(Class<?> clz) {
// return HandlerInterceptor.class.isAssignableFrom(clz);
// }
//
// }
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/servlet/mvc/EnhanceDispachServlet.java
import com.helpinput.holder.ContextHolder;
import com.helpinput.spring.registinerceptor.mvc.UrlInterceptorBeanRegistInterceptor;
import org.slf4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import com.helpinput.core.LoggerBase;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-20
*/
package com.helpinput.spring.servlet.mvc;
@SuppressWarnings("serial")
public class EnhanceDispachServlet extends DispatcherServlet { | static Logger logger = LoggerBase.logger; |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/servlet/mvc/EnhanceDispachServlet.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/holder/ContextHolder.java
// public class ContextHolder {
// public static SafeHolder<String> refreshers = new SafeHolder<>();
//
// public static SafeHolder<BeanRegistInterceptor> beanRegistIntercpterHolder = new SafeHolder<>();
//
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/mvc/UrlInterceptorBeanRegistInterceptor.java
// public class UrlInterceptorBeanRegistInterceptor implements BeanRegistInterceptor {
// static Logger logger = LoggerBase.logger;
//
// @Override
// public BeanDefinition beforeRegist(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf,
// BeanDefinitionBuilder builder) {
// if (getCondition(clz)) {
// String refDefname = beanName + "$$$$";
//
// RootBeanDefinition refDef = new RootBeanDefinition();
// refDef.setBeanClass(clz);
// refDef.setScope(scope);
// dlbf.registerBeanDefinition(refDefname, refDef);
//
// RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition(MappedInterceptor.class);
// mappedInterceptorDef.setScope(scope);
//
// ManagedList<String> includePatterns = null;
// ManagedList<String> excludePatterns = null;
// Object interceptorBean;
//
// Mapping mapAnn = clz.getAnnotation(Mapping.class);
// if (mapAnn != null) {
// String[] includes = mapAnn.value();
// if (Utils.hasLength(includes)) {
// includePatterns = new ManagedList<>(includes.length);
// for (String s : includes)
// includePatterns.add(s);
// }
// }
//
// MappingExclude unMapAnn = clz.getAnnotation(MappingExclude.class);
// if (unMapAnn != null) {
// String[] excludes = unMapAnn.value();
// if (Utils.hasLength(excludes)) {
// excludePatterns = new ManagedList<>(excludes.length);
// for (String s : excludes)
// excludePatterns.add(s);
// }
// }
//
// interceptorBean = new RuntimeBeanReference(refDefname);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, includePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, excludePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, interceptorBean);
// return mappedInterceptorDef;
// }
// return null;
// }
//
// @Override
// public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// public boolean getCondition(Class<?> clz) {
// return HandlerInterceptor.class.isAssignableFrom(clz);
// }
//
// }
| import com.helpinput.holder.ContextHolder;
import com.helpinput.spring.registinerceptor.mvc.UrlInterceptorBeanRegistInterceptor;
import org.slf4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import com.helpinput.core.LoggerBase; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-20
*/
package com.helpinput.spring.servlet.mvc;
@SuppressWarnings("serial")
public class EnhanceDispachServlet extends DispatcherServlet {
static Logger logger = LoggerBase.logger;
@Override
protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/holder/ContextHolder.java
// public class ContextHolder {
// public static SafeHolder<String> refreshers = new SafeHolder<>();
//
// public static SafeHolder<BeanRegistInterceptor> beanRegistIntercpterHolder = new SafeHolder<>();
//
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/mvc/UrlInterceptorBeanRegistInterceptor.java
// public class UrlInterceptorBeanRegistInterceptor implements BeanRegistInterceptor {
// static Logger logger = LoggerBase.logger;
//
// @Override
// public BeanDefinition beforeRegist(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf,
// BeanDefinitionBuilder builder) {
// if (getCondition(clz)) {
// String refDefname = beanName + "$$$$";
//
// RootBeanDefinition refDef = new RootBeanDefinition();
// refDef.setBeanClass(clz);
// refDef.setScope(scope);
// dlbf.registerBeanDefinition(refDefname, refDef);
//
// RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition(MappedInterceptor.class);
// mappedInterceptorDef.setScope(scope);
//
// ManagedList<String> includePatterns = null;
// ManagedList<String> excludePatterns = null;
// Object interceptorBean;
//
// Mapping mapAnn = clz.getAnnotation(Mapping.class);
// if (mapAnn != null) {
// String[] includes = mapAnn.value();
// if (Utils.hasLength(includes)) {
// includePatterns = new ManagedList<>(includes.length);
// for (String s : includes)
// includePatterns.add(s);
// }
// }
//
// MappingExclude unMapAnn = clz.getAnnotation(MappingExclude.class);
// if (unMapAnn != null) {
// String[] excludes = unMapAnn.value();
// if (Utils.hasLength(excludes)) {
// excludePatterns = new ManagedList<>(excludes.length);
// for (String s : excludes)
// excludePatterns.add(s);
// }
// }
//
// interceptorBean = new RuntimeBeanReference(refDefname);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, includePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, excludePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, interceptorBean);
// return mappedInterceptorDef;
// }
// return null;
// }
//
// @Override
// public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// public boolean getCondition(Class<?> clz) {
// return HandlerInterceptor.class.isAssignableFrom(clz);
// }
//
// }
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/servlet/mvc/EnhanceDispachServlet.java
import com.helpinput.holder.ContextHolder;
import com.helpinput.spring.registinerceptor.mvc.UrlInterceptorBeanRegistInterceptor;
import org.slf4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import com.helpinput.core.LoggerBase;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-20
*/
package com.helpinput.spring.servlet.mvc;
@SuppressWarnings("serial")
public class EnhanceDispachServlet extends DispatcherServlet {
static Logger logger = LoggerBase.logger;
@Override
protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) { | ContextHolder.beanRegistIntercpterHolder.register(new UrlInterceptorBeanRegistInterceptor()); |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/servlet/mvc/EnhanceDispachServlet.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/holder/ContextHolder.java
// public class ContextHolder {
// public static SafeHolder<String> refreshers = new SafeHolder<>();
//
// public static SafeHolder<BeanRegistInterceptor> beanRegistIntercpterHolder = new SafeHolder<>();
//
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/mvc/UrlInterceptorBeanRegistInterceptor.java
// public class UrlInterceptorBeanRegistInterceptor implements BeanRegistInterceptor {
// static Logger logger = LoggerBase.logger;
//
// @Override
// public BeanDefinition beforeRegist(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf,
// BeanDefinitionBuilder builder) {
// if (getCondition(clz)) {
// String refDefname = beanName + "$$$$";
//
// RootBeanDefinition refDef = new RootBeanDefinition();
// refDef.setBeanClass(clz);
// refDef.setScope(scope);
// dlbf.registerBeanDefinition(refDefname, refDef);
//
// RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition(MappedInterceptor.class);
// mappedInterceptorDef.setScope(scope);
//
// ManagedList<String> includePatterns = null;
// ManagedList<String> excludePatterns = null;
// Object interceptorBean;
//
// Mapping mapAnn = clz.getAnnotation(Mapping.class);
// if (mapAnn != null) {
// String[] includes = mapAnn.value();
// if (Utils.hasLength(includes)) {
// includePatterns = new ManagedList<>(includes.length);
// for (String s : includes)
// includePatterns.add(s);
// }
// }
//
// MappingExclude unMapAnn = clz.getAnnotation(MappingExclude.class);
// if (unMapAnn != null) {
// String[] excludes = unMapAnn.value();
// if (Utils.hasLength(excludes)) {
// excludePatterns = new ManagedList<>(excludes.length);
// for (String s : excludes)
// excludePatterns.add(s);
// }
// }
//
// interceptorBean = new RuntimeBeanReference(refDefname);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, includePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, excludePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, interceptorBean);
// return mappedInterceptorDef;
// }
// return null;
// }
//
// @Override
// public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// public boolean getCondition(Class<?> clz) {
// return HandlerInterceptor.class.isAssignableFrom(clz);
// }
//
// }
| import com.helpinput.holder.ContextHolder;
import com.helpinput.spring.registinerceptor.mvc.UrlInterceptorBeanRegistInterceptor;
import org.slf4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import com.helpinput.core.LoggerBase; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-20
*/
package com.helpinput.spring.servlet.mvc;
@SuppressWarnings("serial")
public class EnhanceDispachServlet extends DispatcherServlet {
static Logger logger = LoggerBase.logger;
@Override
protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/holder/ContextHolder.java
// public class ContextHolder {
// public static SafeHolder<String> refreshers = new SafeHolder<>();
//
// public static SafeHolder<BeanRegistInterceptor> beanRegistIntercpterHolder = new SafeHolder<>();
//
// }
//
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/registinerceptor/mvc/UrlInterceptorBeanRegistInterceptor.java
// public class UrlInterceptorBeanRegistInterceptor implements BeanRegistInterceptor {
// static Logger logger = LoggerBase.logger;
//
// @Override
// public BeanDefinition beforeRegist(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf,
// BeanDefinitionBuilder builder) {
// if (getCondition(clz)) {
// String refDefname = beanName + "$$$$";
//
// RootBeanDefinition refDef = new RootBeanDefinition();
// refDef.setBeanClass(clz);
// refDef.setScope(scope);
// dlbf.registerBeanDefinition(refDefname, refDef);
//
// RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition(MappedInterceptor.class);
// mappedInterceptorDef.setScope(scope);
//
// ManagedList<String> includePatterns = null;
// ManagedList<String> excludePatterns = null;
// Object interceptorBean;
//
// Mapping mapAnn = clz.getAnnotation(Mapping.class);
// if (mapAnn != null) {
// String[] includes = mapAnn.value();
// if (Utils.hasLength(includes)) {
// includePatterns = new ManagedList<>(includes.length);
// for (String s : includes)
// includePatterns.add(s);
// }
// }
//
// MappingExclude unMapAnn = clz.getAnnotation(MappingExclude.class);
// if (unMapAnn != null) {
// String[] excludes = unMapAnn.value();
// if (Utils.hasLength(excludes)) {
// excludePatterns = new ManagedList<>(excludes.length);
// for (String s : excludes)
// excludePatterns.add(s);
// }
// }
//
// interceptorBean = new RuntimeBeanReference(refDefname);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, includePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, excludePatterns);
// mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(2, interceptorBean);
// return mappedInterceptorDef;
// }
// return null;
// }
//
// @Override
// public boolean afterRemove(Class<?> clz, String beanName, String scope, DefaultListableBeanFactory dlbf) {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// public boolean getCondition(Class<?> clz) {
// return HandlerInterceptor.class.isAssignableFrom(clz);
// }
//
// }
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/servlet/mvc/EnhanceDispachServlet.java
import com.helpinput.holder.ContextHolder;
import com.helpinput.spring.registinerceptor.mvc.UrlInterceptorBeanRegistInterceptor;
import org.slf4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import com.helpinput.core.LoggerBase;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-20
*/
package com.helpinput.spring.servlet.mvc;
@SuppressWarnings("serial")
public class EnhanceDispachServlet extends DispatcherServlet {
static Logger logger = LoggerBase.logger;
@Override
protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) { | ContextHolder.beanRegistIntercpterHolder.register(new UrlInterceptorBeanRegistInterceptor()); |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/SourceFileMonitor.java | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/settings/Options.java
// public class Options {
// public static volatile Long scanInterval = 6000L;
// }
| import java.util.concurrent.ThreadFactory;
import org.springframework.context.ApplicationContext;
import com.helpinput.settings.Options;
import java.util.List; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-16
*/
package com.helpinput.spring;
public class SourceFileMonitor implements Runnable {
private SourceScaner scaner;
private Thread thread = null;
private ThreadFactory threadFactory;
private volatile boolean running = false;
public boolean isRunning() {
return running;
}
public SourceFileMonitor( List<String> dirs, ApplicationContext applicationContext) {
scaner = new SourceScaner(dirs, applicationContext);
}
public synchronized void setThreadFactory(ThreadFactory threadFactory) {
this.threadFactory = threadFactory;
}
public synchronized void start() throws Exception {
if (running) {
throw new IllegalStateException("Monitor is already running");
}
running = true;
if (threadFactory != null) {
thread = threadFactory.newThread(this);
}
else {
thread = new Thread(this);
}
thread.start();
}
public synchronized void stop() throws Exception { | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/settings/Options.java
// public class Options {
// public static volatile Long scanInterval = 6000L;
// }
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/SourceFileMonitor.java
import java.util.concurrent.ThreadFactory;
import org.springframework.context.ApplicationContext;
import com.helpinput.settings.Options;
import java.util.List;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-16
*/
package com.helpinput.spring;
public class SourceFileMonitor implements Runnable {
private SourceScaner scaner;
private Thread thread = null;
private ThreadFactory threadFactory;
private volatile boolean running = false;
public boolean isRunning() {
return running;
}
public SourceFileMonitor( List<String> dirs, ApplicationContext applicationContext) {
scaner = new SourceScaner(dirs, applicationContext);
}
public synchronized void setThreadFactory(ThreadFactory threadFactory) {
this.threadFactory = threadFactory;
}
public synchronized void start() throws Exception {
if (running) {
throw new IllegalStateException("Monitor is already running");
}
running = true;
if (threadFactory != null) {
thread = threadFactory.newThread(this);
}
else {
thread = new Thread(this);
}
thread.start();
}
public synchronized void stop() throws Exception { | stop(Options.scanInterval); |
niaoge/spring-dynamic | 1-hi-utils/src/main/java/com/helpinput/core/Utils.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
| import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values; | e.printStackTrace();
}
catch (InvocationTargetException e) {
e.printStackTrace();
}
}
return null;
}
@SuppressWarnings("unchecked")
public static <T> T newInstance(Object caller, String className, Object... args) {
try {
ClassLoader loader = (caller instanceof ClassLoader) ? (ClassLoader) caller : caller.getClass()
.getClassLoader();
return (T) newInstance(loader.loadClass(className), args);
}
catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
/**
* Java文件操作 获取文件扩展名
*
* Created on: 2011-8-2 Author: blueeagle
*/
public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Utils.java
import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values;
e.printStackTrace();
}
catch (InvocationTargetException e) {
e.printStackTrace();
}
}
return null;
}
@SuppressWarnings("unchecked")
public static <T> T newInstance(Object caller, String className, Object... args) {
try {
ClassLoader loader = (caller instanceof ClassLoader) ? (ClassLoader) caller : caller.getClass()
.getClassLoader();
return (T) newInstance(loader.loadClass(className), args);
}
catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
/**
* Java文件操作 获取文件扩展名
*
* Created on: 2011-8-2 Author: blueeagle
*/
public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) { | int dot = filename.lastIndexOf(DOT); |
niaoge/spring-dynamic | 1-hi-utils/src/main/java/com/helpinput/core/Utils.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
| import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values; | * Created on: 2011-8-2 Author: blueeagle
*/
public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf(DOT);
if ((dot > -1) && (dot < (filename.length() - 1))) {
return filename.substring(dot + 1);
}
}
return filename;
}
/**
* Java文件操作 获取不带扩展名的文件名
*
* Created on: 2011-8-2 Author: blueeagle
*/
public static String getFileNameNoEx(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf(DOT);
if ((dot > -1) && (dot < (filename.length()))) {
return filename.substring(0, dot);
}
}
return filename;
}
public static String treeName(String fileName, int node) {
StringBuffer nodeSb = new StringBuffer();
if (node > 0) { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Utils.java
import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values;
* Created on: 2011-8-2 Author: blueeagle
*/
public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf(DOT);
if ((dot > -1) && (dot < (filename.length() - 1))) {
return filename.substring(dot + 1);
}
}
return filename;
}
/**
* Java文件操作 获取不带扩展名的文件名
*
* Created on: 2011-8-2 Author: blueeagle
*/
public static String getFileNameNoEx(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf(DOT);
if ((dot > -1) && (dot < (filename.length()))) {
return filename.substring(0, dot);
}
}
return filename;
}
public static String treeName(String fileName, int node) {
StringBuffer nodeSb = new StringBuffer();
if (node > 0) { | nodeSb.append(NODE_ROOT); |
niaoge/spring-dynamic | 1-hi-utils/src/main/java/com/helpinput/core/Utils.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
| import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values; | public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf(DOT);
if ((dot > -1) && (dot < (filename.length() - 1))) {
return filename.substring(dot + 1);
}
}
return filename;
}
/**
* Java文件操作 获取不带扩展名的文件名
*
* Created on: 2011-8-2 Author: blueeagle
*/
public static String getFileNameNoEx(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf(DOT);
if ((dot > -1) && (dot < (filename.length()))) {
return filename.substring(0, dot);
}
}
return filename;
}
public static String treeName(String fileName, int node) {
StringBuffer nodeSb = new StringBuffer();
if (node > 0) {
nodeSb.append(NODE_ROOT);
for (int i = 0; i < node; i++) { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Utils.java
import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values;
public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf(DOT);
if ((dot > -1) && (dot < (filename.length() - 1))) {
return filename.substring(dot + 1);
}
}
return filename;
}
/**
* Java文件操作 获取不带扩展名的文件名
*
* Created on: 2011-8-2 Author: blueeagle
*/
public static String getFileNameNoEx(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf(DOT);
if ((dot > -1) && (dot < (filename.length()))) {
return filename.substring(0, dot);
}
}
return filename;
}
public static String treeName(String fileName, int node) {
StringBuffer nodeSb = new StringBuffer();
if (node > 0) {
nodeSb.append(NODE_ROOT);
for (int i = 0; i < node; i++) { | nodeSb.append(NODE_LINDE); |
niaoge/spring-dynamic | 1-hi-utils/src/main/java/com/helpinput/core/Utils.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
| import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values; | }
public static Long parseLong(String s, Long min) {
if (hasLength(s)) {
Long value = Long.parseLong(s);
if (min != null)
value = value < min ? min : value;
return value;
}
return min;
}
public static Integer parseInt(String s, Integer min) {
if (hasLength(s)) {
int value = Integer.parseInt(s);
if (min != null)
value = value < min ? min : value;
return value;
}
return min;
}
public static Map<String, Object> map(String[] keys, Object[] values, Map<String, Object> dest) {
if (Utils.hasLength(keys) && Utils.hasLength(values) && (keys.length == values.length)) {
for (int i = 0; i < values.length; i++)
dest.put(keys[i], values[i]);
}
return dest;
}
| // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Utils.java
import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values;
}
public static Long parseLong(String s, Long min) {
if (hasLength(s)) {
Long value = Long.parseLong(s);
if (min != null)
value = value < min ? min : value;
return value;
}
return min;
}
public static Integer parseInt(String s, Integer min) {
if (hasLength(s)) {
int value = Integer.parseInt(s);
if (min != null)
value = value < min ? min : value;
return value;
}
return min;
}
public static Map<String, Object> map(String[] keys, Object[] values, Map<String, Object> dest) {
if (Utils.hasLength(keys) && Utils.hasLength(values) && (keys.length == values.length)) {
for (int i = 0; i < values.length; i++)
dest.put(keys[i], values[i]);
}
return dest;
}
| public static Values createValues() { |
niaoge/spring-dynamic | 1-hi-utils/src/main/java/com/helpinput/core/Utils.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
| import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values; |
public static Long parseLong(String s, Long min) {
if (hasLength(s)) {
Long value = Long.parseLong(s);
if (min != null)
value = value < min ? min : value;
return value;
}
return min;
}
public static Integer parseInt(String s, Integer min) {
if (hasLength(s)) {
int value = Integer.parseInt(s);
if (min != null)
value = value < min ? min : value;
return value;
}
return min;
}
public static Map<String, Object> map(String[] keys, Object[] values, Map<String, Object> dest) {
if (Utils.hasLength(keys) && Utils.hasLength(values) && (keys.length == values.length)) {
for (int i = 0; i < values.length; i++)
dest.put(keys[i], values[i]);
}
return dest;
}
public static Values createValues() { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String DOT = ".";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_LINDE = "━";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Consts.java
// public static final String NODE_ROOT = "┣";
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java
// public class RequestValues extends CaseInsensitiveHashMap<Object> implements Values {
//
// private static final long serialVersionUID = 1L;
//
// /**
// *
// */
// public RequestValues() {
// super();
// }
//
// public RequestValues(int initialCapacity) {
// super(initialCapacity);
// }
//
// @Override
// public Object put(String key, Object value) {
// if (value instanceof Object[]) {
// Object[] values = (Object[]) value;
// if (values.length == 1) {
// return super.put(key, values[0]);
// }
// }
// return super.put(key, value);
// }
//
// @Override
// public Object set(Object key, Object value) {
// return Utils.put(this, key, value);
// }
//
// @Override
// public <T> T got(Object key, Object defaultValue) {
// return Utils.get(this,key, defaultValue);
// }
//
// @Override
// public <T> T got(Object key) {
// return Utils.get(this,key);
// }
//
// }
//
// Path: 1-hi-utils/src/main/java/com/helpinput/maps/Values.java
// public interface Values extends Map<String, Object> {
// <T>T got(Object key,Object defaultValue);
// <T>T got(Object key);
// Object set(Object key,Object value);
//
// }
// Path: 1-hi-utils/src/main/java/com/helpinput/core/Utils.java
import static com.helpinput.core.Consts.DOT;
import static com.helpinput.core.Consts.NODE_LINDE;
import static com.helpinput.core.Consts.NODE_ROOT;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.ConvertUtils;
import com.helpinput.maps.RequestValues;
import com.helpinput.maps.Values;
public static Long parseLong(String s, Long min) {
if (hasLength(s)) {
Long value = Long.parseLong(s);
if (min != null)
value = value < min ? min : value;
return value;
}
return min;
}
public static Integer parseInt(String s, Integer min) {
if (hasLength(s)) {
int value = Integer.parseInt(s);
if (min != null)
value = value < min ? min : value;
return value;
}
return min;
}
public static Map<String, Object> map(String[] keys, Object[] values, Map<String, Object> dest) {
if (Utils.hasLength(keys) && Utils.hasLength(values) && (keys.length == values.length)) {
for (int i = 0; i < values.length; i++)
dest.put(keys[i], values[i]);
}
return dest;
}
public static Values createValues() { | return new RequestValues(); |
niaoge/spring-dynamic | 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/FileReader.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
| import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.Reader;
import static com.helpinput.core.LoggerBase.logger; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-16
*/
package com.helpinput.spring;
class FileReader {
private static void closeWithWarning(Closeable c) {
if (c != null) {
try {
c.close();
} catch (IOException e) { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/FileReader.java
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.Reader;
import static com.helpinput.core.LoggerBase.logger;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-16
*/
package com.helpinput.spring;
class FileReader {
private static void closeWithWarning(Closeable c) {
if (c != null) {
try {
c.close();
} catch (IOException e) { | logger.warn("Caught exception during close(): " + e); |
niaoge/spring-dynamic | 2-hi-spring-dynamic/override/org/hibernate/internal/util/ReflectHelper.java | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/support/ClassLoaderHolder.java
// public class ClassLoaderHolder {
// public static HiGroovyClassLoader gcl = new HiGroovyClassLoader();
//
// }
| import org.hibernate.MappingException;
import org.hibernate.PropertyNotFoundException;
import org.hibernate.property.BasicPropertyAccessor;
import org.hibernate.property.DirectPropertyAccessor;
import org.hibernate.property.Getter;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.type.PrimitiveType;
import org.hibernate.type.Type;
import com.helpinput.spring.support.ClassLoaderHolder;
import java.lang.reflect.Constructor;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.hibernate.AssertionFailure; | */
public static boolean implementsInterface(Class clazz, Class intf) {
assert intf.isInterface() : "Interface to check was not an interface";
return intf.isAssignableFrom( clazz );
}
/**
* Perform resolution of a class name.
* <p/>
* Here we first check the context classloader, if one, before delegating to
* {@link Class#forName(String, boolean, ClassLoader)} using the caller's classloader
*
* @param name The class name
* @param caller The class from which this call originated (in order to access that class's loader).
* @return The class reference.
* @throws ClassNotFoundException From {@link Class#forName(String, boolean, ClassLoader)}.
*/
public static Class classForName(String name, Class caller) throws ClassNotFoundException {
try {
ClassLoader classLoader = ClassLoaderHelper.getContextClassLoader();
if ( classLoader != null ) {
return classLoader.loadClass( name );
}
}
catch ( Throwable ignore ) {
}
try {
return Class.forName( name, true, caller.getClassLoader() );
}
catch (ClassNotFoundException e) { | // Path: 2-hi-spring-dynamic/src/main/java/com/helpinput/spring/support/ClassLoaderHolder.java
// public class ClassLoaderHolder {
// public static HiGroovyClassLoader gcl = new HiGroovyClassLoader();
//
// }
// Path: 2-hi-spring-dynamic/override/org/hibernate/internal/util/ReflectHelper.java
import org.hibernate.MappingException;
import org.hibernate.PropertyNotFoundException;
import org.hibernate.property.BasicPropertyAccessor;
import org.hibernate.property.DirectPropertyAccessor;
import org.hibernate.property.Getter;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.type.PrimitiveType;
import org.hibernate.type.Type;
import com.helpinput.spring.support.ClassLoaderHolder;
import java.lang.reflect.Constructor;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.hibernate.AssertionFailure;
*/
public static boolean implementsInterface(Class clazz, Class intf) {
assert intf.isInterface() : "Interface to check was not an interface";
return intf.isAssignableFrom( clazz );
}
/**
* Perform resolution of a class name.
* <p/>
* Here we first check the context classloader, if one, before delegating to
* {@link Class#forName(String, boolean, ClassLoader)} using the caller's classloader
*
* @param name The class name
* @param caller The class from which this call originated (in order to access that class's loader).
* @return The class reference.
* @throws ClassNotFoundException From {@link Class#forName(String, boolean, ClassLoader)}.
*/
public static Class classForName(String name, Class caller) throws ClassNotFoundException {
try {
ClassLoader classLoader = ClassLoaderHelper.getContextClassLoader();
if ( classLoader != null ) {
return classLoader.loadClass( name );
}
}
catch ( Throwable ignore ) {
}
try {
return Class.forName( name, true, caller.getClassLoader() );
}
catch (ClassNotFoundException e) { | return ClassLoaderHolder.gcl.loadClass(name); |
niaoge/spring-dynamic | 1-hi-utils/src/main/java/com/helpinput/core/PathUtil.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
| import java.util.List;
import org.apache.commons.lang.StringUtils;
import static com.helpinput.core.LoggerBase.logger;
import java.util.ArrayList ; | /*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-10
*/
package com.helpinput.core;
/**
* 类 名: PathUtils 描 述: 对于路径问题处理的工具类 作 者: Vv 创 建: 2012-11-29 版 本:
* 历 史: (版本) 作者 时间 注释
*/
public class PathUtil {
public static final String PATH_OLD_SPLIT = "\\\\";
public static final String PATH_OTHER_SPLIT = "//";
public static final String PATH_SPLIT = "/";
public static final String UPPER_PATH = "..";
public static final String PATH_HTML = "http://";
/**
*
* 描 述:追加目录 作 者:Vv 历 史: (版本) 作者 时间 注释
*
* @param parentPath
* 上级目录 如:D:/AA
* @param subPath
* 子目录 如:BB
* @return 以目录名结尾 如: D:/AA/BB
*/
public static String appendPath(String parentPath, String subPath) {
if (StringUtils.isNotBlank(parentPath) && !parentPath.endsWith(PATH_SPLIT)) {
parentPath += PATH_SPLIT;
}
if (StringUtils.isNotBlank(subPath)) {
parentPath = parentPath + subPath;
}
return processPath(parentPath);
}
/**
*
* 描 述:根据当前路径获取目标路径的相对路径(传入参数为绝对路径) 算法: 1.将路径分割为文件名的数组
* 2.循环当前目录(currentPath)的文件名数组,分别与目标路径(targetPath)的文件数组里的同一位置(索引值i相同)比较
* 2a.如果同一索引值对应的文件夹名相同,则表示存在相对路径,循环继续(continue),直到一索引值对应的文件夹名不相同时,跳出循环
* 2b.如果两个路径的起始部分不一致,则表示不存在相对路径,返回目标路径 3.根据2中循环结束时的索引值,获取相对路径文件名的集合并组成String
* 作 者:Vv 历 史: (版本) 作者 时间 注释
*
* @param currentPath
* @param targetPath
* @return 存在相对路径,则返回相对路径;否则,返回目标路径
* @throws ProcessPathException
*/
public static String getRelativePath(String currentPath, String targetPath) {
if (StringUtils.isBlank(currentPath) || StringUtils.isBlank(targetPath)) { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// Path: 1-hi-utils/src/main/java/com/helpinput/core/PathUtil.java
import java.util.List;
import org.apache.commons.lang.StringUtils;
import static com.helpinput.core.LoggerBase.logger;
import java.util.ArrayList ;
/*
* Copyright 2013-2015 the original author or authors.
*
* 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.
*/
/**
*@Author: niaoge(Zhengsheng Xia)
*@Email 78493244@qq.com
*@Date: 2015-6-10
*/
package com.helpinput.core;
/**
* 类 名: PathUtils 描 述: 对于路径问题处理的工具类 作 者: Vv 创 建: 2012-11-29 版 本:
* 历 史: (版本) 作者 时间 注释
*/
public class PathUtil {
public static final String PATH_OLD_SPLIT = "\\\\";
public static final String PATH_OTHER_SPLIT = "//";
public static final String PATH_SPLIT = "/";
public static final String UPPER_PATH = "..";
public static final String PATH_HTML = "http://";
/**
*
* 描 述:追加目录 作 者:Vv 历 史: (版本) 作者 时间 注释
*
* @param parentPath
* 上级目录 如:D:/AA
* @param subPath
* 子目录 如:BB
* @return 以目录名结尾 如: D:/AA/BB
*/
public static String appendPath(String parentPath, String subPath) {
if (StringUtils.isNotBlank(parentPath) && !parentPath.endsWith(PATH_SPLIT)) {
parentPath += PATH_SPLIT;
}
if (StringUtils.isNotBlank(subPath)) {
parentPath = parentPath + subPath;
}
return processPath(parentPath);
}
/**
*
* 描 述:根据当前路径获取目标路径的相对路径(传入参数为绝对路径) 算法: 1.将路径分割为文件名的数组
* 2.循环当前目录(currentPath)的文件名数组,分别与目标路径(targetPath)的文件数组里的同一位置(索引值i相同)比较
* 2a.如果同一索引值对应的文件夹名相同,则表示存在相对路径,循环继续(continue),直到一索引值对应的文件夹名不相同时,跳出循环
* 2b.如果两个路径的起始部分不一致,则表示不存在相对路径,返回目标路径 3.根据2中循环结束时的索引值,获取相对路径文件名的集合并组成String
* 作 者:Vv 历 史: (版本) 作者 时间 注释
*
* @param currentPath
* @param targetPath
* @return 存在相对路径,则返回相对路径;否则,返回目标路径
* @throws ProcessPathException
*/
public static String getRelativePath(String currentPath, String targetPath) {
if (StringUtils.isBlank(currentPath) || StringUtils.isBlank(targetPath)) { | logger.error("The currentPath or targetPath parameter is required and can't be null or blank."); |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/web/TeacherController.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/manager/TeacherManager.java
// public interface TeacherManager {
//
// public Teacher getTeacher(String id);
//
// public List<Teacher> getAllTeacher();
//
// public void addTeacher(Teacher teacher);
//
// public boolean delTeacher(String id);
//
// public boolean updateTeacher(Teacher teacher);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/propertyEditors/DatePropertyEditor.java
// @Prototype
// @TargetType(Date.class)
// @Properties({ @Property(name = "format", value = "yyyy-MM-dd") })
// // or @Property(name = "format", value = "yyyy-MM-dd") when has 1 setter
// public class DatePropertyEditor extends PropertyEditorSupport {
// static Logger logger = LoggerBase.logger;
//
// private String format = "yyyy-MM-dd";
//
// public void setFormat(String format) {
// this.format = format;
//
// }
//
// public void setAsText(String text) throws IllegalArgumentException {
// if (Utils.hasLength(text) && Utils.hasLength(format)) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// try {
// Date date = sdf.parse(text);
// this.setValue(date);
// return;
// }
// catch (ParseException e) {
// throw new IllegalArgumentException("data format error!");
// }
// }
// setValue(null);
// }
//
// @Override
// public String getAsText() {
// if (Utils.hasLength(format)) {
// Object value = getValue();
// if (value != null) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// return sdf.format((Date) value);
// }
// }
// return "";
// }
//
// }
| import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.script.entity.Teacher;
import com.script.manager.TeacherManager;
import com.script.propertyEditors.DatePropertyEditor; | package com.script.web;
@Controller
@RequestMapping("/teacher")
@Scope("request")
public class TeacherController { | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/manager/TeacherManager.java
// public interface TeacherManager {
//
// public Teacher getTeacher(String id);
//
// public List<Teacher> getAllTeacher();
//
// public void addTeacher(Teacher teacher);
//
// public boolean delTeacher(String id);
//
// public boolean updateTeacher(Teacher teacher);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/propertyEditors/DatePropertyEditor.java
// @Prototype
// @TargetType(Date.class)
// @Properties({ @Property(name = "format", value = "yyyy-MM-dd") })
// // or @Property(name = "format", value = "yyyy-MM-dd") when has 1 setter
// public class DatePropertyEditor extends PropertyEditorSupport {
// static Logger logger = LoggerBase.logger;
//
// private String format = "yyyy-MM-dd";
//
// public void setFormat(String format) {
// this.format = format;
//
// }
//
// public void setAsText(String text) throws IllegalArgumentException {
// if (Utils.hasLength(text) && Utils.hasLength(format)) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// try {
// Date date = sdf.parse(text);
// this.setValue(date);
// return;
// }
// catch (ParseException e) {
// throw new IllegalArgumentException("data format error!");
// }
// }
// setValue(null);
// }
//
// @Override
// public String getAsText() {
// if (Utils.hasLength(format)) {
// Object value = getValue();
// if (value != null) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// return sdf.format((Date) value);
// }
// }
// return "";
// }
//
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/web/TeacherController.java
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.script.entity.Teacher;
import com.script.manager.TeacherManager;
import com.script.propertyEditors.DatePropertyEditor;
package com.script.web;
@Controller
@RequestMapping("/teacher")
@Scope("request")
public class TeacherController { | static Logger logger = LoggerBase.logger; |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/web/TeacherController.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/manager/TeacherManager.java
// public interface TeacherManager {
//
// public Teacher getTeacher(String id);
//
// public List<Teacher> getAllTeacher();
//
// public void addTeacher(Teacher teacher);
//
// public boolean delTeacher(String id);
//
// public boolean updateTeacher(Teacher teacher);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/propertyEditors/DatePropertyEditor.java
// @Prototype
// @TargetType(Date.class)
// @Properties({ @Property(name = "format", value = "yyyy-MM-dd") })
// // or @Property(name = "format", value = "yyyy-MM-dd") when has 1 setter
// public class DatePropertyEditor extends PropertyEditorSupport {
// static Logger logger = LoggerBase.logger;
//
// private String format = "yyyy-MM-dd";
//
// public void setFormat(String format) {
// this.format = format;
//
// }
//
// public void setAsText(String text) throws IllegalArgumentException {
// if (Utils.hasLength(text) && Utils.hasLength(format)) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// try {
// Date date = sdf.parse(text);
// this.setValue(date);
// return;
// }
// catch (ParseException e) {
// throw new IllegalArgumentException("data format error!");
// }
// }
// setValue(null);
// }
//
// @Override
// public String getAsText() {
// if (Utils.hasLength(format)) {
// Object value = getValue();
// if (value != null) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// return sdf.format((Date) value);
// }
// }
// return "";
// }
//
// }
| import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.script.entity.Teacher;
import com.script.manager.TeacherManager;
import com.script.propertyEditors.DatePropertyEditor; | package com.script.web;
@Controller
@RequestMapping("/teacher")
@Scope("request")
public class TeacherController {
static Logger logger = LoggerBase.logger;
@Resource | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/manager/TeacherManager.java
// public interface TeacherManager {
//
// public Teacher getTeacher(String id);
//
// public List<Teacher> getAllTeacher();
//
// public void addTeacher(Teacher teacher);
//
// public boolean delTeacher(String id);
//
// public boolean updateTeacher(Teacher teacher);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/propertyEditors/DatePropertyEditor.java
// @Prototype
// @TargetType(Date.class)
// @Properties({ @Property(name = "format", value = "yyyy-MM-dd") })
// // or @Property(name = "format", value = "yyyy-MM-dd") when has 1 setter
// public class DatePropertyEditor extends PropertyEditorSupport {
// static Logger logger = LoggerBase.logger;
//
// private String format = "yyyy-MM-dd";
//
// public void setFormat(String format) {
// this.format = format;
//
// }
//
// public void setAsText(String text) throws IllegalArgumentException {
// if (Utils.hasLength(text) && Utils.hasLength(format)) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// try {
// Date date = sdf.parse(text);
// this.setValue(date);
// return;
// }
// catch (ParseException e) {
// throw new IllegalArgumentException("data format error!");
// }
// }
// setValue(null);
// }
//
// @Override
// public String getAsText() {
// if (Utils.hasLength(format)) {
// Object value = getValue();
// if (value != null) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// return sdf.format((Date) value);
// }
// }
// return "";
// }
//
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/web/TeacherController.java
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.script.entity.Teacher;
import com.script.manager.TeacherManager;
import com.script.propertyEditors.DatePropertyEditor;
package com.script.web;
@Controller
@RequestMapping("/teacher")
@Scope("request")
public class TeacherController {
static Logger logger = LoggerBase.logger;
@Resource | TeacherManager teacherManager; |
niaoge/spring-dynamic | 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/web/TeacherController.java | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/manager/TeacherManager.java
// public interface TeacherManager {
//
// public Teacher getTeacher(String id);
//
// public List<Teacher> getAllTeacher();
//
// public void addTeacher(Teacher teacher);
//
// public boolean delTeacher(String id);
//
// public boolean updateTeacher(Teacher teacher);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/propertyEditors/DatePropertyEditor.java
// @Prototype
// @TargetType(Date.class)
// @Properties({ @Property(name = "format", value = "yyyy-MM-dd") })
// // or @Property(name = "format", value = "yyyy-MM-dd") when has 1 setter
// public class DatePropertyEditor extends PropertyEditorSupport {
// static Logger logger = LoggerBase.logger;
//
// private String format = "yyyy-MM-dd";
//
// public void setFormat(String format) {
// this.format = format;
//
// }
//
// public void setAsText(String text) throws IllegalArgumentException {
// if (Utils.hasLength(text) && Utils.hasLength(format)) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// try {
// Date date = sdf.parse(text);
// this.setValue(date);
// return;
// }
// catch (ParseException e) {
// throw new IllegalArgumentException("data format error!");
// }
// }
// setValue(null);
// }
//
// @Override
// public String getAsText() {
// if (Utils.hasLength(format)) {
// Object value = getValue();
// if (value != null) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// return sdf.format((Date) value);
// }
// }
// return "";
// }
//
// }
| import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.script.entity.Teacher;
import com.script.manager.TeacherManager;
import com.script.propertyEditors.DatePropertyEditor; |
response.setContentType("application/json");
try {
PrintWriter out = response.getWriter();
out.write(result);
}
catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping("/updateTeacher")
public String updateTeacher(Teacher teacher, HttpServletRequest request) {
if (teacherManager.updateTeacher(teacher)) {
teacher = teacherManager.getTeacher(teacher.getId());
request.setAttribute("teacher", teacher);
return "redirect:/teacher/getAllTeacher";
}
else {
return "/error";
}
}
@InitBinder
protected void initBinder(WebDataBinder binder) throws ServletException {
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// dateFormat.setLenient(false);
// binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); | // Path: 1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java
// public class LoggerBase {
// public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/manager/TeacherManager.java
// public interface TeacherManager {
//
// public Teacher getTeacher(String id);
//
// public List<Teacher> getAllTeacher();
//
// public void addTeacher(Teacher teacher);
//
// public boolean delTeacher(String id);
//
// public boolean updateTeacher(Teacher teacher);
// }
//
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/propertyEditors/DatePropertyEditor.java
// @Prototype
// @TargetType(Date.class)
// @Properties({ @Property(name = "format", value = "yyyy-MM-dd") })
// // or @Property(name = "format", value = "yyyy-MM-dd") when has 1 setter
// public class DatePropertyEditor extends PropertyEditorSupport {
// static Logger logger = LoggerBase.logger;
//
// private String format = "yyyy-MM-dd";
//
// public void setFormat(String format) {
// this.format = format;
//
// }
//
// public void setAsText(String text) throws IllegalArgumentException {
// if (Utils.hasLength(text) && Utils.hasLength(format)) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// try {
// Date date = sdf.parse(text);
// this.setValue(date);
// return;
// }
// catch (ParseException e) {
// throw new IllegalArgumentException("data format error!");
// }
// }
// setValue(null);
// }
//
// @Override
// public String getAsText() {
// if (Utils.hasLength(format)) {
// Object value = getValue();
// if (value != null) {
// SimpleDateFormat sdf = new SimpleDateFormat(format);
// return sdf.format((Date) value);
// }
// }
// return "";
// }
//
// }
// Path: 3-hi-spring-Dynamic-mvc-demo/WebRoot/WEB-INF/script/com/script/web/TeacherController.java
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import com.helpinput.core.LoggerBase;
import com.script.entity.Teacher;
import com.script.manager.TeacherManager;
import com.script.propertyEditors.DatePropertyEditor;
response.setContentType("application/json");
try {
PrintWriter out = response.getWriter();
out.write(result);
}
catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping("/updateTeacher")
public String updateTeacher(Teacher teacher, HttpServletRequest request) {
if (teacherManager.updateTeacher(teacher)) {
teacher = teacherManager.getTeacher(teacher.getId());
request.setAttribute("teacher", teacher);
return "redirect:/teacher/getAllTeacher";
}
else {
return "/error";
}
}
@InitBinder
protected void initBinder(WebDataBinder binder) throws ServletException {
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// dateFormat.setLenient(false);
// binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); | binder.registerCustomEditor(Date.class, new DatePropertyEditor()); |
remijouannet/get10 | app/src/main/java/com/remijouannet/get10/graphic2D/shape/Shape.java | // Path: app/src/main/java/com/remijouannet/get10/graphic2D/helper/BufferHelper.java
// public class BufferHelper {
// private final String TAG = BufferHelper.class.getSimpleName();
// public FloatBuffer verticesBuffer;
// public FloatBuffer uvsBuffer;
// public ShortBuffer indicesBuffer;
//
// public BufferHelper(short[] shortArray, float[] floatArray0, float[] floatArray1){
// indicesBuffer = ShortArray_ToBuffer(shortArray, indicesBuffer);
// verticesBuffer = FloatArrayToBuffer(floatArray0, verticesBuffer);
// uvsBuffer = FloatArrayToBuffer(floatArray1, uvsBuffer);
// }
//
// public BufferHelper(short[] shortArray, float[] floatArray0){
// indicesBuffer = ShortArray_ToBuffer(shortArray, indicesBuffer);
// verticesBuffer = FloatArrayToBuffer(floatArray0, verticesBuffer);
// }
//
// public void setVertices(float[] array){
// verticesBuffer.clear();
// verticesBuffer.put(array);
// verticesBuffer.flip();
// }
//
// public void setUvs(float[] array){
// uvsBuffer.clear();
// uvsBuffer.put(array);
// uvsBuffer.flip();
// }
//
// public void setIndices(short[] array){
// indicesBuffer.clear();
// indicesBuffer.put(array);
// indicesBuffer.flip();
// }
//
// public FloatBuffer FloatArrayToBuffer(float[] array, FloatBuffer floatBuffer){
// ByteBuffer bb1 = ByteBuffer.allocateDirect(array.length * 4);
// bb1.order(ByteOrder.nativeOrder());
// floatBuffer = bb1.asFloatBuffer();
// floatBuffer.put(array);
// floatBuffer.position(0);
// return floatBuffer;
// }
//
// public ShortBuffer ShortArray_ToBuffer(short[] array, ShortBuffer shortBuffer){
// ByteBuffer bb2 = ByteBuffer.allocateDirect(array.length * 2);
// bb2.order(ByteOrder.nativeOrder());
// shortBuffer = bb2.asShortBuffer();
// shortBuffer.put(array);
// shortBuffer.position(0);
// return shortBuffer;
// }
//
// public void clear(){
// uvsBuffer.clear();
// verticesBuffer.clear();
// indicesBuffer.clear();
// }
// }
| import com.remijouannet.get10.graphic2D.helper.BufferHelper; | return triangle.color;
} else if (rect.exist) {
return rect.color;
} else if (circle.exist) {
return circle.color;
} else if (square.exist) {
return square.color;
}else if (customPolygon.exist) {
return customPolygon.color;
} else {
return null;
}
}
public int drawingType() {
if (triangle.exist) {
return triangle.drawingType;
} else if (rect.exist) {
return rect.drawingType;
} else if (circle.exist) {
return circle.drawingType;
} else if (square.exist) {
return square.drawingType;
}else if (customPolygon.exist) {
return customPolygon.drawingType;
} else {
return 0;
}
}
| // Path: app/src/main/java/com/remijouannet/get10/graphic2D/helper/BufferHelper.java
// public class BufferHelper {
// private final String TAG = BufferHelper.class.getSimpleName();
// public FloatBuffer verticesBuffer;
// public FloatBuffer uvsBuffer;
// public ShortBuffer indicesBuffer;
//
// public BufferHelper(short[] shortArray, float[] floatArray0, float[] floatArray1){
// indicesBuffer = ShortArray_ToBuffer(shortArray, indicesBuffer);
// verticesBuffer = FloatArrayToBuffer(floatArray0, verticesBuffer);
// uvsBuffer = FloatArrayToBuffer(floatArray1, uvsBuffer);
// }
//
// public BufferHelper(short[] shortArray, float[] floatArray0){
// indicesBuffer = ShortArray_ToBuffer(shortArray, indicesBuffer);
// verticesBuffer = FloatArrayToBuffer(floatArray0, verticesBuffer);
// }
//
// public void setVertices(float[] array){
// verticesBuffer.clear();
// verticesBuffer.put(array);
// verticesBuffer.flip();
// }
//
// public void setUvs(float[] array){
// uvsBuffer.clear();
// uvsBuffer.put(array);
// uvsBuffer.flip();
// }
//
// public void setIndices(short[] array){
// indicesBuffer.clear();
// indicesBuffer.put(array);
// indicesBuffer.flip();
// }
//
// public FloatBuffer FloatArrayToBuffer(float[] array, FloatBuffer floatBuffer){
// ByteBuffer bb1 = ByteBuffer.allocateDirect(array.length * 4);
// bb1.order(ByteOrder.nativeOrder());
// floatBuffer = bb1.asFloatBuffer();
// floatBuffer.put(array);
// floatBuffer.position(0);
// return floatBuffer;
// }
//
// public ShortBuffer ShortArray_ToBuffer(short[] array, ShortBuffer shortBuffer){
// ByteBuffer bb2 = ByteBuffer.allocateDirect(array.length * 2);
// bb2.order(ByteOrder.nativeOrder());
// shortBuffer = bb2.asShortBuffer();
// shortBuffer.put(array);
// shortBuffer.position(0);
// return shortBuffer;
// }
//
// public void clear(){
// uvsBuffer.clear();
// verticesBuffer.clear();
// indicesBuffer.clear();
// }
// }
// Path: app/src/main/java/com/remijouannet/get10/graphic2D/shape/Shape.java
import com.remijouannet.get10.graphic2D.helper.BufferHelper;
return triangle.color;
} else if (rect.exist) {
return rect.color;
} else if (circle.exist) {
return circle.color;
} else if (square.exist) {
return square.color;
}else if (customPolygon.exist) {
return customPolygon.color;
} else {
return null;
}
}
public int drawingType() {
if (triangle.exist) {
return triangle.drawingType;
} else if (rect.exist) {
return rect.drawingType;
} else if (circle.exist) {
return circle.drawingType;
} else if (square.exist) {
return square.drawingType;
}else if (customPolygon.exist) {
return customPolygon.drawingType;
} else {
return 0;
}
}
| public BufferHelper getBuffer() { |
remijouannet/get10 | app/src/main/java/com/remijouannet/get10/graphic2D/texture/Texture.java | // Path: app/src/main/java/com/remijouannet/get10/graphic2D/Tools.java
// public class Tools {
// private static String TAG = Tools.class.getSimpleName();
// private static Random rand = new Random();
// private static double degrees;
//
//
// public static float getAngle(float p1X, float p1Y, float p2X, float p2Y) {
// degrees = Math.toDegrees((Math.atan2(p1X - p2X, p1Y - p2Y)));
// degrees = ((degrees < 0) ? -(degrees - 180) : degrees) + 90;
// return (float) ((degrees > 360) ? degrees -= 360 : degrees);
// }
//
// public static float getDistance(float p1X, float p1Y, float p2X, float p2Y) {
// return (float) Math.sqrt((p2X - p1X) * (p2X - p1X) + (p2Y - p1Y) * (p2Y - p1Y));
// }
//
// public static float getRandFloat(float min, float max) {
// return min + rand.nextFloat() * (max - min);
// }
//
// public static int getRandInt(int min, int max) {
// return rand.nextInt((max - min) + 1) + min;
// }
//
// public static void sleep(long time) {
// try {
// Thread.sleep(time);
// } catch (Exception e) {
// e.getMessage();
// }
// }
//
// public static int ptToPixel(int pt, DisplayMetrics metrics){
// return (int) ( (pt * metrics.densityDpi) / 72 );
// }
//
// public static int dpToPixel(int dp, DisplayMetrics metrics){
// return (int) ( dp * (metrics.densityDpi / 160.0f) );
// }
// public static int getIntFromColor(float[] color) {
// return 0xFF000000 | ((Math.round(255 * color[0]) << 16) & 0x00FF0000)
// | ((Math.round(255 * color[1]) << 8) & 0x0000FF00)
// | (Math.round(255 * color[2]) & 0x000000FF);
// }
//
// public static int fps(int fps) {
// return (1000 / fps);
// }
//
// public static String convertStreamToString(InputStream is) throws Exception {
// BufferedReader reader = new BufferedReader(new InputStreamReader(is));
// StringBuilder sb = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// sb.append(line).append("\n");
// }
// reader.close();
// return sb.toString();
// }
//
// public static float[] randomColor(){
// switch (Tools.getRandInt(0, 10)){
// case 0:
// return new float[]{52.0f/255.0f, 152.0f/255.0f, 219.0f/255.0f,1.0f};
// case 1:
// return new float[]{39.0f/255.0f, 174.0f/255.0f, 96.0f/255.0f,1.0f};
// case 2:
// return new float[]{155.0f/255.0f, 89/255.0f, 182/255.0f,1.0f};
// case 3:
// return new float[]{52.0f/255.0f, 73/255.0f, 94/255.0f,1.0f};
// case 4:
// return new float[]{241/255.0f, 196/255.0f, 15/255.0f,1.0f};
// case 5:
// return new float[]{231/255.0f, 76/255.0f, 60/255.0f,1.0f};
// case 6:
// return new float[]{230/255.0f, 126/255.0f, 34/255.0f,1.0f};
// case 7:
// return new float[]{26/255.0f, 188/255.0f, 156/255.0f,1.0f};
// case 8:
// return new float[]{155/255.0f, 89/255.0f, 182/255.0f,1.0f};
// case 9:
// return new float[]{135/255.0f, 211/255.0f, 124/255.0f,1.0f};
// case 10:
// return new float[]{211/255.0f, 84/255.0f, 0/255.0f,1.0f};
// default:
// return new float[]{100.0f / 255.0f, 128.0f / 255.0f, 185.0f / 255.0f, 1.0f};
// }
// }
//
//
// }
| import com.remijouannet.get10.graphic2D.Tools; | public int getGLTex(){
return GLTex;
}
public int getWidth(){
return width;
}
public int getHeight(){
return height;
}
public void getUvs(float[] uvs){
this.uvs = uvs;
}
public void setGLTex(int GLTex){
this.GLTex = GLTex;
}
public void setWidth(int width){
this.width = width;
}
public void setHeight(int height){
this.height = height;
}
public float[] getUvsCircle(){
if (uvsCircle == null){ | // Path: app/src/main/java/com/remijouannet/get10/graphic2D/Tools.java
// public class Tools {
// private static String TAG = Tools.class.getSimpleName();
// private static Random rand = new Random();
// private static double degrees;
//
//
// public static float getAngle(float p1X, float p1Y, float p2X, float p2Y) {
// degrees = Math.toDegrees((Math.atan2(p1X - p2X, p1Y - p2Y)));
// degrees = ((degrees < 0) ? -(degrees - 180) : degrees) + 90;
// return (float) ((degrees > 360) ? degrees -= 360 : degrees);
// }
//
// public static float getDistance(float p1X, float p1Y, float p2X, float p2Y) {
// return (float) Math.sqrt((p2X - p1X) * (p2X - p1X) + (p2Y - p1Y) * (p2Y - p1Y));
// }
//
// public static float getRandFloat(float min, float max) {
// return min + rand.nextFloat() * (max - min);
// }
//
// public static int getRandInt(int min, int max) {
// return rand.nextInt((max - min) + 1) + min;
// }
//
// public static void sleep(long time) {
// try {
// Thread.sleep(time);
// } catch (Exception e) {
// e.getMessage();
// }
// }
//
// public static int ptToPixel(int pt, DisplayMetrics metrics){
// return (int) ( (pt * metrics.densityDpi) / 72 );
// }
//
// public static int dpToPixel(int dp, DisplayMetrics metrics){
// return (int) ( dp * (metrics.densityDpi / 160.0f) );
// }
// public static int getIntFromColor(float[] color) {
// return 0xFF000000 | ((Math.round(255 * color[0]) << 16) & 0x00FF0000)
// | ((Math.round(255 * color[1]) << 8) & 0x0000FF00)
// | (Math.round(255 * color[2]) & 0x000000FF);
// }
//
// public static int fps(int fps) {
// return (1000 / fps);
// }
//
// public static String convertStreamToString(InputStream is) throws Exception {
// BufferedReader reader = new BufferedReader(new InputStreamReader(is));
// StringBuilder sb = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// sb.append(line).append("\n");
// }
// reader.close();
// return sb.toString();
// }
//
// public static float[] randomColor(){
// switch (Tools.getRandInt(0, 10)){
// case 0:
// return new float[]{52.0f/255.0f, 152.0f/255.0f, 219.0f/255.0f,1.0f};
// case 1:
// return new float[]{39.0f/255.0f, 174.0f/255.0f, 96.0f/255.0f,1.0f};
// case 2:
// return new float[]{155.0f/255.0f, 89/255.0f, 182/255.0f,1.0f};
// case 3:
// return new float[]{52.0f/255.0f, 73/255.0f, 94/255.0f,1.0f};
// case 4:
// return new float[]{241/255.0f, 196/255.0f, 15/255.0f,1.0f};
// case 5:
// return new float[]{231/255.0f, 76/255.0f, 60/255.0f,1.0f};
// case 6:
// return new float[]{230/255.0f, 126/255.0f, 34/255.0f,1.0f};
// case 7:
// return new float[]{26/255.0f, 188/255.0f, 156/255.0f,1.0f};
// case 8:
// return new float[]{155/255.0f, 89/255.0f, 182/255.0f,1.0f};
// case 9:
// return new float[]{135/255.0f, 211/255.0f, 124/255.0f,1.0f};
// case 10:
// return new float[]{211/255.0f, 84/255.0f, 0/255.0f,1.0f};
// default:
// return new float[]{100.0f / 255.0f, 128.0f / 255.0f, 185.0f / 255.0f, 1.0f};
// }
// }
//
//
// }
// Path: app/src/main/java/com/remijouannet/get10/graphic2D/texture/Texture.java
import com.remijouannet.get10.graphic2D.Tools;
public int getGLTex(){
return GLTex;
}
public int getWidth(){
return width;
}
public int getHeight(){
return height;
}
public void getUvs(float[] uvs){
this.uvs = uvs;
}
public void setGLTex(int GLTex){
this.GLTex = GLTex;
}
public void setWidth(int width){
this.width = width;
}
public void setHeight(int height){
this.height = height;
}
public float[] getUvsCircle(){
if (uvsCircle == null){ | this.uvHeight = Tools.getDistance(uvs[0] * this.getWidth(), uvs[1] * this.getHeight(), |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-hello-world/src/test/java/moe/tristan/easyfxml/samples/helloworld/HelloWorldContextTest.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxml.java
// public interface EasyFxml {
//
// /**
// * Loads a {@link FxmlComponent} as a Pane (this is the safest base class for all sorts of hierarchies) since most of the base containers are subclasses of
// * it.
// * <p>
// * It also registers its controller in the {@link ControllerManager} for later usage.
// * <p>
// * It returns a {@link Try} which is a monadic structure which allows us to do clean exception-handling.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// *
// * @return A {@link Try} containing either the JavaFX {@link Pane} inside a {@link Try.Success} or the exception that was raised during the chain of calls
// * needed to load it, inside a {@link Try.Failure}. See {@link Try#getOrElse(Object)}, {@link Try#onFailure(Consumer)}, {@link Try#recover(Function)} and
// * related methods for how to handle {@link Try.Failure}.
// */
// FxmlLoadResult<Pane, FxmlController> load(final FxmlComponent component);
//
// /**
// * Same as {@link #load(FxmlComponent)} but offers a selector parameter for multistage usage of {@link ControllerManager}.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param selector The selector for deduplication of Panes sharing the same {@link FxmlComponent}.
// *
// * @return A Try of the {@link Pane} to be loaded. See {@link #load(FxmlComponent)} for more information on {@link Try}.
// */
// FxmlLoadResult<Pane, FxmlController> load(final FxmlComponent component, final Selector selector);
//
// /**
// * Same as {@link #load(FxmlComponent)} except you can choose the return type wished for instead of just {@link Pane}.
// * <p>
// * It's a bad idea but it can sometimes be actually useful on the rare case where the element is really nothing like a Pane. Be it a very complex button or
// * a custom textfield with non-rectangular shape.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param nodeClass The class of the JavaFX {@link Node} represented by this {@link FxmlComponent}.
// * @param controllerClass The class of the {@link FxmlController} managing this {@link FxmlComponent}.
// * @param <NODE> The type of the node. Mostly for type safety.
// * @param <CONTROLLER> The type of the controller. Mostly for type safety.
// *
// * @return A {@link FxmlLoadResult} containing two {@link Try} instances. One for the node itself and one for its controller. This allows for granular load
// * error management.
// */
// <NODE extends Node, CONTROLLER extends FxmlController>
// FxmlLoadResult<NODE, CONTROLLER>
// load(
// final FxmlComponent component,
// final Class<? extends NODE> nodeClass,
// final Class<? extends CONTROLLER> controllerClass
// );
//
// /**
// * This is to {@link #load(FxmlComponent, Class, Class)} just what {@link #load(FxmlComponent, Selector)} is to {@link #load(FxmlComponent)}.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param nodeClass The class of the JavaFX {@link Node} represented by this {@link FxmlComponent}.
// * @param controllerClass The class of the {@link FxmlController} managing this {@link FxmlComponent}.
// * @param selector The selector for deduplication of Panes sharing the same {@link FxmlComponent}.
// * @param <NODE> The type of the node. Mostly for type safety.
// * @param <CONTROLLER> The type of the controller. Mostly for type safety.
// *
// * @return A {@link FxmlLoadResult} containing two {@link Try} instances.
// *
// * One for the node itself and one for its controller. This allows for granular load error management.
// */
// <NODE extends Node, CONTROLLER extends FxmlController>
// FxmlLoadResult<NODE, CONTROLLER>
// load(
// final FxmlComponent component,
// final Class<? extends NODE> nodeClass,
// final Class<? extends CONTROLLER> controllerClass,
// final Selector selector
// );
//
// }
| import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import moe.tristan.easyfxml.EasyFxml; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.helloworld;
@SpringBootTest
public class HelloWorldContextTest {
@Autowired | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxml.java
// public interface EasyFxml {
//
// /**
// * Loads a {@link FxmlComponent} as a Pane (this is the safest base class for all sorts of hierarchies) since most of the base containers are subclasses of
// * it.
// * <p>
// * It also registers its controller in the {@link ControllerManager} for later usage.
// * <p>
// * It returns a {@link Try} which is a monadic structure which allows us to do clean exception-handling.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// *
// * @return A {@link Try} containing either the JavaFX {@link Pane} inside a {@link Try.Success} or the exception that was raised during the chain of calls
// * needed to load it, inside a {@link Try.Failure}. See {@link Try#getOrElse(Object)}, {@link Try#onFailure(Consumer)}, {@link Try#recover(Function)} and
// * related methods for how to handle {@link Try.Failure}.
// */
// FxmlLoadResult<Pane, FxmlController> load(final FxmlComponent component);
//
// /**
// * Same as {@link #load(FxmlComponent)} but offers a selector parameter for multistage usage of {@link ControllerManager}.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param selector The selector for deduplication of Panes sharing the same {@link FxmlComponent}.
// *
// * @return A Try of the {@link Pane} to be loaded. See {@link #load(FxmlComponent)} for more information on {@link Try}.
// */
// FxmlLoadResult<Pane, FxmlController> load(final FxmlComponent component, final Selector selector);
//
// /**
// * Same as {@link #load(FxmlComponent)} except you can choose the return type wished for instead of just {@link Pane}.
// * <p>
// * It's a bad idea but it can sometimes be actually useful on the rare case where the element is really nothing like a Pane. Be it a very complex button or
// * a custom textfield with non-rectangular shape.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param nodeClass The class of the JavaFX {@link Node} represented by this {@link FxmlComponent}.
// * @param controllerClass The class of the {@link FxmlController} managing this {@link FxmlComponent}.
// * @param <NODE> The type of the node. Mostly for type safety.
// * @param <CONTROLLER> The type of the controller. Mostly for type safety.
// *
// * @return A {@link FxmlLoadResult} containing two {@link Try} instances. One for the node itself and one for its controller. This allows for granular load
// * error management.
// */
// <NODE extends Node, CONTROLLER extends FxmlController>
// FxmlLoadResult<NODE, CONTROLLER>
// load(
// final FxmlComponent component,
// final Class<? extends NODE> nodeClass,
// final Class<? extends CONTROLLER> controllerClass
// );
//
// /**
// * This is to {@link #load(FxmlComponent, Class, Class)} just what {@link #load(FxmlComponent, Selector)} is to {@link #load(FxmlComponent)}.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param nodeClass The class of the JavaFX {@link Node} represented by this {@link FxmlComponent}.
// * @param controllerClass The class of the {@link FxmlController} managing this {@link FxmlComponent}.
// * @param selector The selector for deduplication of Panes sharing the same {@link FxmlComponent}.
// * @param <NODE> The type of the node. Mostly for type safety.
// * @param <CONTROLLER> The type of the controller. Mostly for type safety.
// *
// * @return A {@link FxmlLoadResult} containing two {@link Try} instances.
// *
// * One for the node itself and one for its controller. This allows for granular load error management.
// */
// <NODE extends Node, CONTROLLER extends FxmlController>
// FxmlLoadResult<NODE, CONTROLLER>
// load(
// final FxmlComponent component,
// final Class<? extends NODE> nodeClass,
// final Class<? extends CONTROLLER> controllerClass,
// final Selector selector
// );
//
// }
// Path: easyfxml-samples/easyfxml-sample-hello-world/src/test/java/moe/tristan/easyfxml/samples/helloworld/HelloWorldContextTest.java
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import moe.tristan.easyfxml.EasyFxml;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.helloworld;
@SpringBootTest
public class HelloWorldContextTest {
@Autowired | private EasyFxml easyFxml; |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/UserFormUiManager.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/FxUiManager.java
// public abstract class FxUiManager {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FxUiManager.class);
//
// private EasyFxml easyFxml;
//
// /**
// * Called by {@link FxApplication} after Spring and JavaFX are started. This is the equivalent of {@link javafx.application.Application#start(Stage)} in
// * traditional JavaFX apps.
// *
// * @param mainStage A reference to the main stage of the application, received from JavaFX via {@link javafx.application.Application#start(Stage)}.
// */
// public void startGui(final Stage mainStage) {
// try {
// onStageCreated(mainStage);
// final Scene mainScene = getScene(mainComponent());
// onSceneCreated(mainScene);
// mainStage.setScene(mainScene);
// mainStage.setTitle(title());
//
// Option.ofOptional(getStylesheet())
// .filter(style -> !FxmlStylesheets.DEFAULT_JAVAFX_STYLE.equals(style))
// .peek(stylesheet -> this.setTheme(stylesheet, mainStage));
//
// mainStage.show();
// } catch (Throwable t) {
// throw new RuntimeException("There was a failure during start-up of the application.", t);
// }
// }
//
// /**
// * @return The title to give the main stage
// */
// protected abstract String title();
//
// /**
// * @return The component to load in the main stage upon startup
// */
// protected abstract FxmlComponent mainComponent();
//
// /**
// * Called right after the main {@link Scene} was created if you want to edit it.
// *
// * @param mainScene The main scene of the application
// */
// @SuppressWarnings("unused")
// protected void onSceneCreated(final Scene mainScene) {
// //do nothing by default
// }
//
// /**
// * Called as we enter the {@link #startGui(Stage)} method.
// *
// * @param mainStage The main stage, supplied by JavaFX's {@link javafx.application.Application#start(Stage)} method.
// */
// @SuppressWarnings("unused")
// protected void onStageCreated(final Stage mainStage) {
// //do nothing by default
// }
//
// /**
// * @return If overriden, this function returns the {@link FxmlStylesheet} to apply to the main window.
// */
// protected Optional<FxmlStylesheet> getStylesheet() {
// return Optional.empty();
// }
//
// /**
// * Simple utility class to load an {@link FxmlComponent} as a {@link Scene} for use with {@link #mainComponent()}
// *
// * @param component the component to load in the {@link Scene}
// *
// * @return The ready-to-use {@link Scene}
// *
// * @throws RuntimeException if the scene could not be loaded properly
// */
// protected Scene getScene(final FxmlComponent component) {
// return easyFxml
// .load(component)
// .getNode()
// .map(Scene::new)
// .getOrElseThrow((Function<? super Throwable, RuntimeException>) RuntimeException::new);
// }
//
// private void setTheme(final FxmlStylesheet stylesheet, Stage mainStage) {
// Try.of(() -> stylesheet)
// .mapTry(FxmlStylesheet::getExternalForm)
// .mapTry(stylesheetUri -> Stages.setStylesheet(mainStage, stylesheetUri))
// .orElseRun(err -> ExceptionHandler.displayExceptionPane(
// "Could not load theme!",
// "Could not load theme file with description : " + stylesheet,
// err
// ));
// }
//
// @Autowired
// public void setEasyFxml(EasyFxml easyFxml) {
// this.easyFxml = easyFxml;
// }
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/UserFormComponent.java
// @Component
// public class UserFormComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "UserForm.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return UserFormController.class;
// }
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.FxUiManager;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.samples.form.user.view.userform.UserFormComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view;
@Component
public class UserFormUiManager extends FxUiManager {
| // Path: easyfxml/src/main/java/moe/tristan/easyfxml/FxUiManager.java
// public abstract class FxUiManager {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FxUiManager.class);
//
// private EasyFxml easyFxml;
//
// /**
// * Called by {@link FxApplication} after Spring and JavaFX are started. This is the equivalent of {@link javafx.application.Application#start(Stage)} in
// * traditional JavaFX apps.
// *
// * @param mainStage A reference to the main stage of the application, received from JavaFX via {@link javafx.application.Application#start(Stage)}.
// */
// public void startGui(final Stage mainStage) {
// try {
// onStageCreated(mainStage);
// final Scene mainScene = getScene(mainComponent());
// onSceneCreated(mainScene);
// mainStage.setScene(mainScene);
// mainStage.setTitle(title());
//
// Option.ofOptional(getStylesheet())
// .filter(style -> !FxmlStylesheets.DEFAULT_JAVAFX_STYLE.equals(style))
// .peek(stylesheet -> this.setTheme(stylesheet, mainStage));
//
// mainStage.show();
// } catch (Throwable t) {
// throw new RuntimeException("There was a failure during start-up of the application.", t);
// }
// }
//
// /**
// * @return The title to give the main stage
// */
// protected abstract String title();
//
// /**
// * @return The component to load in the main stage upon startup
// */
// protected abstract FxmlComponent mainComponent();
//
// /**
// * Called right after the main {@link Scene} was created if you want to edit it.
// *
// * @param mainScene The main scene of the application
// */
// @SuppressWarnings("unused")
// protected void onSceneCreated(final Scene mainScene) {
// //do nothing by default
// }
//
// /**
// * Called as we enter the {@link #startGui(Stage)} method.
// *
// * @param mainStage The main stage, supplied by JavaFX's {@link javafx.application.Application#start(Stage)} method.
// */
// @SuppressWarnings("unused")
// protected void onStageCreated(final Stage mainStage) {
// //do nothing by default
// }
//
// /**
// * @return If overriden, this function returns the {@link FxmlStylesheet} to apply to the main window.
// */
// protected Optional<FxmlStylesheet> getStylesheet() {
// return Optional.empty();
// }
//
// /**
// * Simple utility class to load an {@link FxmlComponent} as a {@link Scene} for use with {@link #mainComponent()}
// *
// * @param component the component to load in the {@link Scene}
// *
// * @return The ready-to-use {@link Scene}
// *
// * @throws RuntimeException if the scene could not be loaded properly
// */
// protected Scene getScene(final FxmlComponent component) {
// return easyFxml
// .load(component)
// .getNode()
// .map(Scene::new)
// .getOrElseThrow((Function<? super Throwable, RuntimeException>) RuntimeException::new);
// }
//
// private void setTheme(final FxmlStylesheet stylesheet, Stage mainStage) {
// Try.of(() -> stylesheet)
// .mapTry(FxmlStylesheet::getExternalForm)
// .mapTry(stylesheetUri -> Stages.setStylesheet(mainStage, stylesheetUri))
// .orElseRun(err -> ExceptionHandler.displayExceptionPane(
// "Could not load theme!",
// "Could not load theme file with description : " + stylesheet,
// err
// ));
// }
//
// @Autowired
// public void setEasyFxml(EasyFxml easyFxml) {
// this.easyFxml = easyFxml;
// }
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/UserFormComponent.java
// @Component
// public class UserFormComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "UserForm.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return UserFormController.class;
// }
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/UserFormUiManager.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.FxUiManager;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.samples.form.user.view.userform.UserFormComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view;
@Component
public class UserFormUiManager extends FxUiManager {
| private final UserFormComponent userFormComponent; |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/UserFormUiManager.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/FxUiManager.java
// public abstract class FxUiManager {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FxUiManager.class);
//
// private EasyFxml easyFxml;
//
// /**
// * Called by {@link FxApplication} after Spring and JavaFX are started. This is the equivalent of {@link javafx.application.Application#start(Stage)} in
// * traditional JavaFX apps.
// *
// * @param mainStage A reference to the main stage of the application, received from JavaFX via {@link javafx.application.Application#start(Stage)}.
// */
// public void startGui(final Stage mainStage) {
// try {
// onStageCreated(mainStage);
// final Scene mainScene = getScene(mainComponent());
// onSceneCreated(mainScene);
// mainStage.setScene(mainScene);
// mainStage.setTitle(title());
//
// Option.ofOptional(getStylesheet())
// .filter(style -> !FxmlStylesheets.DEFAULT_JAVAFX_STYLE.equals(style))
// .peek(stylesheet -> this.setTheme(stylesheet, mainStage));
//
// mainStage.show();
// } catch (Throwable t) {
// throw new RuntimeException("There was a failure during start-up of the application.", t);
// }
// }
//
// /**
// * @return The title to give the main stage
// */
// protected abstract String title();
//
// /**
// * @return The component to load in the main stage upon startup
// */
// protected abstract FxmlComponent mainComponent();
//
// /**
// * Called right after the main {@link Scene} was created if you want to edit it.
// *
// * @param mainScene The main scene of the application
// */
// @SuppressWarnings("unused")
// protected void onSceneCreated(final Scene mainScene) {
// //do nothing by default
// }
//
// /**
// * Called as we enter the {@link #startGui(Stage)} method.
// *
// * @param mainStage The main stage, supplied by JavaFX's {@link javafx.application.Application#start(Stage)} method.
// */
// @SuppressWarnings("unused")
// protected void onStageCreated(final Stage mainStage) {
// //do nothing by default
// }
//
// /**
// * @return If overriden, this function returns the {@link FxmlStylesheet} to apply to the main window.
// */
// protected Optional<FxmlStylesheet> getStylesheet() {
// return Optional.empty();
// }
//
// /**
// * Simple utility class to load an {@link FxmlComponent} as a {@link Scene} for use with {@link #mainComponent()}
// *
// * @param component the component to load in the {@link Scene}
// *
// * @return The ready-to-use {@link Scene}
// *
// * @throws RuntimeException if the scene could not be loaded properly
// */
// protected Scene getScene(final FxmlComponent component) {
// return easyFxml
// .load(component)
// .getNode()
// .map(Scene::new)
// .getOrElseThrow((Function<? super Throwable, RuntimeException>) RuntimeException::new);
// }
//
// private void setTheme(final FxmlStylesheet stylesheet, Stage mainStage) {
// Try.of(() -> stylesheet)
// .mapTry(FxmlStylesheet::getExternalForm)
// .mapTry(stylesheetUri -> Stages.setStylesheet(mainStage, stylesheetUri))
// .orElseRun(err -> ExceptionHandler.displayExceptionPane(
// "Could not load theme!",
// "Could not load theme file with description : " + stylesheet,
// err
// ));
// }
//
// @Autowired
// public void setEasyFxml(EasyFxml easyFxml) {
// this.easyFxml = easyFxml;
// }
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/UserFormComponent.java
// @Component
// public class UserFormComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "UserForm.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return UserFormController.class;
// }
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.FxUiManager;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.samples.form.user.view.userform.UserFormComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view;
@Component
public class UserFormUiManager extends FxUiManager {
private final UserFormComponent userFormComponent;
public UserFormUiManager(UserFormComponent userFormComponent) {
this.userFormComponent = userFormComponent;
}
@Override
protected String title() {
return "User sign up form";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/FxUiManager.java
// public abstract class FxUiManager {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FxUiManager.class);
//
// private EasyFxml easyFxml;
//
// /**
// * Called by {@link FxApplication} after Spring and JavaFX are started. This is the equivalent of {@link javafx.application.Application#start(Stage)} in
// * traditional JavaFX apps.
// *
// * @param mainStage A reference to the main stage of the application, received from JavaFX via {@link javafx.application.Application#start(Stage)}.
// */
// public void startGui(final Stage mainStage) {
// try {
// onStageCreated(mainStage);
// final Scene mainScene = getScene(mainComponent());
// onSceneCreated(mainScene);
// mainStage.setScene(mainScene);
// mainStage.setTitle(title());
//
// Option.ofOptional(getStylesheet())
// .filter(style -> !FxmlStylesheets.DEFAULT_JAVAFX_STYLE.equals(style))
// .peek(stylesheet -> this.setTheme(stylesheet, mainStage));
//
// mainStage.show();
// } catch (Throwable t) {
// throw new RuntimeException("There was a failure during start-up of the application.", t);
// }
// }
//
// /**
// * @return The title to give the main stage
// */
// protected abstract String title();
//
// /**
// * @return The component to load in the main stage upon startup
// */
// protected abstract FxmlComponent mainComponent();
//
// /**
// * Called right after the main {@link Scene} was created if you want to edit it.
// *
// * @param mainScene The main scene of the application
// */
// @SuppressWarnings("unused")
// protected void onSceneCreated(final Scene mainScene) {
// //do nothing by default
// }
//
// /**
// * Called as we enter the {@link #startGui(Stage)} method.
// *
// * @param mainStage The main stage, supplied by JavaFX's {@link javafx.application.Application#start(Stage)} method.
// */
// @SuppressWarnings("unused")
// protected void onStageCreated(final Stage mainStage) {
// //do nothing by default
// }
//
// /**
// * @return If overriden, this function returns the {@link FxmlStylesheet} to apply to the main window.
// */
// protected Optional<FxmlStylesheet> getStylesheet() {
// return Optional.empty();
// }
//
// /**
// * Simple utility class to load an {@link FxmlComponent} as a {@link Scene} for use with {@link #mainComponent()}
// *
// * @param component the component to load in the {@link Scene}
// *
// * @return The ready-to-use {@link Scene}
// *
// * @throws RuntimeException if the scene could not be loaded properly
// */
// protected Scene getScene(final FxmlComponent component) {
// return easyFxml
// .load(component)
// .getNode()
// .map(Scene::new)
// .getOrElseThrow((Function<? super Throwable, RuntimeException>) RuntimeException::new);
// }
//
// private void setTheme(final FxmlStylesheet stylesheet, Stage mainStage) {
// Try.of(() -> stylesheet)
// .mapTry(FxmlStylesheet::getExternalForm)
// .mapTry(stylesheetUri -> Stages.setStylesheet(mainStage, stylesheetUri))
// .orElseRun(err -> ExceptionHandler.displayExceptionPane(
// "Could not load theme!",
// "Could not load theme file with description : " + stylesheet,
// err
// ));
// }
//
// @Autowired
// public void setEasyFxml(EasyFxml easyFxml) {
// this.easyFxml = easyFxml;
// }
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/UserFormComponent.java
// @Component
// public class UserFormComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "UserForm.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return UserFormController.class;
// }
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/UserFormUiManager.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.FxUiManager;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.samples.form.user.view.userform.UserFormComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view;
@Component
public class UserFormUiManager extends FxUiManager {
private final UserFormComponent userFormComponent;
public UserFormUiManager(UserFormComponent userFormComponent) {
this.userFormComponent = userFormComponent;
}
@Override
protected String title() {
return "User sign up form";
}
@Override | protected FxmlComponent mainComponent() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/UserFormComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view.userform;
@Component
public class UserFormComponent implements FxmlComponent {
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/UserFormComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view.userform;
@Component
public class UserFormComponent implements FxmlComponent {
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/UserFormComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view.userform;
@Component
public class UserFormComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "UserForm.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/UserFormComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view.userform;
@Component
public class UserFormComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "UserForm.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/firstname/FirstnameComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view.userform.fields.firstname;
@Component
public class FirstnameComponent implements FxmlComponent {
public static final String FIRST_NAME_FIELD_NAME = "First name";
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/firstname/FirstnameComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* 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 moe.tristan.easyfxml.samples.form.user.view.userform.fields.firstname;
@Component
public class FirstnameComponent implements FxmlComponent {
public static final String FIRST_NAME_FIELD_NAME = "First name";
@Override | public FxmlFile getFile() { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.