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 |
|---|---|---|---|---|---|---|
lenguyenthanh/nimble | nimble/src/test/java/com/lenguyenthanh/nimble/view/TestNimbleLinearLayout.java | // Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimblePresenter.java
// public interface NimblePresenter<View extends NimbleView> {
// void takeView(View view);
//
// void onSave(Bundle outState);
//
// void dropView(View view);
//
// void onCreate(Bundle savedInstanceState);
//
// void onDestroy();
// }
//
// Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimbleView.java
// public interface NimbleView {
// }
| import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import com.lenguyenthanh.nimble.NimblePresenter;
import com.lenguyenthanh.nimble.NimbleView;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; | /*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimble.view;
public class TestNimbleLinearLayout {
@Mock | // Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimblePresenter.java
// public interface NimblePresenter<View extends NimbleView> {
// void takeView(View view);
//
// void onSave(Bundle outState);
//
// void dropView(View view);
//
// void onCreate(Bundle savedInstanceState);
//
// void onDestroy();
// }
//
// Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimbleView.java
// public interface NimbleView {
// }
// Path: nimble/src/test/java/com/lenguyenthanh/nimble/view/TestNimbleLinearLayout.java
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import com.lenguyenthanh.nimble.NimblePresenter;
import com.lenguyenthanh.nimble.NimbleView;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
/*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimble.view;
public class TestNimbleLinearLayout {
@Mock | NimblePresenter<NimbleView> presenter; |
lenguyenthanh/nimble | nimble/src/test/java/com/lenguyenthanh/nimble/view/NimbleActivityTest.java | // Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimblePresenter.java
// public interface NimblePresenter<View extends NimbleView> {
// void takeView(View view);
//
// void onSave(Bundle outState);
//
// void dropView(View view);
//
// void onCreate(Bundle savedInstanceState);
//
// void onDestroy();
// }
//
// Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimbleView.java
// public interface NimbleView {
// }
| import android.os.Bundle;
import com.lenguyenthanh.nimble.NimblePresenter;
import com.lenguyenthanh.nimble.NimbleView;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.verify; | /*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimble.view;
public class NimbleActivityTest {
@Mock | // Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimblePresenter.java
// public interface NimblePresenter<View extends NimbleView> {
// void takeView(View view);
//
// void onSave(Bundle outState);
//
// void dropView(View view);
//
// void onCreate(Bundle savedInstanceState);
//
// void onDestroy();
// }
//
// Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimbleView.java
// public interface NimbleView {
// }
// Path: nimble/src/test/java/com/lenguyenthanh/nimble/view/NimbleActivityTest.java
import android.os.Bundle;
import com.lenguyenthanh.nimble.NimblePresenter;
import com.lenguyenthanh.nimble.NimbleView;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.verify;
/*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimble.view;
public class NimbleActivityTest {
@Mock | NimblePresenter<NimbleView> presenter; |
lenguyenthanh/nimble | nimble/src/test/java/com/lenguyenthanh/nimble/view/NimbleActivityTest.java | // Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimblePresenter.java
// public interface NimblePresenter<View extends NimbleView> {
// void takeView(View view);
//
// void onSave(Bundle outState);
//
// void dropView(View view);
//
// void onCreate(Bundle savedInstanceState);
//
// void onDestroy();
// }
//
// Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimbleView.java
// public interface NimbleView {
// }
| import android.os.Bundle;
import com.lenguyenthanh.nimble.NimblePresenter;
import com.lenguyenthanh.nimble.NimbleView;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.verify; | /*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimble.view;
public class NimbleActivityTest {
@Mock | // Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimblePresenter.java
// public interface NimblePresenter<View extends NimbleView> {
// void takeView(View view);
//
// void onSave(Bundle outState);
//
// void dropView(View view);
//
// void onCreate(Bundle savedInstanceState);
//
// void onDestroy();
// }
//
// Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimbleView.java
// public interface NimbleView {
// }
// Path: nimble/src/test/java/com/lenguyenthanh/nimble/view/NimbleActivityTest.java
import android.os.Bundle;
import com.lenguyenthanh.nimble.NimblePresenter;
import com.lenguyenthanh.nimble.NimbleView;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.verify;
/*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimble.view;
public class NimbleActivityTest {
@Mock | NimblePresenter<NimbleView> presenter; |
lenguyenthanh/nimble | nimble-dagger2/src/main/java/com/lenguyenthanh/nimbledagger2/ui/main/MainActivity.java | // Path: nimble-dagger2/src/main/java/com/lenguyenthanh/nimbledagger2/DaggerApplication.java
// public class DaggerApplication extends Application{
// protected AppComponent appComponent;
//
// public AppComponent getAppComponent() {
// return appComponent;
// }
//
// public static DaggerApplication get(Context context) {
// return (DaggerApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// initializeDaggerComponent();
// }
//
// protected void initializeDaggerComponent() {
// appComponent = DaggerDaggerApplication_AppComponent.builder()
// .appModule(new AppModule(this))
// .build();
// appComponent.inject(this);
// }
//
// @Singleton
// @Component(modules = AppModule.class)
// public interface AppComponent {
// DaggerApplication application();
//
// void inject(DaggerApplication app);
// }
// }
//
// Path: nimble-dagger2/src/main/java/com/lenguyenthanh/nimbledagger2/ui/base/BaseActivity.java
// public abstract class BaseActivity<V extends NimbleView> extends NimbleActivity<V>
// implements NimbleView {
//
// @Override
// public void onContentChanged() {
// super.onContentChanged();
// ButterKnife.bind(this);
// }
//
// @Override
// protected void onDestroy() {
// ButterKnife.unbind(this);
// super.onDestroy();
// }
//
// @Override
// protected void initialize() {
// super.initialize();
// setupActivityComponent();
// }
//
// protected void setupActivityComponent() {
// buildComponent(DaggerApplication.get(this).getAppComponent());
// }
//
// abstract protected void buildComponent(DaggerApplication.AppComponent appComponent);
// }
| import android.widget.TextView;
import butterknife.Bind;
import butterknife.OnClick;
import com.lenguyenthanh.nimbledagger2.DaggerApplication;
import com.lenguyenthanh.nimbledagger2.R;
import com.lenguyenthanh.nimbledagger2.ui.base.BaseActivity;
import javax.inject.Inject; | /*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimbledagger2.ui.main;
public class MainActivity extends BaseActivity<MainView> implements MainView {
@Bind(R.id.tvContent)
TextView tvContent;
@Inject
MainPresenter presenter;
@Override
protected MainPresenter presenter() {
return presenter;
}
@Override
protected int layoutId() {
return R.layout.activity_main;
}
@Override | // Path: nimble-dagger2/src/main/java/com/lenguyenthanh/nimbledagger2/DaggerApplication.java
// public class DaggerApplication extends Application{
// protected AppComponent appComponent;
//
// public AppComponent getAppComponent() {
// return appComponent;
// }
//
// public static DaggerApplication get(Context context) {
// return (DaggerApplication) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// initializeDaggerComponent();
// }
//
// protected void initializeDaggerComponent() {
// appComponent = DaggerDaggerApplication_AppComponent.builder()
// .appModule(new AppModule(this))
// .build();
// appComponent.inject(this);
// }
//
// @Singleton
// @Component(modules = AppModule.class)
// public interface AppComponent {
// DaggerApplication application();
//
// void inject(DaggerApplication app);
// }
// }
//
// Path: nimble-dagger2/src/main/java/com/lenguyenthanh/nimbledagger2/ui/base/BaseActivity.java
// public abstract class BaseActivity<V extends NimbleView> extends NimbleActivity<V>
// implements NimbleView {
//
// @Override
// public void onContentChanged() {
// super.onContentChanged();
// ButterKnife.bind(this);
// }
//
// @Override
// protected void onDestroy() {
// ButterKnife.unbind(this);
// super.onDestroy();
// }
//
// @Override
// protected void initialize() {
// super.initialize();
// setupActivityComponent();
// }
//
// protected void setupActivityComponent() {
// buildComponent(DaggerApplication.get(this).getAppComponent());
// }
//
// abstract protected void buildComponent(DaggerApplication.AppComponent appComponent);
// }
// Path: nimble-dagger2/src/main/java/com/lenguyenthanh/nimbledagger2/ui/main/MainActivity.java
import android.widget.TextView;
import butterknife.Bind;
import butterknife.OnClick;
import com.lenguyenthanh.nimbledagger2.DaggerApplication;
import com.lenguyenthanh.nimbledagger2.R;
import com.lenguyenthanh.nimbledagger2.ui.base.BaseActivity;
import javax.inject.Inject;
/*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimbledagger2.ui.main;
public class MainActivity extends BaseActivity<MainView> implements MainView {
@Bind(R.id.tvContent)
TextView tvContent;
@Inject
MainPresenter presenter;
@Override
protected MainPresenter presenter() {
return presenter;
}
@Override
protected int layoutId() {
return R.layout.activity_main;
}
@Override | protected void buildComponent(DaggerApplication.AppComponent appComponent) { |
lenguyenthanh/nimble | nimble/src/main/java/com/lenguyenthanh/nimble/view/NimbleFrameLayout.java | // Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimblePresenter.java
// public interface NimblePresenter<View extends NimbleView> {
// void takeView(View view);
//
// void onSave(Bundle outState);
//
// void dropView(View view);
//
// void onCreate(Bundle savedInstanceState);
//
// void onDestroy();
// }
//
// Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimbleView.java
// public interface NimbleView {
// }
| import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import com.lenguyenthanh.nimble.NimblePresenter;
import com.lenguyenthanh.nimble.NimbleView; | /*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimble.view;
public abstract class NimbleFrameLayout<V extends NimbleView> extends FrameLayout
implements NimbleView {
protected static final String PARENT_STATE_KEY = "parent_state";
| // Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimblePresenter.java
// public interface NimblePresenter<View extends NimbleView> {
// void takeView(View view);
//
// void onSave(Bundle outState);
//
// void dropView(View view);
//
// void onCreate(Bundle savedInstanceState);
//
// void onDestroy();
// }
//
// Path: nimble/src/main/java/com/lenguyenthanh/nimble/NimbleView.java
// public interface NimbleView {
// }
// Path: nimble/src/main/java/com/lenguyenthanh/nimble/view/NimbleFrameLayout.java
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import com.lenguyenthanh.nimble.NimblePresenter;
import com.lenguyenthanh.nimble.NimbleView;
/*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimble.view;
public abstract class NimbleFrameLayout<V extends NimbleView> extends FrameLayout
implements NimbleView {
protected static final String PARENT_STATE_KEY = "parent_state";
| abstract protected NimblePresenter<V> presenter(); |
asaflevy/SelenuimExtend | src/main/java/com/outbrain/selenium/extjs/components/Fieldset.java | // Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java
// public abstract class ComponentLocator {
//
// /**
// * Field sel.
// */
// private final Selenium selenium;
// /**
// * Field xtype.
// */
// private Xtype xtype;
// /**
// * Field textOrLable.
// */
// private String textOrLable;
//
// /**
// * Method getComponentId.
//
// * @return String */
// public abstract String getComponentId();
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param textOrLable String
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final String textOrLable, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// setTextOrLable(textOrLable);
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// */
// public ComponentLocator(final Selenium sel) {
// selenium = sel;
//
// }
//
// /**
// * Method getSelenium.
//
// * @return Selenium */
// public Selenium getSelenium() {
// return selenium;
// }
//
// /**
// * Method getXtype.
// * @return Xtype */
// protected Xtype getXtype() {
// return xtype;
// }
//
// /**
// * Method getTextOrLable.
// * @return String */
// public String getTextOrLable() {
// return textOrLable;
// }
//
// /**
// * Method setTextOrLable.
// * @param textOrLable String
// */
// public void setTextOrLable(final String textOrLable) {
// this.textOrLable = textOrLable;
// }
//
// /**
// * Method waitCmpNotNull.
// * @param fullExpr String
// * @return String */
// protected String waitCmpNotNull(final String fullExpr) {
// for (int second = 0;; second++) {
// if (second >= 5) {
// throw new RuntimeException("Timeout");
// }
//
// try {
// String componentId = null;
// componentId = getSelenium().getEval(fullExpr);
// if (!"null".equals(componentId)) {
// return componentId;
// }
// } catch (final Exception e) {
// // ignore
// }
//
// try {
// Thread.sleep(1000);
// } catch (final InterruptedException e) {
// // ignore
// }
// }
// }
// }
| import com.outbrain.selenium.extjs.core.locators.ComponentLocator;
| package com.outbrain.selenium.extjs.components;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class Fieldset extends Component {
/**
* Field checkbox.
*/
private Checkbox checkbox;
/**
* Constructor for Fieldset.
* @param locator ComponentLocator
*/
| // Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java
// public abstract class ComponentLocator {
//
// /**
// * Field sel.
// */
// private final Selenium selenium;
// /**
// * Field xtype.
// */
// private Xtype xtype;
// /**
// * Field textOrLable.
// */
// private String textOrLable;
//
// /**
// * Method getComponentId.
//
// * @return String */
// public abstract String getComponentId();
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param textOrLable String
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final String textOrLable, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// setTextOrLable(textOrLable);
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// */
// public ComponentLocator(final Selenium sel) {
// selenium = sel;
//
// }
//
// /**
// * Method getSelenium.
//
// * @return Selenium */
// public Selenium getSelenium() {
// return selenium;
// }
//
// /**
// * Method getXtype.
// * @return Xtype */
// protected Xtype getXtype() {
// return xtype;
// }
//
// /**
// * Method getTextOrLable.
// * @return String */
// public String getTextOrLable() {
// return textOrLable;
// }
//
// /**
// * Method setTextOrLable.
// * @param textOrLable String
// */
// public void setTextOrLable(final String textOrLable) {
// this.textOrLable = textOrLable;
// }
//
// /**
// * Method waitCmpNotNull.
// * @param fullExpr String
// * @return String */
// protected String waitCmpNotNull(final String fullExpr) {
// for (int second = 0;; second++) {
// if (second >= 5) {
// throw new RuntimeException("Timeout");
// }
//
// try {
// String componentId = null;
// componentId = getSelenium().getEval(fullExpr);
// if (!"null".equals(componentId)) {
// return componentId;
// }
// } catch (final Exception e) {
// // ignore
// }
//
// try {
// Thread.sleep(1000);
// } catch (final InterruptedException e) {
// // ignore
// }
// }
// }
// }
// Path: src/main/java/com/outbrain/selenium/extjs/components/Fieldset.java
import com.outbrain.selenium.extjs.core.locators.ComponentLocator;
package com.outbrain.selenium.extjs.components;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class Fieldset extends Component {
/**
* Field checkbox.
*/
private Checkbox checkbox;
/**
* Constructor for Fieldset.
* @param locator ComponentLocator
*/
| public Fieldset(final ComponentLocator locator) {
|
asaflevy/SelenuimExtend | src/main/java/com/outbrain/selenium/extjs/core/locators/TextOrLableLocator.java | // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
| import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
| package com.outbrain.selenium.extjs.core.locators;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TextOrLableLocator extends ComponentLocator {
Integer index = null;
/**
* Field textOrLable.
*/
String textOrLable;
/**
* Constructor for TextOrLableLocator.
* @param sel Selenium
* @param nameOrLable String
* @param xtype Xtype
*/
| // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
// Path: src/main/java/com/outbrain/selenium/extjs/core/locators/TextOrLableLocator.java
import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
package com.outbrain.selenium.extjs.core.locators;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TextOrLableLocator extends ComponentLocator {
Integer index = null;
/**
* Field textOrLable.
*/
String textOrLable;
/**
* Constructor for TextOrLableLocator.
* @param sel Selenium
* @param nameOrLable String
* @param xtype Xtype
*/
| public TextOrLableLocator(final Selenium sel, final String nameOrLable, final Xtype xtype) {
|
asaflevy/SelenuimExtend | src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java | // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
| import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
| package com.outbrain.selenium.extjs.core.locators;
/**
* Base Class for locating an extjs component
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public abstract class ComponentLocator {
/**
* Field sel.
*/
private final Selenium selenium;
/**
* Field xtype.
*/
| // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
// Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java
import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
package com.outbrain.selenium.extjs.core.locators;
/**
* Base Class for locating an extjs component
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public abstract class ComponentLocator {
/**
* Field sel.
*/
private final Selenium selenium;
/**
* Field xtype.
*/
| private Xtype xtype;
|
asaflevy/SelenuimExtend | src/main/java/com/outbrain/selenium/extjs/components/TriggerField.java | // Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java
// public abstract class ComponentLocator {
//
// /**
// * Field sel.
// */
// private final Selenium selenium;
// /**
// * Field xtype.
// */
// private Xtype xtype;
// /**
// * Field textOrLable.
// */
// private String textOrLable;
//
// /**
// * Method getComponentId.
//
// * @return String */
// public abstract String getComponentId();
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param textOrLable String
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final String textOrLable, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// setTextOrLable(textOrLable);
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// */
// public ComponentLocator(final Selenium sel) {
// selenium = sel;
//
// }
//
// /**
// * Method getSelenium.
//
// * @return Selenium */
// public Selenium getSelenium() {
// return selenium;
// }
//
// /**
// * Method getXtype.
// * @return Xtype */
// protected Xtype getXtype() {
// return xtype;
// }
//
// /**
// * Method getTextOrLable.
// * @return String */
// public String getTextOrLable() {
// return textOrLable;
// }
//
// /**
// * Method setTextOrLable.
// * @param textOrLable String
// */
// public void setTextOrLable(final String textOrLable) {
// this.textOrLable = textOrLable;
// }
//
// /**
// * Method waitCmpNotNull.
// * @param fullExpr String
// * @return String */
// protected String waitCmpNotNull(final String fullExpr) {
// for (int second = 0;; second++) {
// if (second >= 5) {
// throw new RuntimeException("Timeout");
// }
//
// try {
// String componentId = null;
// componentId = getSelenium().getEval(fullExpr);
// if (!"null".equals(componentId)) {
// return componentId;
// }
// } catch (final Exception e) {
// // ignore
// }
//
// try {
// Thread.sleep(1000);
// } catch (final InterruptedException e) {
// // ignore
// }
// }
// }
// }
| import com.outbrain.selenium.extjs.core.locators.ComponentLocator;
import com.thoughtworks.selenium.Selenium;
| package com.outbrain.selenium.extjs.components;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TriggerField extends Component {
/**
* Field trigger.
*/
private Button trigger;
/**
* Constructor for TriggerField.
* @param locator ComponentLocator
*/
| // Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java
// public abstract class ComponentLocator {
//
// /**
// * Field sel.
// */
// private final Selenium selenium;
// /**
// * Field xtype.
// */
// private Xtype xtype;
// /**
// * Field textOrLable.
// */
// private String textOrLable;
//
// /**
// * Method getComponentId.
//
// * @return String */
// public abstract String getComponentId();
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param textOrLable String
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final String textOrLable, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// setTextOrLable(textOrLable);
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// */
// public ComponentLocator(final Selenium sel) {
// selenium = sel;
//
// }
//
// /**
// * Method getSelenium.
//
// * @return Selenium */
// public Selenium getSelenium() {
// return selenium;
// }
//
// /**
// * Method getXtype.
// * @return Xtype */
// protected Xtype getXtype() {
// return xtype;
// }
//
// /**
// * Method getTextOrLable.
// * @return String */
// public String getTextOrLable() {
// return textOrLable;
// }
//
// /**
// * Method setTextOrLable.
// * @param textOrLable String
// */
// public void setTextOrLable(final String textOrLable) {
// this.textOrLable = textOrLable;
// }
//
// /**
// * Method waitCmpNotNull.
// * @param fullExpr String
// * @return String */
// protected String waitCmpNotNull(final String fullExpr) {
// for (int second = 0;; second++) {
// if (second >= 5) {
// throw new RuntimeException("Timeout");
// }
//
// try {
// String componentId = null;
// componentId = getSelenium().getEval(fullExpr);
// if (!"null".equals(componentId)) {
// return componentId;
// }
// } catch (final Exception e) {
// // ignore
// }
//
// try {
// Thread.sleep(1000);
// } catch (final InterruptedException e) {
// // ignore
// }
// }
// }
// }
// Path: src/main/java/com/outbrain/selenium/extjs/components/TriggerField.java
import com.outbrain.selenium.extjs.core.locators.ComponentLocator;
import com.thoughtworks.selenium.Selenium;
package com.outbrain.selenium.extjs.components;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TriggerField extends Component {
/**
* Field trigger.
*/
private Button trigger;
/**
* Constructor for TriggerField.
* @param locator ComponentLocator
*/
| public TriggerField(final ComponentLocator locator) {
|
asaflevy/SelenuimExtend | src/main/java/com/outbrain/selenium/extjs/components/TreeNode.java | // Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java
// public abstract class ComponentLocator {
//
// /**
// * Field sel.
// */
// private final Selenium selenium;
// /**
// * Field xtype.
// */
// private Xtype xtype;
// /**
// * Field textOrLable.
// */
// private String textOrLable;
//
// /**
// * Method getComponentId.
//
// * @return String */
// public abstract String getComponentId();
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param textOrLable String
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final String textOrLable, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// setTextOrLable(textOrLable);
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// */
// public ComponentLocator(final Selenium sel) {
// selenium = sel;
//
// }
//
// /**
// * Method getSelenium.
//
// * @return Selenium */
// public Selenium getSelenium() {
// return selenium;
// }
//
// /**
// * Method getXtype.
// * @return Xtype */
// protected Xtype getXtype() {
// return xtype;
// }
//
// /**
// * Method getTextOrLable.
// * @return String */
// public String getTextOrLable() {
// return textOrLable;
// }
//
// /**
// * Method setTextOrLable.
// * @param textOrLable String
// */
// public void setTextOrLable(final String textOrLable) {
// this.textOrLable = textOrLable;
// }
//
// /**
// * Method waitCmpNotNull.
// * @param fullExpr String
// * @return String */
// protected String waitCmpNotNull(final String fullExpr) {
// for (int second = 0;; second++) {
// if (second >= 5) {
// throw new RuntimeException("Timeout");
// }
//
// try {
// String componentId = null;
// componentId = getSelenium().getEval(fullExpr);
// if (!"null".equals(componentId)) {
// return componentId;
// }
// } catch (final Exception e) {
// // ignore
// }
//
// try {
// Thread.sleep(1000);
// } catch (final InterruptedException e) {
// // ignore
// }
// }
// }
// }
| import com.outbrain.selenium.extjs.core.locators.ComponentLocator;
import com.thoughtworks.selenium.Selenium;
| package com.outbrain.selenium.extjs.components;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TreeNode extends Component {
final String getUIfunction = ".getUI()";
/**
* Field nodeExpression.
*/
private String nodeExpression = "";
/**
* Field nodeUiExpression.
*/
private String nodeUiExpression = "";
/**
* Field treeExpression.
*/
private String treeExpression = "";
/**
* Constructor for TreeNode.
* @param selenium Selenium
* @param expression String
*/
public TreeNode(final Selenium selenium, final String expression) {
super(selenium, expression);
treeExpression = expression;
}
/**
* @param parentTree Locator
*/
| // Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java
// public abstract class ComponentLocator {
//
// /**
// * Field sel.
// */
// private final Selenium selenium;
// /**
// * Field xtype.
// */
// private Xtype xtype;
// /**
// * Field textOrLable.
// */
// private String textOrLable;
//
// /**
// * Method getComponentId.
//
// * @return String */
// public abstract String getComponentId();
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param textOrLable String
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final String textOrLable, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// setTextOrLable(textOrLable);
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// */
// public ComponentLocator(final Selenium sel) {
// selenium = sel;
//
// }
//
// /**
// * Method getSelenium.
//
// * @return Selenium */
// public Selenium getSelenium() {
// return selenium;
// }
//
// /**
// * Method getXtype.
// * @return Xtype */
// protected Xtype getXtype() {
// return xtype;
// }
//
// /**
// * Method getTextOrLable.
// * @return String */
// public String getTextOrLable() {
// return textOrLable;
// }
//
// /**
// * Method setTextOrLable.
// * @param textOrLable String
// */
// public void setTextOrLable(final String textOrLable) {
// this.textOrLable = textOrLable;
// }
//
// /**
// * Method waitCmpNotNull.
// * @param fullExpr String
// * @return String */
// protected String waitCmpNotNull(final String fullExpr) {
// for (int second = 0;; second++) {
// if (second >= 5) {
// throw new RuntimeException("Timeout");
// }
//
// try {
// String componentId = null;
// componentId = getSelenium().getEval(fullExpr);
// if (!"null".equals(componentId)) {
// return componentId;
// }
// } catch (final Exception e) {
// // ignore
// }
//
// try {
// Thread.sleep(1000);
// } catch (final InterruptedException e) {
// // ignore
// }
// }
// }
// }
// Path: src/main/java/com/outbrain/selenium/extjs/components/TreeNode.java
import com.outbrain.selenium.extjs.core.locators.ComponentLocator;
import com.thoughtworks.selenium.Selenium;
package com.outbrain.selenium.extjs.components;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TreeNode extends Component {
final String getUIfunction = ".getUI()";
/**
* Field nodeExpression.
*/
private String nodeExpression = "";
/**
* Field nodeUiExpression.
*/
private String nodeUiExpression = "";
/**
* Field treeExpression.
*/
private String treeExpression = "";
/**
* Constructor for TreeNode.
* @param selenium Selenium
* @param expression String
*/
public TreeNode(final Selenium selenium, final String expression) {
super(selenium, expression);
treeExpression = expression;
}
/**
* @param parentTree Locator
*/
| public TreeNode(final ComponentLocator parentTree) {
|
asaflevy/SelenuimExtend | src/main/java/com/outbrain/selenium/extjs/components/TabPanel.java | // Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java
// public abstract class ComponentLocator {
//
// /**
// * Field sel.
// */
// private final Selenium selenium;
// /**
// * Field xtype.
// */
// private Xtype xtype;
// /**
// * Field textOrLable.
// */
// private String textOrLable;
//
// /**
// * Method getComponentId.
//
// * @return String */
// public abstract String getComponentId();
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param textOrLable String
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final String textOrLable, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// setTextOrLable(textOrLable);
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// */
// public ComponentLocator(final Selenium sel) {
// selenium = sel;
//
// }
//
// /**
// * Method getSelenium.
//
// * @return Selenium */
// public Selenium getSelenium() {
// return selenium;
// }
//
// /**
// * Method getXtype.
// * @return Xtype */
// protected Xtype getXtype() {
// return xtype;
// }
//
// /**
// * Method getTextOrLable.
// * @return String */
// public String getTextOrLable() {
// return textOrLable;
// }
//
// /**
// * Method setTextOrLable.
// * @param textOrLable String
// */
// public void setTextOrLable(final String textOrLable) {
// this.textOrLable = textOrLable;
// }
//
// /**
// * Method waitCmpNotNull.
// * @param fullExpr String
// * @return String */
// protected String waitCmpNotNull(final String fullExpr) {
// for (int second = 0;; second++) {
// if (second >= 5) {
// throw new RuntimeException("Timeout");
// }
//
// try {
// String componentId = null;
// componentId = getSelenium().getEval(fullExpr);
// if (!"null".equals(componentId)) {
// return componentId;
// }
// } catch (final Exception e) {
// // ignore
// }
//
// try {
// Thread.sleep(1000);
// } catch (final InterruptedException e) {
// // ignore
// }
// }
// }
// }
| import com.outbrain.selenium.extjs.core.locators.ComponentLocator;
| package com.outbrain.selenium.extjs.components;
/***
* TabPanel represent Ext TabPanel (The Master tab Panel) So if search for specific tab inside a tabPanel the function will return the master tab panel
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TabPanel extends Component {
/**
* Field tabIndex.
*/
private int tabIndex;
/**
* Constructor for TabPanel.
* @param locator ComponentLocator
* @param tabIndex Integer
*/
| // Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocator.java
// public abstract class ComponentLocator {
//
// /**
// * Field sel.
// */
// private final Selenium selenium;
// /**
// * Field xtype.
// */
// private Xtype xtype;
// /**
// * Field textOrLable.
// */
// private String textOrLable;
//
// /**
// * Method getComponentId.
//
// * @return String */
// public abstract String getComponentId();
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param textOrLable String
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final String textOrLable, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// setTextOrLable(textOrLable);
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// * @param xtype Xtype
// */
// public ComponentLocator(final Selenium sel, final Xtype xtype) {
// selenium = sel;
// this.xtype = xtype;
// }
//
// /**
// * Constructor for ComponentLocator.
// * @param sel Selenium
// */
// public ComponentLocator(final Selenium sel) {
// selenium = sel;
//
// }
//
// /**
// * Method getSelenium.
//
// * @return Selenium */
// public Selenium getSelenium() {
// return selenium;
// }
//
// /**
// * Method getXtype.
// * @return Xtype */
// protected Xtype getXtype() {
// return xtype;
// }
//
// /**
// * Method getTextOrLable.
// * @return String */
// public String getTextOrLable() {
// return textOrLable;
// }
//
// /**
// * Method setTextOrLable.
// * @param textOrLable String
// */
// public void setTextOrLable(final String textOrLable) {
// this.textOrLable = textOrLable;
// }
//
// /**
// * Method waitCmpNotNull.
// * @param fullExpr String
// * @return String */
// protected String waitCmpNotNull(final String fullExpr) {
// for (int second = 0;; second++) {
// if (second >= 5) {
// throw new RuntimeException("Timeout");
// }
//
// try {
// String componentId = null;
// componentId = getSelenium().getEval(fullExpr);
// if (!"null".equals(componentId)) {
// return componentId;
// }
// } catch (final Exception e) {
// // ignore
// }
//
// try {
// Thread.sleep(1000);
// } catch (final InterruptedException e) {
// // ignore
// }
// }
// }
// }
// Path: src/main/java/com/outbrain/selenium/extjs/components/TabPanel.java
import com.outbrain.selenium.extjs.core.locators.ComponentLocator;
package com.outbrain.selenium.extjs.components;
/***
* TabPanel represent Ext TabPanel (The Master tab Panel) So if search for specific tab inside a tabPanel the function will return the master tab panel
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TabPanel extends Component {
/**
* Field tabIndex.
*/
private int tabIndex;
/**
* Constructor for TabPanel.
* @param locator ComponentLocator
* @param tabIndex Integer
*/
| public TabPanel(final ComponentLocator locator, final Integer tabIndex) {
|
asaflevy/SelenuimExtend | src/main/java/com/outbrain/selenium/extjs/core/locators/TextOrLableInComponentLocator.java | // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
| import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
| package com.outbrain.selenium.extjs.core.locators;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TextOrLableInComponentLocator extends ComponentLocator {
/**
* Field textOrLable.
*/
private final String textOrLable;
/**
* Field parentCmpId.
*/
private final String parentCmpId;
/**
* Constructor for TextOrLableInComponentLocator.
* @param sel Selenium
* @param parentCmpId String
* @param textOrLable String
* @param xtype Xtype
*/
| // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
// Path: src/main/java/com/outbrain/selenium/extjs/core/locators/TextOrLableInComponentLocator.java
import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
package com.outbrain.selenium.extjs.core.locators;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TextOrLableInComponentLocator extends ComponentLocator {
/**
* Field textOrLable.
*/
private final String textOrLable;
/**
* Field parentCmpId.
*/
private final String parentCmpId;
/**
* Constructor for TextOrLableInComponentLocator.
* @param sel Selenium
* @param parentCmpId String
* @param textOrLable String
* @param xtype Xtype
*/
| public TextOrLableInComponentLocator(final Selenium sel, final String parentCmpId, final String textOrLable, final Xtype xtype) {
|
asaflevy/SelenuimExtend | src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocatorFactory.java | // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
| import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
| package com.outbrain.selenium.extjs.core.locators;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class ComponentLocatorFactory {
private final Selenium selenium;
/**
*
* @param Selenium sel
*/
public ComponentLocatorFactory(final Selenium sel) {
selenium = sel;
}
/**
* Method createLocator.
* @param textOrLable String
* @param xtype Xtype
* @return ComponentLocator */
| // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
// Path: src/main/java/com/outbrain/selenium/extjs/core/locators/ComponentLocatorFactory.java
import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
package com.outbrain.selenium.extjs.core.locators;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class ComponentLocatorFactory {
private final Selenium selenium;
/**
*
* @param Selenium sel
*/
public ComponentLocatorFactory(final Selenium sel) {
selenium = sel;
}
/**
* Method createLocator.
* @param textOrLable String
* @param xtype Xtype
* @return ComponentLocator */
| public ComponentLocator createLocator(final String textOrLable, final Xtype xtype) {
|
asaflevy/SelenuimExtend | src/main/java/com/outbrain/selenium/extjs/core/locators/TypeLocator.java | // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
| import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
| package com.outbrain.selenium.extjs.core.locators;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TypeLocator extends ComponentLocator {
/**
* Field index.
*/
Integer index = null;
/**
* Constructor for TypeLocator.
* @param selenium Selenium
* @param type Xtype
* @param idx int
*/
| // Path: src/main/java/com/outbrain/selenium/util/ExtjsUtils.java
// public static enum Xtype {
// NUMBERFIELD,
// BOX,
// DATEFIELD,
// BUTTON,
// BUTTONGROUP,
// COLORPALETTE,
// COMPONENT,
// CONTAINER,
// CYCLE,
// DATAVIEW,
// DATEPICKER,
// EDITOR,
// EDITORGRID,
// FLASH,
// GRID,
// LISTVIEW,
// PANEL,
// WINDOW,
// SPLITBUTTON,
// TABPANEL,
// TREEPANEL,
// VIEWPORT,
// TREEGRID,
// TEXTFIELD,
// TEXTAREA,
// COMBO,
// CHECKBOX,
// TRIGGER,
// RADIO,
// LABEL,
// MENU,
// SUPERBOXSELECT;
//
// public String getName() {
// return toString().toLowerCase();
// }
// }
// Path: src/main/java/com/outbrain/selenium/extjs/core/locators/TypeLocator.java
import com.outbrain.selenium.util.ExtjsUtils.Xtype;
import com.thoughtworks.selenium.Selenium;
package com.outbrain.selenium.extjs.core.locators;
/**
* @author Asaf Levy
* @version $Revision: 1.0
*/
public class TypeLocator extends ComponentLocator {
/**
* Field index.
*/
Integer index = null;
/**
* Constructor for TypeLocator.
* @param selenium Selenium
* @param type Xtype
* @param idx int
*/
| public TypeLocator(final Selenium selenium, final Xtype type, final int idx) {
|
keunlee/sample-fullstack-app | backend-java/src/main/java/com/stocks/sample/cli/ImportStocksFromURICommand.java | // Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
| import com.stocks.sample.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.stereotype.Component; | package com.stocks.sample.cli;
@Component
public class ImportStocksFromURICommand implements CommandMarker {
@Autowired | // Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
// Path: backend-java/src/main/java/com/stocks/sample/cli/ImportStocksFromURICommand.java
import com.stocks.sample.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.stereotype.Component;
package com.stocks.sample.cli;
@Component
public class ImportStocksFromURICommand implements CommandMarker {
@Autowired | private StockService stockService; |
keunlee/sample-fullstack-app | backend-java/src/test/java/com/stocks/sample/test/service/StockServiceTest.java | // Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
// private Long id;
// private String name;
// private String symbol;
//
// public StockDto() {}
//
// public StockDto( Stock entity ) {
// this.id = entity.getId();
// this.name = entity.getName();
// this.symbol = entity.getSymbol();
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
//
// Path: backend-java/src/test/java/com/stocks/sample/test/AbstractTestConfiguration.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @WebAppConfiguration
// @ContextConfiguration({"classpath:spring/application-context.xml"})
// @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
// public class AbstractTestConfiguration {
// }
| import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import com.stocks.sample.test.AbstractTestConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; | package com.stocks.sample.test.service;
public class StockServiceTest extends AbstractTestConfiguration {
@Autowired | // Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
// private Long id;
// private String name;
// private String symbol;
//
// public StockDto() {}
//
// public StockDto( Stock entity ) {
// this.id = entity.getId();
// this.name = entity.getName();
// this.symbol = entity.getSymbol();
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
//
// Path: backend-java/src/test/java/com/stocks/sample/test/AbstractTestConfiguration.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @WebAppConfiguration
// @ContextConfiguration({"classpath:spring/application-context.xml"})
// @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
// public class AbstractTestConfiguration {
// }
// Path: backend-java/src/test/java/com/stocks/sample/test/service/StockServiceTest.java
import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import com.stocks.sample.test.AbstractTestConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
package com.stocks.sample.test.service;
public class StockServiceTest extends AbstractTestConfiguration {
@Autowired | private StockService stockService; |
keunlee/sample-fullstack-app | backend-java/src/test/java/com/stocks/sample/test/service/StockServiceTest.java | // Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
// private Long id;
// private String name;
// private String symbol;
//
// public StockDto() {}
//
// public StockDto( Stock entity ) {
// this.id = entity.getId();
// this.name = entity.getName();
// this.symbol = entity.getSymbol();
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
//
// Path: backend-java/src/test/java/com/stocks/sample/test/AbstractTestConfiguration.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @WebAppConfiguration
// @ContextConfiguration({"classpath:spring/application-context.xml"})
// @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
// public class AbstractTestConfiguration {
// }
| import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import com.stocks.sample.test.AbstractTestConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; | package com.stocks.sample.test.service;
public class StockServiceTest extends AbstractTestConfiguration {
@Autowired
private StockService stockService;
@Test
@Rollback(value = true)
@Transactional
public void testImportStocksByCSVFile() throws Exception {
String file = StockServiceTest.class.getResource("/data/amex.csv").getFile(); | // Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
// private Long id;
// private String name;
// private String symbol;
//
// public StockDto() {}
//
// public StockDto( Stock entity ) {
// this.id = entity.getId();
// this.name = entity.getName();
// this.symbol = entity.getSymbol();
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
//
// Path: backend-java/src/test/java/com/stocks/sample/test/AbstractTestConfiguration.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @WebAppConfiguration
// @ContextConfiguration({"classpath:spring/application-context.xml"})
// @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
// public class AbstractTestConfiguration {
// }
// Path: backend-java/src/test/java/com/stocks/sample/test/service/StockServiceTest.java
import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import com.stocks.sample.test.AbstractTestConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
package com.stocks.sample.test.service;
public class StockServiceTest extends AbstractTestConfiguration {
@Autowired
private StockService stockService;
@Test
@Rollback(value = true)
@Transactional
public void testImportStocksByCSVFile() throws Exception {
String file = StockServiceTest.class.getResource("/data/amex.csv").getFile(); | List<StockDto> results = stockService.importStocksByCSVFile(file); |
keunlee/sample-fullstack-app | backend-java/src/main/java/com/stocks/sample/controller/StockController.java | // Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
// private Long id;
// private String name;
// private String symbol;
//
// public StockDto() {}
//
// public StockDto( Stock entity ) {
// this.id = entity.getId();
// this.name = entity.getName();
// this.symbol = entity.getSymbol();
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
| import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List; | package com.stocks.sample.controller;
@Controller
public class StockController extends AbstractController {
@Autowired | // Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
// private Long id;
// private String name;
// private String symbol;
//
// public StockDto() {}
//
// public StockDto( Stock entity ) {
// this.id = entity.getId();
// this.name = entity.getName();
// this.symbol = entity.getSymbol();
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
// Path: backend-java/src/main/java/com/stocks/sample/controller/StockController.java
import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
package com.stocks.sample.controller;
@Controller
public class StockController extends AbstractController {
@Autowired | private StockService stockService; |
keunlee/sample-fullstack-app | backend-java/src/main/java/com/stocks/sample/controller/StockController.java | // Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
// private Long id;
// private String name;
// private String symbol;
//
// public StockDto() {}
//
// public StockDto( Stock entity ) {
// this.id = entity.getId();
// this.name = entity.getName();
// this.symbol = entity.getSymbol();
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
| import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List; | package com.stocks.sample.controller;
@Controller
public class StockController extends AbstractController {
@Autowired
private StockService stockService;
/**
* @param q
* @return
*/
@ResponseBody
@RequestMapping(value = {"/service/stocks"}, method = {RequestMethod.GET}, produces = "application/json") | // Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
// private Long id;
// private String name;
// private String symbol;
//
// public StockDto() {}
//
// public StockDto( Stock entity ) {
// this.id = entity.getId();
// this.name = entity.getName();
// this.symbol = entity.getSymbol();
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
// List<StockDto> importStocksByCSVFile(String file) throws Exception;
//
// List<StockDto> findStocksByWildCard(String phrase);
//
// String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }
// Path: backend-java/src/main/java/com/stocks/sample/controller/StockController.java
import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
package com.stocks.sample.controller;
@Controller
public class StockController extends AbstractController {
@Autowired
private StockService stockService;
/**
* @param q
* @return
*/
@ResponseBody
@RequestMapping(value = {"/service/stocks"}, method = {RequestMethod.GET}, produces = "application/json") | public List<StockDto> findStocksByWildCard(@RequestParam("q") String q) { |
keunlee/sample-fullstack-app | backend-java/src/main/java/com/stocks/sample/dto/StockDto.java | // Path: backend-java/src/main/java/com/stocks/sample/domain/Stock.java
// @Entity
// @Table(name = "stock")
// public class Stock implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// @Id
// @SequenceGenerator(name = "stock_id_seq", sequenceName = "stock_id_seq", allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "stock_id_seq")
// private Long id;
//
// @Column
// private String symbol;
//
// @Column
// private String name;
//
// @Column
// private String lastSale;
//
// @Column
// private String marketCap;
//
// @Column
// private String ipoYear;
//
// @Column
// private String sector;
//
// @Column
// private String industry;
//
// @Column
// private String summary;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// id = id;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getLastSale() {
// return lastSale;
// }
//
// public void setLastSale(String lastSale) {
// this.lastSale = lastSale;
// }
//
// public String getMarketCap() {
// return marketCap;
// }
//
// public void setMarketCap(String marketCap) {
// this.marketCap = marketCap;
// }
//
// public String getIpoYear() {
// return ipoYear;
// }
//
// public void setIpoYear(String ipoYear) {
// this.ipoYear = ipoYear;
// }
//
// public String getSector() {
// return sector;
// }
//
// public void setSector(String sector) {
// this.sector = sector;
// }
//
// public String getIndustry() {
// return industry;
// }
//
// public void setIndustry(String industry) {
// this.industry = industry;
// }
//
// public String getSummary() {
// return summary;
// }
//
// public void setSummary(String summary) {
// this.summary = summary;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Stock stock = (Stock) o;
//
// if (id != null ? !id.equals(stock.id) : stock.id != null) return false;
// if (symbol != null ? !symbol.equals(stock.symbol) : stock.symbol != null) return false;
// if (name != null ? !name.equals(stock.name) : stock.name != null) return false;
// if (lastSale != null ? !lastSale.equals(stock.lastSale) : stock.lastSale != null) return false;
// if (marketCap != null ? !marketCap.equals(stock.marketCap) : stock.marketCap != null) return false;
// if (ipoYear != null ? !ipoYear.equals(stock.ipoYear) : stock.ipoYear != null) return false;
// if (sector != null ? !sector.equals(stock.sector) : stock.sector != null) return false;
// if (industry != null ? !industry.equals(stock.industry) : stock.industry != null) return false;
// return !(summary != null ? !summary.equals(stock.summary) : stock.summary != null);
//
// }
//
// @Override
// public int hashCode() {
// int result = id != null ? id.hashCode() : 0;
// result = 31 * result + (symbol != null ? symbol.hashCode() : 0);
// result = 31 * result + (name != null ? name.hashCode() : 0);
// result = 31 * result + (lastSale != null ? lastSale.hashCode() : 0);
// result = 31 * result + (marketCap != null ? marketCap.hashCode() : 0);
// result = 31 * result + (ipoYear != null ? ipoYear.hashCode() : 0);
// result = 31 * result + (sector != null ? sector.hashCode() : 0);
// result = 31 * result + (industry != null ? industry.hashCode() : 0);
// result = 31 * result + (summary != null ? summary.hashCode() : 0);
// return result;
// }
// }
| import com.stocks.sample.domain.Stock; | package com.stocks.sample.dto;
public class StockDto {
private Long id;
private String name;
private String symbol;
public StockDto() {}
| // Path: backend-java/src/main/java/com/stocks/sample/domain/Stock.java
// @Entity
// @Table(name = "stock")
// public class Stock implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// @Id
// @SequenceGenerator(name = "stock_id_seq", sequenceName = "stock_id_seq", allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "stock_id_seq")
// private Long id;
//
// @Column
// private String symbol;
//
// @Column
// private String name;
//
// @Column
// private String lastSale;
//
// @Column
// private String marketCap;
//
// @Column
// private String ipoYear;
//
// @Column
// private String sector;
//
// @Column
// private String industry;
//
// @Column
// private String summary;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// id = id;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getLastSale() {
// return lastSale;
// }
//
// public void setLastSale(String lastSale) {
// this.lastSale = lastSale;
// }
//
// public String getMarketCap() {
// return marketCap;
// }
//
// public void setMarketCap(String marketCap) {
// this.marketCap = marketCap;
// }
//
// public String getIpoYear() {
// return ipoYear;
// }
//
// public void setIpoYear(String ipoYear) {
// this.ipoYear = ipoYear;
// }
//
// public String getSector() {
// return sector;
// }
//
// public void setSector(String sector) {
// this.sector = sector;
// }
//
// public String getIndustry() {
// return industry;
// }
//
// public void setIndustry(String industry) {
// this.industry = industry;
// }
//
// public String getSummary() {
// return summary;
// }
//
// public void setSummary(String summary) {
// this.summary = summary;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Stock stock = (Stock) o;
//
// if (id != null ? !id.equals(stock.id) : stock.id != null) return false;
// if (symbol != null ? !symbol.equals(stock.symbol) : stock.symbol != null) return false;
// if (name != null ? !name.equals(stock.name) : stock.name != null) return false;
// if (lastSale != null ? !lastSale.equals(stock.lastSale) : stock.lastSale != null) return false;
// if (marketCap != null ? !marketCap.equals(stock.marketCap) : stock.marketCap != null) return false;
// if (ipoYear != null ? !ipoYear.equals(stock.ipoYear) : stock.ipoYear != null) return false;
// if (sector != null ? !sector.equals(stock.sector) : stock.sector != null) return false;
// if (industry != null ? !industry.equals(stock.industry) : stock.industry != null) return false;
// return !(summary != null ? !summary.equals(stock.summary) : stock.summary != null);
//
// }
//
// @Override
// public int hashCode() {
// int result = id != null ? id.hashCode() : 0;
// result = 31 * result + (symbol != null ? symbol.hashCode() : 0);
// result = 31 * result + (name != null ? name.hashCode() : 0);
// result = 31 * result + (lastSale != null ? lastSale.hashCode() : 0);
// result = 31 * result + (marketCap != null ? marketCap.hashCode() : 0);
// result = 31 * result + (ipoYear != null ? ipoYear.hashCode() : 0);
// result = 31 * result + (sector != null ? sector.hashCode() : 0);
// result = 31 * result + (industry != null ? industry.hashCode() : 0);
// result = 31 * result + (summary != null ? summary.hashCode() : 0);
// return result;
// }
// }
// Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
import com.stocks.sample.domain.Stock;
package com.stocks.sample.dto;
public class StockDto {
private Long id;
private String name;
private String symbol;
public StockDto() {}
| public StockDto( Stock entity ) { |
keunlee/sample-fullstack-app | backend-java/src/test/java/com/stocks/sample/test/repository/StockRepositoryTest.java | // Path: backend-java/src/main/java/com/stocks/sample/domain/Stock.java
// @Entity
// @Table(name = "stock")
// public class Stock implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// @Id
// @SequenceGenerator(name = "stock_id_seq", sequenceName = "stock_id_seq", allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "stock_id_seq")
// private Long id;
//
// @Column
// private String symbol;
//
// @Column
// private String name;
//
// @Column
// private String lastSale;
//
// @Column
// private String marketCap;
//
// @Column
// private String ipoYear;
//
// @Column
// private String sector;
//
// @Column
// private String industry;
//
// @Column
// private String summary;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// id = id;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getLastSale() {
// return lastSale;
// }
//
// public void setLastSale(String lastSale) {
// this.lastSale = lastSale;
// }
//
// public String getMarketCap() {
// return marketCap;
// }
//
// public void setMarketCap(String marketCap) {
// this.marketCap = marketCap;
// }
//
// public String getIpoYear() {
// return ipoYear;
// }
//
// public void setIpoYear(String ipoYear) {
// this.ipoYear = ipoYear;
// }
//
// public String getSector() {
// return sector;
// }
//
// public void setSector(String sector) {
// this.sector = sector;
// }
//
// public String getIndustry() {
// return industry;
// }
//
// public void setIndustry(String industry) {
// this.industry = industry;
// }
//
// public String getSummary() {
// return summary;
// }
//
// public void setSummary(String summary) {
// this.summary = summary;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Stock stock = (Stock) o;
//
// if (id != null ? !id.equals(stock.id) : stock.id != null) return false;
// if (symbol != null ? !symbol.equals(stock.symbol) : stock.symbol != null) return false;
// if (name != null ? !name.equals(stock.name) : stock.name != null) return false;
// if (lastSale != null ? !lastSale.equals(stock.lastSale) : stock.lastSale != null) return false;
// if (marketCap != null ? !marketCap.equals(stock.marketCap) : stock.marketCap != null) return false;
// if (ipoYear != null ? !ipoYear.equals(stock.ipoYear) : stock.ipoYear != null) return false;
// if (sector != null ? !sector.equals(stock.sector) : stock.sector != null) return false;
// if (industry != null ? !industry.equals(stock.industry) : stock.industry != null) return false;
// return !(summary != null ? !summary.equals(stock.summary) : stock.summary != null);
//
// }
//
// @Override
// public int hashCode() {
// int result = id != null ? id.hashCode() : 0;
// result = 31 * result + (symbol != null ? symbol.hashCode() : 0);
// result = 31 * result + (name != null ? name.hashCode() : 0);
// result = 31 * result + (lastSale != null ? lastSale.hashCode() : 0);
// result = 31 * result + (marketCap != null ? marketCap.hashCode() : 0);
// result = 31 * result + (ipoYear != null ? ipoYear.hashCode() : 0);
// result = 31 * result + (sector != null ? sector.hashCode() : 0);
// result = 31 * result + (industry != null ? industry.hashCode() : 0);
// result = 31 * result + (summary != null ? summary.hashCode() : 0);
// return result;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/repository/StockRepository.java
// public interface StockRepository extends JpaRepository<Stock, Long> {
//
// @Query("select s from Stock s where s.symbol = ?1")
// List<Stock> findBySymbol(String symbol);
//
// @Query("select s from Stock s where upper(s.symbol) like upper(?1) or upper(s.name) like upper(?1) order by s.name asc")
// List<Stock> findByWildCard(String symbol);
// }
//
// Path: backend-java/src/test/java/com/stocks/sample/test/AbstractTestConfiguration.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @WebAppConfiguration
// @ContextConfiguration({"classpath:spring/application-context.xml"})
// @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
// public class AbstractTestConfiguration {
// }
| import com.stocks.sample.domain.Stock;
import com.stocks.sample.repository.StockRepository;
import com.stocks.sample.test.AbstractTestConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; | package com.stocks.sample.test.repository;
public class StockRepositoryTest extends AbstractTestConfiguration {
private static final Logger logger = LoggerFactory.getLogger(StockRepositoryTest.class);
@Autowired | // Path: backend-java/src/main/java/com/stocks/sample/domain/Stock.java
// @Entity
// @Table(name = "stock")
// public class Stock implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// @Id
// @SequenceGenerator(name = "stock_id_seq", sequenceName = "stock_id_seq", allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "stock_id_seq")
// private Long id;
//
// @Column
// private String symbol;
//
// @Column
// private String name;
//
// @Column
// private String lastSale;
//
// @Column
// private String marketCap;
//
// @Column
// private String ipoYear;
//
// @Column
// private String sector;
//
// @Column
// private String industry;
//
// @Column
// private String summary;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// id = id;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getLastSale() {
// return lastSale;
// }
//
// public void setLastSale(String lastSale) {
// this.lastSale = lastSale;
// }
//
// public String getMarketCap() {
// return marketCap;
// }
//
// public void setMarketCap(String marketCap) {
// this.marketCap = marketCap;
// }
//
// public String getIpoYear() {
// return ipoYear;
// }
//
// public void setIpoYear(String ipoYear) {
// this.ipoYear = ipoYear;
// }
//
// public String getSector() {
// return sector;
// }
//
// public void setSector(String sector) {
// this.sector = sector;
// }
//
// public String getIndustry() {
// return industry;
// }
//
// public void setIndustry(String industry) {
// this.industry = industry;
// }
//
// public String getSummary() {
// return summary;
// }
//
// public void setSummary(String summary) {
// this.summary = summary;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Stock stock = (Stock) o;
//
// if (id != null ? !id.equals(stock.id) : stock.id != null) return false;
// if (symbol != null ? !symbol.equals(stock.symbol) : stock.symbol != null) return false;
// if (name != null ? !name.equals(stock.name) : stock.name != null) return false;
// if (lastSale != null ? !lastSale.equals(stock.lastSale) : stock.lastSale != null) return false;
// if (marketCap != null ? !marketCap.equals(stock.marketCap) : stock.marketCap != null) return false;
// if (ipoYear != null ? !ipoYear.equals(stock.ipoYear) : stock.ipoYear != null) return false;
// if (sector != null ? !sector.equals(stock.sector) : stock.sector != null) return false;
// if (industry != null ? !industry.equals(stock.industry) : stock.industry != null) return false;
// return !(summary != null ? !summary.equals(stock.summary) : stock.summary != null);
//
// }
//
// @Override
// public int hashCode() {
// int result = id != null ? id.hashCode() : 0;
// result = 31 * result + (symbol != null ? symbol.hashCode() : 0);
// result = 31 * result + (name != null ? name.hashCode() : 0);
// result = 31 * result + (lastSale != null ? lastSale.hashCode() : 0);
// result = 31 * result + (marketCap != null ? marketCap.hashCode() : 0);
// result = 31 * result + (ipoYear != null ? ipoYear.hashCode() : 0);
// result = 31 * result + (sector != null ? sector.hashCode() : 0);
// result = 31 * result + (industry != null ? industry.hashCode() : 0);
// result = 31 * result + (summary != null ? summary.hashCode() : 0);
// return result;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/repository/StockRepository.java
// public interface StockRepository extends JpaRepository<Stock, Long> {
//
// @Query("select s from Stock s where s.symbol = ?1")
// List<Stock> findBySymbol(String symbol);
//
// @Query("select s from Stock s where upper(s.symbol) like upper(?1) or upper(s.name) like upper(?1) order by s.name asc")
// List<Stock> findByWildCard(String symbol);
// }
//
// Path: backend-java/src/test/java/com/stocks/sample/test/AbstractTestConfiguration.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @WebAppConfiguration
// @ContextConfiguration({"classpath:spring/application-context.xml"})
// @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
// public class AbstractTestConfiguration {
// }
// Path: backend-java/src/test/java/com/stocks/sample/test/repository/StockRepositoryTest.java
import com.stocks.sample.domain.Stock;
import com.stocks.sample.repository.StockRepository;
import com.stocks.sample.test.AbstractTestConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
package com.stocks.sample.test.repository;
public class StockRepositoryTest extends AbstractTestConfiguration {
private static final Logger logger = LoggerFactory.getLogger(StockRepositoryTest.class);
@Autowired | private StockRepository stockRepository; |
keunlee/sample-fullstack-app | backend-java/src/test/java/com/stocks/sample/test/repository/StockRepositoryTest.java | // Path: backend-java/src/main/java/com/stocks/sample/domain/Stock.java
// @Entity
// @Table(name = "stock")
// public class Stock implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// @Id
// @SequenceGenerator(name = "stock_id_seq", sequenceName = "stock_id_seq", allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "stock_id_seq")
// private Long id;
//
// @Column
// private String symbol;
//
// @Column
// private String name;
//
// @Column
// private String lastSale;
//
// @Column
// private String marketCap;
//
// @Column
// private String ipoYear;
//
// @Column
// private String sector;
//
// @Column
// private String industry;
//
// @Column
// private String summary;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// id = id;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getLastSale() {
// return lastSale;
// }
//
// public void setLastSale(String lastSale) {
// this.lastSale = lastSale;
// }
//
// public String getMarketCap() {
// return marketCap;
// }
//
// public void setMarketCap(String marketCap) {
// this.marketCap = marketCap;
// }
//
// public String getIpoYear() {
// return ipoYear;
// }
//
// public void setIpoYear(String ipoYear) {
// this.ipoYear = ipoYear;
// }
//
// public String getSector() {
// return sector;
// }
//
// public void setSector(String sector) {
// this.sector = sector;
// }
//
// public String getIndustry() {
// return industry;
// }
//
// public void setIndustry(String industry) {
// this.industry = industry;
// }
//
// public String getSummary() {
// return summary;
// }
//
// public void setSummary(String summary) {
// this.summary = summary;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Stock stock = (Stock) o;
//
// if (id != null ? !id.equals(stock.id) : stock.id != null) return false;
// if (symbol != null ? !symbol.equals(stock.symbol) : stock.symbol != null) return false;
// if (name != null ? !name.equals(stock.name) : stock.name != null) return false;
// if (lastSale != null ? !lastSale.equals(stock.lastSale) : stock.lastSale != null) return false;
// if (marketCap != null ? !marketCap.equals(stock.marketCap) : stock.marketCap != null) return false;
// if (ipoYear != null ? !ipoYear.equals(stock.ipoYear) : stock.ipoYear != null) return false;
// if (sector != null ? !sector.equals(stock.sector) : stock.sector != null) return false;
// if (industry != null ? !industry.equals(stock.industry) : stock.industry != null) return false;
// return !(summary != null ? !summary.equals(stock.summary) : stock.summary != null);
//
// }
//
// @Override
// public int hashCode() {
// int result = id != null ? id.hashCode() : 0;
// result = 31 * result + (symbol != null ? symbol.hashCode() : 0);
// result = 31 * result + (name != null ? name.hashCode() : 0);
// result = 31 * result + (lastSale != null ? lastSale.hashCode() : 0);
// result = 31 * result + (marketCap != null ? marketCap.hashCode() : 0);
// result = 31 * result + (ipoYear != null ? ipoYear.hashCode() : 0);
// result = 31 * result + (sector != null ? sector.hashCode() : 0);
// result = 31 * result + (industry != null ? industry.hashCode() : 0);
// result = 31 * result + (summary != null ? summary.hashCode() : 0);
// return result;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/repository/StockRepository.java
// public interface StockRepository extends JpaRepository<Stock, Long> {
//
// @Query("select s from Stock s where s.symbol = ?1")
// List<Stock> findBySymbol(String symbol);
//
// @Query("select s from Stock s where upper(s.symbol) like upper(?1) or upper(s.name) like upper(?1) order by s.name asc")
// List<Stock> findByWildCard(String symbol);
// }
//
// Path: backend-java/src/test/java/com/stocks/sample/test/AbstractTestConfiguration.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @WebAppConfiguration
// @ContextConfiguration({"classpath:spring/application-context.xml"})
// @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
// public class AbstractTestConfiguration {
// }
| import com.stocks.sample.domain.Stock;
import com.stocks.sample.repository.StockRepository;
import com.stocks.sample.test.AbstractTestConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; | package com.stocks.sample.test.repository;
public class StockRepositoryTest extends AbstractTestConfiguration {
private static final Logger logger = LoggerFactory.getLogger(StockRepositoryTest.class);
@Autowired
private StockRepository stockRepository;
@Test
@Rollback(value = true)
@Transactional
public void testCreateStock() { | // Path: backend-java/src/main/java/com/stocks/sample/domain/Stock.java
// @Entity
// @Table(name = "stock")
// public class Stock implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// @Id
// @SequenceGenerator(name = "stock_id_seq", sequenceName = "stock_id_seq", allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "stock_id_seq")
// private Long id;
//
// @Column
// private String symbol;
//
// @Column
// private String name;
//
// @Column
// private String lastSale;
//
// @Column
// private String marketCap;
//
// @Column
// private String ipoYear;
//
// @Column
// private String sector;
//
// @Column
// private String industry;
//
// @Column
// private String summary;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// id = id;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public void setSymbol(String symbol) {
// this.symbol = symbol;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getLastSale() {
// return lastSale;
// }
//
// public void setLastSale(String lastSale) {
// this.lastSale = lastSale;
// }
//
// public String getMarketCap() {
// return marketCap;
// }
//
// public void setMarketCap(String marketCap) {
// this.marketCap = marketCap;
// }
//
// public String getIpoYear() {
// return ipoYear;
// }
//
// public void setIpoYear(String ipoYear) {
// this.ipoYear = ipoYear;
// }
//
// public String getSector() {
// return sector;
// }
//
// public void setSector(String sector) {
// this.sector = sector;
// }
//
// public String getIndustry() {
// return industry;
// }
//
// public void setIndustry(String industry) {
// this.industry = industry;
// }
//
// public String getSummary() {
// return summary;
// }
//
// public void setSummary(String summary) {
// this.summary = summary;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Stock stock = (Stock) o;
//
// if (id != null ? !id.equals(stock.id) : stock.id != null) return false;
// if (symbol != null ? !symbol.equals(stock.symbol) : stock.symbol != null) return false;
// if (name != null ? !name.equals(stock.name) : stock.name != null) return false;
// if (lastSale != null ? !lastSale.equals(stock.lastSale) : stock.lastSale != null) return false;
// if (marketCap != null ? !marketCap.equals(stock.marketCap) : stock.marketCap != null) return false;
// if (ipoYear != null ? !ipoYear.equals(stock.ipoYear) : stock.ipoYear != null) return false;
// if (sector != null ? !sector.equals(stock.sector) : stock.sector != null) return false;
// if (industry != null ? !industry.equals(stock.industry) : stock.industry != null) return false;
// return !(summary != null ? !summary.equals(stock.summary) : stock.summary != null);
//
// }
//
// @Override
// public int hashCode() {
// int result = id != null ? id.hashCode() : 0;
// result = 31 * result + (symbol != null ? symbol.hashCode() : 0);
// result = 31 * result + (name != null ? name.hashCode() : 0);
// result = 31 * result + (lastSale != null ? lastSale.hashCode() : 0);
// result = 31 * result + (marketCap != null ? marketCap.hashCode() : 0);
// result = 31 * result + (ipoYear != null ? ipoYear.hashCode() : 0);
// result = 31 * result + (sector != null ? sector.hashCode() : 0);
// result = 31 * result + (industry != null ? industry.hashCode() : 0);
// result = 31 * result + (summary != null ? summary.hashCode() : 0);
// return result;
// }
// }
//
// Path: backend-java/src/main/java/com/stocks/sample/repository/StockRepository.java
// public interface StockRepository extends JpaRepository<Stock, Long> {
//
// @Query("select s from Stock s where s.symbol = ?1")
// List<Stock> findBySymbol(String symbol);
//
// @Query("select s from Stock s where upper(s.symbol) like upper(?1) or upper(s.name) like upper(?1) order by s.name asc")
// List<Stock> findByWildCard(String symbol);
// }
//
// Path: backend-java/src/test/java/com/stocks/sample/test/AbstractTestConfiguration.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @WebAppConfiguration
// @ContextConfiguration({"classpath:spring/application-context.xml"})
// @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
// public class AbstractTestConfiguration {
// }
// Path: backend-java/src/test/java/com/stocks/sample/test/repository/StockRepositoryTest.java
import com.stocks.sample.domain.Stock;
import com.stocks.sample.repository.StockRepository;
import com.stocks.sample.test.AbstractTestConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
package com.stocks.sample.test.repository;
public class StockRepositoryTest extends AbstractTestConfiguration {
private static final Logger logger = LoggerFactory.getLogger(StockRepositoryTest.class);
@Autowired
private StockRepository stockRepository;
@Test
@Rollback(value = true)
@Transactional
public void testCreateStock() { | Stock stock = new Stock(); |
shijiebei2009/Algorithms | src/main/java/cn/codepub/algorithms/strings/ReverseString.java | // Path: src/main/java/cn/codepub/algorithms/utils/StackX.java
// public class StackX<T> {
// private int maxSize;
// private Object[] stackArray;
// private int top;
//
// public StackX() {
//
// }
//
// public StackX(int s) {
// maxSize = s;
// stackArray = new Object[maxSize];
// top = -1;
// }
//
// public void push(T j) {
// stackArray[++top] = j;
// }
//
// public T pop() {
// return (T) stackArray[top--];
// }
//
// public T peek() {
// return (T) stackArray[top];
// }
//
// public boolean isEmpty() {
// return (top == -1);
// }
//
// public int size() {
// return top + 1;
// }
//
// public T peekN(int n) {
// return (T) stackArray[n];
// }
//
// public void displayStack(String s) {
// System.out.print(s);
// System.out.print("Stack(bottom->top):");
// for (int j = 0; j < size(); j++) {
// System.out.print(peekN(j) + " ");
// }
// System.out.println();
// }
// }
| import cn.codepub.algorithms.utils.StackX;
import java.io.BufferedReader;
import java.io.InputStreamReader;
| package cn.codepub.algorithms.strings;
/**
* <p>
* Created with IntelliJ IDEA. 2016/1/8 19:32
* </p>
* <p>
* ClassName:ReverseString
* </p>
* <p>
* Description:反转字符串,例如abc->cba
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class ReverseString {
private String input;
private String output = "";//默认是null,所以此处将""赋值给它
public ReverseString(String in) {
input = in;
}
public String doRev() {
int stackSize = input.length();
| // Path: src/main/java/cn/codepub/algorithms/utils/StackX.java
// public class StackX<T> {
// private int maxSize;
// private Object[] stackArray;
// private int top;
//
// public StackX() {
//
// }
//
// public StackX(int s) {
// maxSize = s;
// stackArray = new Object[maxSize];
// top = -1;
// }
//
// public void push(T j) {
// stackArray[++top] = j;
// }
//
// public T pop() {
// return (T) stackArray[top--];
// }
//
// public T peek() {
// return (T) stackArray[top];
// }
//
// public boolean isEmpty() {
// return (top == -1);
// }
//
// public int size() {
// return top + 1;
// }
//
// public T peekN(int n) {
// return (T) stackArray[n];
// }
//
// public void displayStack(String s) {
// System.out.print(s);
// System.out.print("Stack(bottom->top):");
// for (int j = 0; j < size(); j++) {
// System.out.print(peekN(j) + " ");
// }
// System.out.println();
// }
// }
// Path: src/main/java/cn/codepub/algorithms/strings/ReverseString.java
import cn.codepub.algorithms.utils.StackX;
import java.io.BufferedReader;
import java.io.InputStreamReader;
package cn.codepub.algorithms.strings;
/**
* <p>
* Created with IntelliJ IDEA. 2016/1/8 19:32
* </p>
* <p>
* ClassName:ReverseString
* </p>
* <p>
* Description:反转字符串,例如abc->cba
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class ReverseString {
private String input;
private String output = "";//默认是null,所以此处将""赋值给它
public ReverseString(String in) {
input = in;
}
public String doRev() {
int stackSize = input.length();
| StackX<Character> theStack = new StackX(stackSize);
|
shijiebei2009/Algorithms | src/main/java/cn/codepub/algorithms/trees/TraverseBinaryTree.java | // Path: src/main/java/cn/codepub/algorithms/utils/Tree.java
// public class Tree {
// public Tree left;//左子树
// public Tree right;//右子树
// public int value;//结点值
// public boolean isVisited;//是否访问
//
// public Tree() {
//
// }
//
// public Tree(int value) {
// this.value = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(this.value);
// }
// }
| import cn.codepub.algorithms.utils.Tree;
| package cn.codepub.algorithms.trees;
/**
* <p>
* Created with IntelliJ IDEA. 2015/10/30 14:16
* </p>
* <p>
* ClassName:TraverseTree
* </p>
* <p>
* Description:提供对二叉树的三种遍历方式:先序遍历,中序遍历,后序遍历
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class TraverseBinaryTree {
public static void main(String[] args) {
| // Path: src/main/java/cn/codepub/algorithms/utils/Tree.java
// public class Tree {
// public Tree left;//左子树
// public Tree right;//右子树
// public int value;//结点值
// public boolean isVisited;//是否访问
//
// public Tree() {
//
// }
//
// public Tree(int value) {
// this.value = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(this.value);
// }
// }
// Path: src/main/java/cn/codepub/algorithms/trees/TraverseBinaryTree.java
import cn.codepub.algorithms.utils.Tree;
package cn.codepub.algorithms.trees;
/**
* <p>
* Created with IntelliJ IDEA. 2015/10/30 14:16
* </p>
* <p>
* ClassName:TraverseTree
* </p>
* <p>
* Description:提供对二叉树的三种遍历方式:先序遍历,中序遍历,后序遍历
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class TraverseBinaryTree {
public static void main(String[] args) {
| Tree root = new Tree(1);
|
shijiebei2009/Algorithms | src/main/java/cn/codepub/algorithms/trees/LevelTraverseBinaryTree.java | // Path: src/main/java/cn/codepub/algorithms/utils/Tree.java
// public class Tree {
// public Tree left;//左子树
// public Tree right;//右子树
// public int value;//结点值
// public boolean isVisited;//是否访问
//
// public Tree() {
//
// }
//
// public Tree(int value) {
// this.value = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(this.value);
// }
// }
| import cn.codepub.algorithms.utils.Tree;
import java.util.ArrayDeque;
import java.util.Queue;
| package cn.codepub.algorithms.trees;
/**
* <p>
* Created with IntelliJ IDEA. 2015/10/30 13:38
* </p>
* <p>
* ClassName:LevelTraverseBinaryTree
* </p>
* <p>
* Description:二叉树的层次遍历
* 题目:从上往下打印出二叉树的每个结点,同一层的结点按照从左到右的顺序打印
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class LevelTraverseBinaryTree {
public static void main(String[] args) {
Queue queue = new ArrayDeque<>();
| // Path: src/main/java/cn/codepub/algorithms/utils/Tree.java
// public class Tree {
// public Tree left;//左子树
// public Tree right;//右子树
// public int value;//结点值
// public boolean isVisited;//是否访问
//
// public Tree() {
//
// }
//
// public Tree(int value) {
// this.value = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(this.value);
// }
// }
// Path: src/main/java/cn/codepub/algorithms/trees/LevelTraverseBinaryTree.java
import cn.codepub.algorithms.utils.Tree;
import java.util.ArrayDeque;
import java.util.Queue;
package cn.codepub.algorithms.trees;
/**
* <p>
* Created with IntelliJ IDEA. 2015/10/30 13:38
* </p>
* <p>
* ClassName:LevelTraverseBinaryTree
* </p>
* <p>
* Description:二叉树的层次遍历
* 题目:从上往下打印出二叉树的每个结点,同一层的结点按照从左到右的顺序打印
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class LevelTraverseBinaryTree {
public static void main(String[] args) {
Queue queue = new ArrayDeque<>();
| Tree root = new Tree(1);
|
shijiebei2009/Algorithms | src/main/java/cn/codepub/algorithms/graph/Kruskal.java | // Path: src/main/java/cn/codepub/algorithms/graph/utils/UnionFindSet.java
// public class UnionFindSet {
// public int[] father;//father[i]=i表示本集合且i是集合对应的树的根,father[i]=j表示j是i的父节点
// public int[] rank;//rank[i]代表集合的秩,比如子孙个数或者树的高度等。用于合并集合,秩小的合并到秩大的
// private int DEFAULT_SIZE = 2 << 9;//设置默认值为1024
//
// public UnionFindSet() {
// init();
// }
//
// public UnionFindSet(int size) {
// DEFAULT_SIZE = size;
// init();
// }
//
// /**
// * 利用默认值做初始化工作
// */
// private void init() {
// father = new int[DEFAULT_SIZE];
// rank = new int[DEFAULT_SIZE];
// makeSet();
// }
//
// /**
// * 初始化集合
// */
// public void makeSet() {
// for (int i = 0; i < father.length; i++) {
// father[i] = i;
// rank[i] = 0;
// }
// }
//
// /**
// * 查找一个元素所在的集合,其精髓是找到这个元素所在的集合的祖先,如果需要判断两个元素是否属于同一个集合,只要看他们所在集合的祖先是否相同即可
// *
// * @param x
// * @return
// */
// public int findSet(int x) {
// if (x != father[x]) {
// //在递归查找的时候进行了路径压缩,所谓的路径压缩其实非常简单,就是将该树的祖先置为每个节点的父节点
// father[x] = findSet(father[x]);
// }
// return father[x];
// }
//
// /**
// * 合并树,将秩小的合并到大的
// *
// * @param x
// * @param y
// */
// public void union(int x, int y) {
// x = findSet(x);
// y = findSet(y);
// if (x == y) {
// return;
// }
// if (rank[x] > rank[y]) {
// father[y] = x;
// } else if (rank[x] < rank[y]) {
// father[x] = y;
// } else {//任意合并一个即可
// rank[y]++;
// father[x] = y;
// }
// }
// }
| import cn.codepub.algorithms.graph.utils.UnionFindSet;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
| private static class Edge {
Vertex start;//边的起始点
Vertex end;//边的终结点
int value;//边的权值
public Edge(Vertex a, Vertex b, int val) {
this.start = a;
this.end = b;
this.value = val;
}
@Override
public String toString() {
return "顶点是:" + this.start.name + "-->" + this.end.name + ",权值:" + this.value;
}
}
/**
* 添加边的函数
*
* @param a 起始点
* @param b 终结点
* @param val 边的权值
*/
public static void addEdge(Vertex a, Vertex b, int val) {
Edge edge = new Edge(a, b, val);
edgeList.add(edge);
}
public static void minimumSpanningTree() {
| // Path: src/main/java/cn/codepub/algorithms/graph/utils/UnionFindSet.java
// public class UnionFindSet {
// public int[] father;//father[i]=i表示本集合且i是集合对应的树的根,father[i]=j表示j是i的父节点
// public int[] rank;//rank[i]代表集合的秩,比如子孙个数或者树的高度等。用于合并集合,秩小的合并到秩大的
// private int DEFAULT_SIZE = 2 << 9;//设置默认值为1024
//
// public UnionFindSet() {
// init();
// }
//
// public UnionFindSet(int size) {
// DEFAULT_SIZE = size;
// init();
// }
//
// /**
// * 利用默认值做初始化工作
// */
// private void init() {
// father = new int[DEFAULT_SIZE];
// rank = new int[DEFAULT_SIZE];
// makeSet();
// }
//
// /**
// * 初始化集合
// */
// public void makeSet() {
// for (int i = 0; i < father.length; i++) {
// father[i] = i;
// rank[i] = 0;
// }
// }
//
// /**
// * 查找一个元素所在的集合,其精髓是找到这个元素所在的集合的祖先,如果需要判断两个元素是否属于同一个集合,只要看他们所在集合的祖先是否相同即可
// *
// * @param x
// * @return
// */
// public int findSet(int x) {
// if (x != father[x]) {
// //在递归查找的时候进行了路径压缩,所谓的路径压缩其实非常简单,就是将该树的祖先置为每个节点的父节点
// father[x] = findSet(father[x]);
// }
// return father[x];
// }
//
// /**
// * 合并树,将秩小的合并到大的
// *
// * @param x
// * @param y
// */
// public void union(int x, int y) {
// x = findSet(x);
// y = findSet(y);
// if (x == y) {
// return;
// }
// if (rank[x] > rank[y]) {
// father[y] = x;
// } else if (rank[x] < rank[y]) {
// father[x] = y;
// } else {//任意合并一个即可
// rank[y]++;
// father[x] = y;
// }
// }
// }
// Path: src/main/java/cn/codepub/algorithms/graph/Kruskal.java
import cn.codepub.algorithms.graph.utils.UnionFindSet;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
private static class Edge {
Vertex start;//边的起始点
Vertex end;//边的终结点
int value;//边的权值
public Edge(Vertex a, Vertex b, int val) {
this.start = a;
this.end = b;
this.value = val;
}
@Override
public String toString() {
return "顶点是:" + this.start.name + "-->" + this.end.name + ",权值:" + this.value;
}
}
/**
* 添加边的函数
*
* @param a 起始点
* @param b 终结点
* @param val 边的权值
*/
public static void addEdge(Vertex a, Vertex b, int val) {
Edge edge = new Edge(a, b, val);
edgeList.add(edge);
}
public static void minimumSpanningTree() {
| UnionFindSet unionFindSet = new UnionFindSet(vertexList.size());
|
shijiebei2009/Algorithms | src/main/java/cn/codepub/algorithms/stack/PostfixApp.java | // Path: src/main/java/cn/codepub/algorithms/utils/StackX.java
// public class StackX<T> {
// private int maxSize;
// private Object[] stackArray;
// private int top;
//
// public StackX() {
//
// }
//
// public StackX(int s) {
// maxSize = s;
// stackArray = new Object[maxSize];
// top = -1;
// }
//
// public void push(T j) {
// stackArray[++top] = j;
// }
//
// public T pop() {
// return (T) stackArray[top--];
// }
//
// public T peek() {
// return (T) stackArray[top];
// }
//
// public boolean isEmpty() {
// return (top == -1);
// }
//
// public int size() {
// return top + 1;
// }
//
// public T peekN(int n) {
// return (T) stackArray[n];
// }
//
// public void displayStack(String s) {
// System.out.print(s);
// System.out.print("Stack(bottom->top):");
// for (int j = 0; j < size(); j++) {
// System.out.print(peekN(j) + " ");
// }
// System.out.println();
// }
// }
| import cn.codepub.algorithms.utils.StackX;
import java.io.BufferedReader;
import java.io.InputStreamReader;
| package cn.codepub.algorithms.stack;
/**
* <p>
* Created with IntelliJ IDEA. 2016/1/8 19:04
* </p>
* <p>
* ClassName:PostfixApp
* </p>
* <p>
* Description:求解后缀表达式,For Example<br/>
* Enter postfix:34*2/<br/>
* 3 Stack(bottom->top):<br/>
* 4 Stack(bottom->top):3<br/>
* Stack(bottom->top):3 4<br/>
* 2 Stack(bottom->top):12<br/>
* / Stack(bottom->top):12 2<br/>
* Evaluates to 6<br/>
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class PostfixApp {
public static void main(String[] args) throws Exception {
String input;
int output;
while (true) {
System.out.print("Enter postfix:");
System.out.flush();
input = getString();
if (input.equals("")) {
break;
}
ParsePost aParse = new ParsePost(input);
output = aParse.doParse();
System.out.println("Evaluates to " + output);
}
}
public static String getString() throws Exception {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader buf = new BufferedReader(isr);
String s = buf.readLine();
return s;
}
}
class ParsePost {
| // Path: src/main/java/cn/codepub/algorithms/utils/StackX.java
// public class StackX<T> {
// private int maxSize;
// private Object[] stackArray;
// private int top;
//
// public StackX() {
//
// }
//
// public StackX(int s) {
// maxSize = s;
// stackArray = new Object[maxSize];
// top = -1;
// }
//
// public void push(T j) {
// stackArray[++top] = j;
// }
//
// public T pop() {
// return (T) stackArray[top--];
// }
//
// public T peek() {
// return (T) stackArray[top];
// }
//
// public boolean isEmpty() {
// return (top == -1);
// }
//
// public int size() {
// return top + 1;
// }
//
// public T peekN(int n) {
// return (T) stackArray[n];
// }
//
// public void displayStack(String s) {
// System.out.print(s);
// System.out.print("Stack(bottom->top):");
// for (int j = 0; j < size(); j++) {
// System.out.print(peekN(j) + " ");
// }
// System.out.println();
// }
// }
// Path: src/main/java/cn/codepub/algorithms/stack/PostfixApp.java
import cn.codepub.algorithms.utils.StackX;
import java.io.BufferedReader;
import java.io.InputStreamReader;
package cn.codepub.algorithms.stack;
/**
* <p>
* Created with IntelliJ IDEA. 2016/1/8 19:04
* </p>
* <p>
* ClassName:PostfixApp
* </p>
* <p>
* Description:求解后缀表达式,For Example<br/>
* Enter postfix:34*2/<br/>
* 3 Stack(bottom->top):<br/>
* 4 Stack(bottom->top):3<br/>
* Stack(bottom->top):3 4<br/>
* 2 Stack(bottom->top):12<br/>
* / Stack(bottom->top):12 2<br/>
* Evaluates to 6<br/>
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class PostfixApp {
public static void main(String[] args) throws Exception {
String input;
int output;
while (true) {
System.out.print("Enter postfix:");
System.out.flush();
input = getString();
if (input.equals("")) {
break;
}
ParsePost aParse = new ParsePost(input);
output = aParse.doParse();
System.out.println("Evaluates to " + output);
}
}
public static String getString() throws Exception {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader buf = new BufferedReader(isr);
String s = buf.readLine();
return s;
}
}
class ParsePost {
| private StackX<Integer> theStack;
|
shijiebei2009/Algorithms | src/main/java/cn/codepub/algorithms/stack/BracketsApp.java | // Path: src/main/java/cn/codepub/algorithms/utils/StackX.java
// public class StackX<T> {
// private int maxSize;
// private Object[] stackArray;
// private int top;
//
// public StackX() {
//
// }
//
// public StackX(int s) {
// maxSize = s;
// stackArray = new Object[maxSize];
// top = -1;
// }
//
// public void push(T j) {
// stackArray[++top] = j;
// }
//
// public T pop() {
// return (T) stackArray[top--];
// }
//
// public T peek() {
// return (T) stackArray[top];
// }
//
// public boolean isEmpty() {
// return (top == -1);
// }
//
// public int size() {
// return top + 1;
// }
//
// public T peekN(int n) {
// return (T) stackArray[n];
// }
//
// public void displayStack(String s) {
// System.out.print(s);
// System.out.print("Stack(bottom->top):");
// for (int j = 0; j < size(); j++) {
// System.out.print(peekN(j) + " ");
// }
// System.out.println();
// }
// }
| import cn.codepub.algorithms.utils.StackX;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
| package cn.codepub.algorithms.stack;
/**
* <p>
* Created with IntelliJ IDEA. 2016/1/8 20:17
* </p>
* <p>
* ClassName:BracketsApp
* </p>
* <p>
* Description:判断括号是否匹配,For Example:(((())))
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class BracketsApp {
public static void main(String[] args) throws IOException {
String input;
while (true) {
System.out.println("Enter string containing delimiters:");
System.out.flush();
input = getString();
if (input.equals("")) {
break;
}
BracketChecker theChecker = new BracketChecker(input);
theChecker.check();
}
}
public static String getString() throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String str = br.readLine();
return str;
}
}
class BracketChecker {
private String input;
public BracketChecker(String in) {
this.input = in;
}
public void check() {
int stackSize = input.length();
| // Path: src/main/java/cn/codepub/algorithms/utils/StackX.java
// public class StackX<T> {
// private int maxSize;
// private Object[] stackArray;
// private int top;
//
// public StackX() {
//
// }
//
// public StackX(int s) {
// maxSize = s;
// stackArray = new Object[maxSize];
// top = -1;
// }
//
// public void push(T j) {
// stackArray[++top] = j;
// }
//
// public T pop() {
// return (T) stackArray[top--];
// }
//
// public T peek() {
// return (T) stackArray[top];
// }
//
// public boolean isEmpty() {
// return (top == -1);
// }
//
// public int size() {
// return top + 1;
// }
//
// public T peekN(int n) {
// return (T) stackArray[n];
// }
//
// public void displayStack(String s) {
// System.out.print(s);
// System.out.print("Stack(bottom->top):");
// for (int j = 0; j < size(); j++) {
// System.out.print(peekN(j) + " ");
// }
// System.out.println();
// }
// }
// Path: src/main/java/cn/codepub/algorithms/stack/BracketsApp.java
import cn.codepub.algorithms.utils.StackX;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
package cn.codepub.algorithms.stack;
/**
* <p>
* Created with IntelliJ IDEA. 2016/1/8 20:17
* </p>
* <p>
* ClassName:BracketsApp
* </p>
* <p>
* Description:判断括号是否匹配,For Example:(((())))
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class BracketsApp {
public static void main(String[] args) throws IOException {
String input;
while (true) {
System.out.println("Enter string containing delimiters:");
System.out.flush();
input = getString();
if (input.equals("")) {
break;
}
BracketChecker theChecker = new BracketChecker(input);
theChecker.check();
}
}
public static String getString() throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String str = br.readLine();
return str;
}
}
class BracketChecker {
private String input;
public BracketChecker(String in) {
this.input = in;
}
public void check() {
int stackSize = input.length();
| StackX<Character> theStack = new StackX(stackSize);
|
shijiebei2009/Algorithms | src/main/java/cn/codepub/algorithms/stack/InfixApp.java | // Path: src/main/java/cn/codepub/algorithms/utils/StackX.java
// public class StackX<T> {
// private int maxSize;
// private Object[] stackArray;
// private int top;
//
// public StackX() {
//
// }
//
// public StackX(int s) {
// maxSize = s;
// stackArray = new Object[maxSize];
// top = -1;
// }
//
// public void push(T j) {
// stackArray[++top] = j;
// }
//
// public T pop() {
// return (T) stackArray[top--];
// }
//
// public T peek() {
// return (T) stackArray[top];
// }
//
// public boolean isEmpty() {
// return (top == -1);
// }
//
// public int size() {
// return top + 1;
// }
//
// public T peekN(int n) {
// return (T) stackArray[n];
// }
//
// public void displayStack(String s) {
// System.out.print(s);
// System.out.print("Stack(bottom->top):");
// for (int j = 0; j < size(); j++) {
// System.out.print(peekN(j) + " ");
// }
// System.out.println();
// }
// }
| import cn.codepub.algorithms.utils.StackX;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
| package cn.codepub.algorithms.stack;
/**
* <p>
* Created with IntelliJ IDEA. 2016/1/8 19:16
* </p>
* <p>
* ClassName:InfixApp
* </p>
* <p>
* Description:中缀表达式转后缀表达式,For Example<br/>
* Enter infix:<br/>
* 2+4-4+3*2<br/>
* Postfix is 24+4-32*+<br/>
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class InfixApp {
public static void main(String[] args) throws IOException {
String input, output;
while (true) {
System.out.println("Enter infix:");
System.out.flush();
input = getString();
if (input.equals("")) {
break;
}
InToPost theTrans = new InToPost(input);
output = theTrans.doTrans();
System.out.println("Postfix is " + output + "\n");
}
}
public static String getString() throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
return s;
}
}
class InToPost {
| // Path: src/main/java/cn/codepub/algorithms/utils/StackX.java
// public class StackX<T> {
// private int maxSize;
// private Object[] stackArray;
// private int top;
//
// public StackX() {
//
// }
//
// public StackX(int s) {
// maxSize = s;
// stackArray = new Object[maxSize];
// top = -1;
// }
//
// public void push(T j) {
// stackArray[++top] = j;
// }
//
// public T pop() {
// return (T) stackArray[top--];
// }
//
// public T peek() {
// return (T) stackArray[top];
// }
//
// public boolean isEmpty() {
// return (top == -1);
// }
//
// public int size() {
// return top + 1;
// }
//
// public T peekN(int n) {
// return (T) stackArray[n];
// }
//
// public void displayStack(String s) {
// System.out.print(s);
// System.out.print("Stack(bottom->top):");
// for (int j = 0; j < size(); j++) {
// System.out.print(peekN(j) + " ");
// }
// System.out.println();
// }
// }
// Path: src/main/java/cn/codepub/algorithms/stack/InfixApp.java
import cn.codepub.algorithms.utils.StackX;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
package cn.codepub.algorithms.stack;
/**
* <p>
* Created with IntelliJ IDEA. 2016/1/8 19:16
* </p>
* <p>
* ClassName:InfixApp
* </p>
* <p>
* Description:中缀表达式转后缀表达式,For Example<br/>
* Enter infix:<br/>
* 2+4-4+3*2<br/>
* Postfix is 24+4-32*+<br/>
* </P>
*
* @author Wang Xu
* @version V1.0.0
* @since V1.0.0
*/
public class InfixApp {
public static void main(String[] args) throws IOException {
String input, output;
while (true) {
System.out.println("Enter infix:");
System.out.flush();
input = getString();
if (input.equals("")) {
break;
}
InToPost theTrans = new InToPost(input);
output = theTrans.doTrans();
System.out.println("Postfix is " + output + "\n");
}
}
public static String getString() throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
return s;
}
}
class InToPost {
| private StackX<Character> theStack;
|
robinxdroid/XDroidAnimation | XDroidAnimation/src/com/xdroid/animation/anim/ScaleAnimation.java | // Path: XDroidAnimation/src/com/xdroid/animation/base/AnimationBase.java
// public abstract class AnimationBase<T> implements CombinableMethod<T>{
//
// /** 目标动画view */
// protected View targetView;
//
// /** 插值器 */
// protected TimeInterpolator interpolator;
//
// /** 动画时间 */
// protected long duration;
//
// /** 动画执行回调 */
// protected AnimatorListener listener;
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setInterpolator(TimeInterpolator interpolator) {
// this.interpolator = interpolator;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setDuration(long duration) {
// this.duration = duration;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setListener(AnimatorListener listener) {
// this.listener = listener;
// return (T) this;
// }
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotX(int pivotX) {
// ViewHelper.setPivotX(targetView, pivotX);
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotY(int pivotY) {
// ViewHelper.setPivotY(targetView, pivotY);
// return (T) this;
// }
//
// @Override
// public long getDuration() {
// return duration;
// }
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Duration.java
// public interface Duration {
//
// public static final int DURATION_DEFAULT = 300;
// public static final int DURATION_SHORT = 100;
// public static final int DURATION_LONG = 500;
//
// }
| import com.xdroid.animation.base.AnimationBase;
import com.xdroid.animation.interfaces.Duration;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator; | package com.xdroid.animation.anim;
/**
* Scale animation, the default 0.0 - > 1.0 f f
*
* @author Robin
* @since 2015-07-21 14:40:02
*
*/
public class ScaleAnimation extends AnimationBase<ScaleAnimation>{
/** X direction change of attribute values */
protected float[] valuesX;
/** Y direction change of attribute values */
protected float[] valuesY;
/*
* ==================================================================
* Constructor
* ==================================================================
*/
public ScaleAnimation(View targetView) {
this.targetView = targetView;
interpolator = new AccelerateDecelerateInterpolator(); | // Path: XDroidAnimation/src/com/xdroid/animation/base/AnimationBase.java
// public abstract class AnimationBase<T> implements CombinableMethod<T>{
//
// /** 目标动画view */
// protected View targetView;
//
// /** 插值器 */
// protected TimeInterpolator interpolator;
//
// /** 动画时间 */
// protected long duration;
//
// /** 动画执行回调 */
// protected AnimatorListener listener;
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setInterpolator(TimeInterpolator interpolator) {
// this.interpolator = interpolator;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setDuration(long duration) {
// this.duration = duration;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setListener(AnimatorListener listener) {
// this.listener = listener;
// return (T) this;
// }
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotX(int pivotX) {
// ViewHelper.setPivotX(targetView, pivotX);
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotY(int pivotY) {
// ViewHelper.setPivotY(targetView, pivotY);
// return (T) this;
// }
//
// @Override
// public long getDuration() {
// return duration;
// }
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Duration.java
// public interface Duration {
//
// public static final int DURATION_DEFAULT = 300;
// public static final int DURATION_SHORT = 100;
// public static final int DURATION_LONG = 500;
//
// }
// Path: XDroidAnimation/src/com/xdroid/animation/anim/ScaleAnimation.java
import com.xdroid.animation.base.AnimationBase;
import com.xdroid.animation.interfaces.Duration;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
package com.xdroid.animation.anim;
/**
* Scale animation, the default 0.0 - > 1.0 f f
*
* @author Robin
* @since 2015-07-21 14:40:02
*
*/
public class ScaleAnimation extends AnimationBase<ScaleAnimation>{
/** X direction change of attribute values */
protected float[] valuesX;
/** Y direction change of attribute values */
protected float[] valuesY;
/*
* ==================================================================
* Constructor
* ==================================================================
*/
public ScaleAnimation(View targetView) {
this.targetView = targetView;
interpolator = new AccelerateDecelerateInterpolator(); | duration = Duration.DURATION_LONG; |
robinxdroid/XDroidAnimation | XDroidAnimation/src/com/xdroid/animation/anim/AlphaAnimation.java | // Path: XDroidAnimation/src/com/xdroid/animation/base/AnimationBase.java
// public abstract class AnimationBase<T> implements CombinableMethod<T>{
//
// /** 目标动画view */
// protected View targetView;
//
// /** 插值器 */
// protected TimeInterpolator interpolator;
//
// /** 动画时间 */
// protected long duration;
//
// /** 动画执行回调 */
// protected AnimatorListener listener;
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setInterpolator(TimeInterpolator interpolator) {
// this.interpolator = interpolator;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setDuration(long duration) {
// this.duration = duration;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setListener(AnimatorListener listener) {
// this.listener = listener;
// return (T) this;
// }
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotX(int pivotX) {
// ViewHelper.setPivotX(targetView, pivotX);
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotY(int pivotY) {
// ViewHelper.setPivotY(targetView, pivotY);
// return (T) this;
// }
//
// @Override
// public long getDuration() {
// return duration;
// }
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Duration.java
// public interface Duration {
//
// public static final int DURATION_DEFAULT = 300;
// public static final int DURATION_SHORT = 100;
// public static final int DURATION_LONG = 500;
//
// }
| import com.xdroid.animation.base.AnimationBase;
import com.xdroid.animation.interfaces.Duration;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator; | package com.xdroid.animation.anim;
/**
* Alpha animation
*
* @author Robin
* @since2015-07-31 10:25:38
*
*/
public class AlphaAnimation extends AnimationBase<AlphaAnimation>{
/** The gradient change of attribute values */
protected float[] values;
/*
* ==================================================================
* Constructor
* ==================================================================
*/
public AlphaAnimation(View targetView) {
this.targetView = targetView;
interpolator = new AccelerateDecelerateInterpolator(); | // Path: XDroidAnimation/src/com/xdroid/animation/base/AnimationBase.java
// public abstract class AnimationBase<T> implements CombinableMethod<T>{
//
// /** 目标动画view */
// protected View targetView;
//
// /** 插值器 */
// protected TimeInterpolator interpolator;
//
// /** 动画时间 */
// protected long duration;
//
// /** 动画执行回调 */
// protected AnimatorListener listener;
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setInterpolator(TimeInterpolator interpolator) {
// this.interpolator = interpolator;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setDuration(long duration) {
// this.duration = duration;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setListener(AnimatorListener listener) {
// this.listener = listener;
// return (T) this;
// }
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotX(int pivotX) {
// ViewHelper.setPivotX(targetView, pivotX);
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotY(int pivotY) {
// ViewHelper.setPivotY(targetView, pivotY);
// return (T) this;
// }
//
// @Override
// public long getDuration() {
// return duration;
// }
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Duration.java
// public interface Duration {
//
// public static final int DURATION_DEFAULT = 300;
// public static final int DURATION_SHORT = 100;
// public static final int DURATION_LONG = 500;
//
// }
// Path: XDroidAnimation/src/com/xdroid/animation/anim/AlphaAnimation.java
import com.xdroid.animation.base.AnimationBase;
import com.xdroid.animation.interfaces.Duration;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
package com.xdroid.animation.anim;
/**
* Alpha animation
*
* @author Robin
* @since2015-07-31 10:25:38
*
*/
public class AlphaAnimation extends AnimationBase<AlphaAnimation>{
/** The gradient change of attribute values */
protected float[] values;
/*
* ==================================================================
* Constructor
* ==================================================================
*/
public AlphaAnimation(View targetView) {
this.targetView = targetView;
interpolator = new AccelerateDecelerateInterpolator(); | duration = Duration.DURATION_LONG; |
robinxdroid/XDroidAnimation | XDroidAnimation/src/com/xdroid/animation/anim/BlindAnimation.java | // Path: XDroidAnimation/src/com/xdroid/animation/base/AnimationBase.java
// public abstract class AnimationBase<T> implements CombinableMethod<T>{
//
// /** 目标动画view */
// protected View targetView;
//
// /** 插值器 */
// protected TimeInterpolator interpolator;
//
// /** 动画时间 */
// protected long duration;
//
// /** 动画执行回调 */
// protected AnimatorListener listener;
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setInterpolator(TimeInterpolator interpolator) {
// this.interpolator = interpolator;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setDuration(long duration) {
// this.duration = duration;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setListener(AnimatorListener listener) {
// this.listener = listener;
// return (T) this;
// }
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotX(int pivotX) {
// ViewHelper.setPivotX(targetView, pivotX);
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotY(int pivotY) {
// ViewHelper.setPivotY(targetView, pivotY);
// return (T) this;
// }
//
// @Override
// public long getDuration() {
// return duration;
// }
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Direction.java
// public interface Direction {
//
// public static final int DIRECTION_LEFT = 0x01;
// public static final int DIRECTION_RIGHT = 0x02;
// public static final int DIRECTION_UP = 0x03;
// public static final int DIRECTION_DOWN = 0x04;
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Duration.java
// public interface Duration {
//
// public static final int DURATION_DEFAULT = 300;
// public static final int DURATION_SHORT = 100;
// public static final int DURATION_LONG = 500;
//
// }
| import com.xdroid.animation.base.AnimationBase;
import com.xdroid.animation.interfaces.Direction;
import com.xdroid.animation.interfaces.Duration;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.FrameLayout; | package com.xdroid.animation.anim;
/**
* Blind Animation ,Similar to the shutter
*
* @author Robin
* @since 2015-08-05 19:28:58
*
*/
public class BlindAnimation extends AnimationBase<BlindAnimation>{
private int direction = Direction.DIRECTION_UP;
int blindMode = BlindMode.IN;
public interface BlindMode {
public static final int IN = 0x01, OUT = 0x02;
}
/*
* ==================================================================
* Constructor
* ==================================================================
*/
public BlindAnimation(View targetView) {
this.targetView = targetView;
interpolator = new AccelerateDecelerateInterpolator(); | // Path: XDroidAnimation/src/com/xdroid/animation/base/AnimationBase.java
// public abstract class AnimationBase<T> implements CombinableMethod<T>{
//
// /** 目标动画view */
// protected View targetView;
//
// /** 插值器 */
// protected TimeInterpolator interpolator;
//
// /** 动画时间 */
// protected long duration;
//
// /** 动画执行回调 */
// protected AnimatorListener listener;
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setInterpolator(TimeInterpolator interpolator) {
// this.interpolator = interpolator;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setDuration(long duration) {
// this.duration = duration;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setListener(AnimatorListener listener) {
// this.listener = listener;
// return (T) this;
// }
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotX(int pivotX) {
// ViewHelper.setPivotX(targetView, pivotX);
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotY(int pivotY) {
// ViewHelper.setPivotY(targetView, pivotY);
// return (T) this;
// }
//
// @Override
// public long getDuration() {
// return duration;
// }
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Direction.java
// public interface Direction {
//
// public static final int DIRECTION_LEFT = 0x01;
// public static final int DIRECTION_RIGHT = 0x02;
// public static final int DIRECTION_UP = 0x03;
// public static final int DIRECTION_DOWN = 0x04;
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Duration.java
// public interface Duration {
//
// public static final int DURATION_DEFAULT = 300;
// public static final int DURATION_SHORT = 100;
// public static final int DURATION_LONG = 500;
//
// }
// Path: XDroidAnimation/src/com/xdroid/animation/anim/BlindAnimation.java
import com.xdroid.animation.base.AnimationBase;
import com.xdroid.animation.interfaces.Direction;
import com.xdroid.animation.interfaces.Duration;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.FrameLayout;
package com.xdroid.animation.anim;
/**
* Blind Animation ,Similar to the shutter
*
* @author Robin
* @since 2015-08-05 19:28:58
*
*/
public class BlindAnimation extends AnimationBase<BlindAnimation>{
private int direction = Direction.DIRECTION_UP;
int blindMode = BlindMode.IN;
public interface BlindMode {
public static final int IN = 0x01, OUT = 0x02;
}
/*
* ==================================================================
* Constructor
* ==================================================================
*/
public BlindAnimation(View targetView) {
this.targetView = targetView;
interpolator = new AccelerateDecelerateInterpolator(); | duration = Duration.DURATION_LONG; |
robinxdroid/XDroidAnimation | XDroidAnimation/src/com/xdroid/animation/anim/svg/SVG.java | // Path: XDroidAnimation/src/com/xdroid/animation/anim/svg/CSSParser.java
// public static class Ruleset
// {
// private List<Rule> rules = null;
//
// // Add a rule to the ruleset. The position at which it is inserted is determined by its specificity value.
// public void add(Rule rule)
// {
// if (this.rules == null)
// this.rules = new ArrayList<Rule>();
// for (int i = 0; i < rules.size(); i++)
// {
// Rule nextRule = rules.get(i);
// if (nextRule.selector.specificity > rule.selector.specificity) {
// rules.add(i, rule);
// return;
// }
// }
// rules.add(rule);
// }
//
// public void addAll(Ruleset rules)
// {
// if (rules.rules == null)
// return;
// if (this.rules == null)
// this.rules = new ArrayList<Rule>(rules.rules.size());
// for (Rule rule: rules.rules) {
// this.rules.add(rule);
// }
// }
//
// public List<Rule> getRules()
// {
// return this.rules;
// }
//
// public boolean isEmpty()
// {
// return this.rules == null || this.rules.isEmpty();
// }
//
// @Override
// public String toString()
// {
// if (rules == null)
// return "";
// StringBuilder sb = new StringBuilder();
// for (Rule rule: rules)
// sb.append(rule.toString()).append('\n');
// return sb.toString();
// }
// }
| import android.content.res.AssetManager;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Picture;
import android.graphics.RectF;
import android.util.Log;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.xml.sax.SAXException;
import com.xdroid.animation.anim.svg.CSSParser.Ruleset;
import android.content.Context; | /*
Copyright 2013 Paul LeBeau, Cave Rock Software Ltd.
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 com.xdroid.animation.anim.svg;
/**
* AndroidSVG is a library for reading, parsing and rendering SVG documents on Android devices.
* <p/>
* All interaction with AndroidSVG is via this class.
* <p/>
* Typically, you will call one of the SVG loading and parsing classes then call the renderer,
* passing it a canvas to draw upon.
* <p/>
* <h4>Usage summary</h4>
* <p/>
* <ul>
* <li>Use one of the static {@code getFromX()} methods to read and parse the SVG file. They will
* return an instance of this class.
* <li>Call one of the {@code renderToX()} methods to render the document.
* </ul>
* <p/>
* <h4>Usage example</h4>
* <p/>
* <pre>
* {@code
* SVG svg = SVG.getFromAsset(getContext().getAssets(), svgPath);
* svg.registerExternalFileResolver(myResolver);
*
* Bitmap newBM = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
* Canvas bmcanvas = new Canvas(newBM);
* bmcanvas.drawRGB(255, 255, 255); // Clear background to white
*
* svg.renderToCanvas(bmcanvas);
* }
* </pre>
* <p/>
* For more detailed information on how to use this library, see the documentation at {@code http://code.google
* .com/p/androidsvg/}
*/
public class SVG {
private static final String TAG = "AndroidSVG";
private static final String VERSION = "1.2.0";
protected static final String SUPPORTED_SVG_VERSION = "1.2";
private static final int DEFAULT_PICTURE_WIDTH = 512;
private static final int DEFAULT_PICTURE_HEIGHT = 512;
private static final double SQRT2 = 1.414213562373095;
private static final List<SvgObject> EMPTY_CHILD_LIST = new ArrayList<SvgObject>(0);
private Svg rootElement = null;
// Metadata
private String title = "";
private String desc = "";
// Resolver
private SVGExternalFileResolver fileResolver = null;
// DPI to use for rendering
private float renderDPI = 96f; // default is 96
// CSS rules | // Path: XDroidAnimation/src/com/xdroid/animation/anim/svg/CSSParser.java
// public static class Ruleset
// {
// private List<Rule> rules = null;
//
// // Add a rule to the ruleset. The position at which it is inserted is determined by its specificity value.
// public void add(Rule rule)
// {
// if (this.rules == null)
// this.rules = new ArrayList<Rule>();
// for (int i = 0; i < rules.size(); i++)
// {
// Rule nextRule = rules.get(i);
// if (nextRule.selector.specificity > rule.selector.specificity) {
// rules.add(i, rule);
// return;
// }
// }
// rules.add(rule);
// }
//
// public void addAll(Ruleset rules)
// {
// if (rules.rules == null)
// return;
// if (this.rules == null)
// this.rules = new ArrayList<Rule>(rules.rules.size());
// for (Rule rule: rules.rules) {
// this.rules.add(rule);
// }
// }
//
// public List<Rule> getRules()
// {
// return this.rules;
// }
//
// public boolean isEmpty()
// {
// return this.rules == null || this.rules.isEmpty();
// }
//
// @Override
// public String toString()
// {
// if (rules == null)
// return "";
// StringBuilder sb = new StringBuilder();
// for (Rule rule: rules)
// sb.append(rule.toString()).append('\n');
// return sb.toString();
// }
// }
// Path: XDroidAnimation/src/com/xdroid/animation/anim/svg/SVG.java
import android.content.res.AssetManager;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Picture;
import android.graphics.RectF;
import android.util.Log;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.xml.sax.SAXException;
import com.xdroid.animation.anim.svg.CSSParser.Ruleset;
import android.content.Context;
/*
Copyright 2013 Paul LeBeau, Cave Rock Software Ltd.
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 com.xdroid.animation.anim.svg;
/**
* AndroidSVG is a library for reading, parsing and rendering SVG documents on Android devices.
* <p/>
* All interaction with AndroidSVG is via this class.
* <p/>
* Typically, you will call one of the SVG loading and parsing classes then call the renderer,
* passing it a canvas to draw upon.
* <p/>
* <h4>Usage summary</h4>
* <p/>
* <ul>
* <li>Use one of the static {@code getFromX()} methods to read and parse the SVG file. They will
* return an instance of this class.
* <li>Call one of the {@code renderToX()} methods to render the document.
* </ul>
* <p/>
* <h4>Usage example</h4>
* <p/>
* <pre>
* {@code
* SVG svg = SVG.getFromAsset(getContext().getAssets(), svgPath);
* svg.registerExternalFileResolver(myResolver);
*
* Bitmap newBM = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
* Canvas bmcanvas = new Canvas(newBM);
* bmcanvas.drawRGB(255, 255, 255); // Clear background to white
*
* svg.renderToCanvas(bmcanvas);
* }
* </pre>
* <p/>
* For more detailed information on how to use this library, see the documentation at {@code http://code.google
* .com/p/androidsvg/}
*/
public class SVG {
private static final String TAG = "AndroidSVG";
private static final String VERSION = "1.2.0";
protected static final String SUPPORTED_SVG_VERSION = "1.2";
private static final int DEFAULT_PICTURE_WIDTH = 512;
private static final int DEFAULT_PICTURE_HEIGHT = 512;
private static final double SQRT2 = 1.414213562373095;
private static final List<SvgObject> EMPTY_CHILD_LIST = new ArrayList<SvgObject>(0);
private Svg rootElement = null;
// Metadata
private String title = "";
private String desc = "";
// Resolver
private SVGExternalFileResolver fileResolver = null;
// DPI to use for rendering
private float renderDPI = 96f; // default is 96
// CSS rules | private Ruleset cssRules = new Ruleset(); |
robinxdroid/XDroidAnimation | XDroidAnimationExample/src/com/xdroid/animation/sample/interpolate/EaseAdapter.java | // Path: XDroidAnimationExample/src/com/xdroid/animation/sample/view/CursorView.java
// public class CursorView extends View {
// public int width;
// public int height;
//
// private Context context;
// private Paint paint;
// private Path path;
//
// public CursorView(Context context) {
// this(context, null);
// }
//
// public CursorView(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.context = context;
// init();
// }
//
// private void init() {
// width = dip2px(20); //from layout
// height = dip2px(8); //from layout
//
// paint = new Paint();
// paint.setAntiAlias(true);
// paint.setStrokeWidth(1);
// paint.setStyle(Paint.Style.FILL);
// paint.setColor(Color.RED);
//
// path = new Path();
// path.moveTo(0, height / 2);
// path.lineTo(width / 5, 0);
// path.lineTo(width, 0);
// path.lineTo(width, height);
// path.lineTo(width / 5, height);
// path.close();
// }
//
// @Override
// protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
// canvas.drawPath(path, paint);
// }
//
// private int dip2px(float dpValue) {
// final float scale = context.getResources()
// .getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
// }
//
// Path: XDroidAnimationExample/src/com/xdroid/animation/sample/view/EaseView.java
// public class EaseView extends View {
// public int width;
// public int height;
// public int blankTB;//blank of top or bottom
// public int blankLR;//blank of left or right
//
// private Context context;
// private Paint linePaint;
// private Paint pathPaint;
// private Path path;
//
// public EaseView(Context context) {
// this(context, null);
// }
//
// public EaseView(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.context = context;
// init();
// }
//
// private void init() {
// width = dip2px(100); //from layout
// height = dip2px(100); //from layout
// blankTB = height * 2 / 7;
// blankLR = 0;
//
// linePaint = new Paint();
// linePaint.setAntiAlias(true);
// linePaint.setStrokeWidth(1);
// linePaint.setStyle(Paint.Style.STROKE);
// linePaint.setColor(Color.DKGRAY);
//
// pathPaint = new Paint();
// pathPaint.setAntiAlias(true);
// pathPaint.setStrokeWidth(2);
// pathPaint.setStyle(Paint.Style.STROKE);
// pathPaint.setColor(Color.RED);
//
// path = new Path();
// }
//
// public void setDurationAndInterpolator(long duration, Interpolator interpolator) {
// if (duration <= 0)
// return;
// if (interpolator == null)
// return;
//
// int w = width - blankLR * 2;
// int h = height - blankTB * 2;
//
// path.reset();
// path.moveTo(blankLR, height-blankTB);
// int factor = (int)(duration / w + (duration % w > 0 ? 1 : 0));
// int i = 0;
// for (; i < duration; i += factor) {
// path.lineTo(i/factor + blankLR, h - interpolator.getInterpolation((float)i / duration) * h + blankTB);
// }
// path.lineTo(i/factor + blankLR, blankTB);
//
// invalidate();
// }
//
// @Override
// protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
// canvas.drawLine(0, blankTB, width, blankTB, linePaint);
// canvas.drawLine(0, height-blankTB, width, height-blankTB, linePaint);
//
// canvas.drawPath(path, pathPaint);
// }
//
// private int dip2px(float dpValue) {
// final float scale = context.getResources()
// .getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
// }
| import java.util.List;
import com.xdroid.animation.sample.R;
import com.xdroid.animation.sample.view.CursorView;
import com.xdroid.animation.sample.view.EaseView;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Interpolator;
import android.view.animation.TranslateAnimation;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView; | package com.xdroid.animation.sample.interpolate;
/**
* Created by cimi on 15/7/7.
*/
public class EaseAdapter extends BaseAdapter {
private Context mContext;
private LayoutInflater mInflater;
private List<String> mNameList;
private List<Interpolator> mInterpolatorList;
private long duration;
private int selectIndex = -1;
public EaseAdapter(Context context, List<String> nameList, List<Interpolator> interpolatorList, long duration) {
mContext = context;
mInflater = LayoutInflater.from(context);
mNameList = nameList;
mInterpolatorList = interpolatorList;
this.duration = duration;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
mHolder = new ViewHolder();
convertView = mInflater.inflate(R.layout.adapter, null);
convertView.setBackgroundColor(Color.WHITE);
mHolder.easeName = (TextView) convertView.findViewById(R.id.easeName); | // Path: XDroidAnimationExample/src/com/xdroid/animation/sample/view/CursorView.java
// public class CursorView extends View {
// public int width;
// public int height;
//
// private Context context;
// private Paint paint;
// private Path path;
//
// public CursorView(Context context) {
// this(context, null);
// }
//
// public CursorView(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.context = context;
// init();
// }
//
// private void init() {
// width = dip2px(20); //from layout
// height = dip2px(8); //from layout
//
// paint = new Paint();
// paint.setAntiAlias(true);
// paint.setStrokeWidth(1);
// paint.setStyle(Paint.Style.FILL);
// paint.setColor(Color.RED);
//
// path = new Path();
// path.moveTo(0, height / 2);
// path.lineTo(width / 5, 0);
// path.lineTo(width, 0);
// path.lineTo(width, height);
// path.lineTo(width / 5, height);
// path.close();
// }
//
// @Override
// protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
// canvas.drawPath(path, paint);
// }
//
// private int dip2px(float dpValue) {
// final float scale = context.getResources()
// .getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
// }
//
// Path: XDroidAnimationExample/src/com/xdroid/animation/sample/view/EaseView.java
// public class EaseView extends View {
// public int width;
// public int height;
// public int blankTB;//blank of top or bottom
// public int blankLR;//blank of left or right
//
// private Context context;
// private Paint linePaint;
// private Paint pathPaint;
// private Path path;
//
// public EaseView(Context context) {
// this(context, null);
// }
//
// public EaseView(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.context = context;
// init();
// }
//
// private void init() {
// width = dip2px(100); //from layout
// height = dip2px(100); //from layout
// blankTB = height * 2 / 7;
// blankLR = 0;
//
// linePaint = new Paint();
// linePaint.setAntiAlias(true);
// linePaint.setStrokeWidth(1);
// linePaint.setStyle(Paint.Style.STROKE);
// linePaint.setColor(Color.DKGRAY);
//
// pathPaint = new Paint();
// pathPaint.setAntiAlias(true);
// pathPaint.setStrokeWidth(2);
// pathPaint.setStyle(Paint.Style.STROKE);
// pathPaint.setColor(Color.RED);
//
// path = new Path();
// }
//
// public void setDurationAndInterpolator(long duration, Interpolator interpolator) {
// if (duration <= 0)
// return;
// if (interpolator == null)
// return;
//
// int w = width - blankLR * 2;
// int h = height - blankTB * 2;
//
// path.reset();
// path.moveTo(blankLR, height-blankTB);
// int factor = (int)(duration / w + (duration % w > 0 ? 1 : 0));
// int i = 0;
// for (; i < duration; i += factor) {
// path.lineTo(i/factor + blankLR, h - interpolator.getInterpolation((float)i / duration) * h + blankTB);
// }
// path.lineTo(i/factor + blankLR, blankTB);
//
// invalidate();
// }
//
// @Override
// protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
// canvas.drawLine(0, blankTB, width, blankTB, linePaint);
// canvas.drawLine(0, height-blankTB, width, height-blankTB, linePaint);
//
// canvas.drawPath(path, pathPaint);
// }
//
// private int dip2px(float dpValue) {
// final float scale = context.getResources()
// .getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
// }
// Path: XDroidAnimationExample/src/com/xdroid/animation/sample/interpolate/EaseAdapter.java
import java.util.List;
import com.xdroid.animation.sample.R;
import com.xdroid.animation.sample.view.CursorView;
import com.xdroid.animation.sample.view.EaseView;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Interpolator;
import android.view.animation.TranslateAnimation;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
package com.xdroid.animation.sample.interpolate;
/**
* Created by cimi on 15/7/7.
*/
public class EaseAdapter extends BaseAdapter {
private Context mContext;
private LayoutInflater mInflater;
private List<String> mNameList;
private List<Interpolator> mInterpolatorList;
private long duration;
private int selectIndex = -1;
public EaseAdapter(Context context, List<String> nameList, List<Interpolator> interpolatorList, long duration) {
mContext = context;
mInflater = LayoutInflater.from(context);
mNameList = nameList;
mInterpolatorList = interpolatorList;
this.duration = duration;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
mHolder = new ViewHolder();
convertView = mInflater.inflate(R.layout.adapter, null);
convertView.setBackgroundColor(Color.WHITE);
mHolder.easeName = (TextView) convertView.findViewById(R.id.easeName); | mHolder.easeView = (EaseView) convertView.findViewById(R.id.easeView); |
robinxdroid/XDroidAnimation | XDroidAnimationExample/src/com/xdroid/animation/sample/interpolate/EaseAdapter.java | // Path: XDroidAnimationExample/src/com/xdroid/animation/sample/view/CursorView.java
// public class CursorView extends View {
// public int width;
// public int height;
//
// private Context context;
// private Paint paint;
// private Path path;
//
// public CursorView(Context context) {
// this(context, null);
// }
//
// public CursorView(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.context = context;
// init();
// }
//
// private void init() {
// width = dip2px(20); //from layout
// height = dip2px(8); //from layout
//
// paint = new Paint();
// paint.setAntiAlias(true);
// paint.setStrokeWidth(1);
// paint.setStyle(Paint.Style.FILL);
// paint.setColor(Color.RED);
//
// path = new Path();
// path.moveTo(0, height / 2);
// path.lineTo(width / 5, 0);
// path.lineTo(width, 0);
// path.lineTo(width, height);
// path.lineTo(width / 5, height);
// path.close();
// }
//
// @Override
// protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
// canvas.drawPath(path, paint);
// }
//
// private int dip2px(float dpValue) {
// final float scale = context.getResources()
// .getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
// }
//
// Path: XDroidAnimationExample/src/com/xdroid/animation/sample/view/EaseView.java
// public class EaseView extends View {
// public int width;
// public int height;
// public int blankTB;//blank of top or bottom
// public int blankLR;//blank of left or right
//
// private Context context;
// private Paint linePaint;
// private Paint pathPaint;
// private Path path;
//
// public EaseView(Context context) {
// this(context, null);
// }
//
// public EaseView(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.context = context;
// init();
// }
//
// private void init() {
// width = dip2px(100); //from layout
// height = dip2px(100); //from layout
// blankTB = height * 2 / 7;
// blankLR = 0;
//
// linePaint = new Paint();
// linePaint.setAntiAlias(true);
// linePaint.setStrokeWidth(1);
// linePaint.setStyle(Paint.Style.STROKE);
// linePaint.setColor(Color.DKGRAY);
//
// pathPaint = new Paint();
// pathPaint.setAntiAlias(true);
// pathPaint.setStrokeWidth(2);
// pathPaint.setStyle(Paint.Style.STROKE);
// pathPaint.setColor(Color.RED);
//
// path = new Path();
// }
//
// public void setDurationAndInterpolator(long duration, Interpolator interpolator) {
// if (duration <= 0)
// return;
// if (interpolator == null)
// return;
//
// int w = width - blankLR * 2;
// int h = height - blankTB * 2;
//
// path.reset();
// path.moveTo(blankLR, height-blankTB);
// int factor = (int)(duration / w + (duration % w > 0 ? 1 : 0));
// int i = 0;
// for (; i < duration; i += factor) {
// path.lineTo(i/factor + blankLR, h - interpolator.getInterpolation((float)i / duration) * h + blankTB);
// }
// path.lineTo(i/factor + blankLR, blankTB);
//
// invalidate();
// }
//
// @Override
// protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
// canvas.drawLine(0, blankTB, width, blankTB, linePaint);
// canvas.drawLine(0, height-blankTB, width, height-blankTB, linePaint);
//
// canvas.drawPath(path, pathPaint);
// }
//
// private int dip2px(float dpValue) {
// final float scale = context.getResources()
// .getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
// }
| import java.util.List;
import com.xdroid.animation.sample.R;
import com.xdroid.animation.sample.view.CursorView;
import com.xdroid.animation.sample.view.EaseView;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Interpolator;
import android.view.animation.TranslateAnimation;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView; | package com.xdroid.animation.sample.interpolate;
/**
* Created by cimi on 15/7/7.
*/
public class EaseAdapter extends BaseAdapter {
private Context mContext;
private LayoutInflater mInflater;
private List<String> mNameList;
private List<Interpolator> mInterpolatorList;
private long duration;
private int selectIndex = -1;
public EaseAdapter(Context context, List<String> nameList, List<Interpolator> interpolatorList, long duration) {
mContext = context;
mInflater = LayoutInflater.from(context);
mNameList = nameList;
mInterpolatorList = interpolatorList;
this.duration = duration;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
mHolder = new ViewHolder();
convertView = mInflater.inflate(R.layout.adapter, null);
convertView.setBackgroundColor(Color.WHITE);
mHolder.easeName = (TextView) convertView.findViewById(R.id.easeName);
mHolder.easeView = (EaseView) convertView.findViewById(R.id.easeView); | // Path: XDroidAnimationExample/src/com/xdroid/animation/sample/view/CursorView.java
// public class CursorView extends View {
// public int width;
// public int height;
//
// private Context context;
// private Paint paint;
// private Path path;
//
// public CursorView(Context context) {
// this(context, null);
// }
//
// public CursorView(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.context = context;
// init();
// }
//
// private void init() {
// width = dip2px(20); //from layout
// height = dip2px(8); //from layout
//
// paint = new Paint();
// paint.setAntiAlias(true);
// paint.setStrokeWidth(1);
// paint.setStyle(Paint.Style.FILL);
// paint.setColor(Color.RED);
//
// path = new Path();
// path.moveTo(0, height / 2);
// path.lineTo(width / 5, 0);
// path.lineTo(width, 0);
// path.lineTo(width, height);
// path.lineTo(width / 5, height);
// path.close();
// }
//
// @Override
// protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
// canvas.drawPath(path, paint);
// }
//
// private int dip2px(float dpValue) {
// final float scale = context.getResources()
// .getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
// }
//
// Path: XDroidAnimationExample/src/com/xdroid/animation/sample/view/EaseView.java
// public class EaseView extends View {
// public int width;
// public int height;
// public int blankTB;//blank of top or bottom
// public int blankLR;//blank of left or right
//
// private Context context;
// private Paint linePaint;
// private Paint pathPaint;
// private Path path;
//
// public EaseView(Context context) {
// this(context, null);
// }
//
// public EaseView(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.context = context;
// init();
// }
//
// private void init() {
// width = dip2px(100); //from layout
// height = dip2px(100); //from layout
// blankTB = height * 2 / 7;
// blankLR = 0;
//
// linePaint = new Paint();
// linePaint.setAntiAlias(true);
// linePaint.setStrokeWidth(1);
// linePaint.setStyle(Paint.Style.STROKE);
// linePaint.setColor(Color.DKGRAY);
//
// pathPaint = new Paint();
// pathPaint.setAntiAlias(true);
// pathPaint.setStrokeWidth(2);
// pathPaint.setStyle(Paint.Style.STROKE);
// pathPaint.setColor(Color.RED);
//
// path = new Path();
// }
//
// public void setDurationAndInterpolator(long duration, Interpolator interpolator) {
// if (duration <= 0)
// return;
// if (interpolator == null)
// return;
//
// int w = width - blankLR * 2;
// int h = height - blankTB * 2;
//
// path.reset();
// path.moveTo(blankLR, height-blankTB);
// int factor = (int)(duration / w + (duration % w > 0 ? 1 : 0));
// int i = 0;
// for (; i < duration; i += factor) {
// path.lineTo(i/factor + blankLR, h - interpolator.getInterpolation((float)i / duration) * h + blankTB);
// }
// path.lineTo(i/factor + blankLR, blankTB);
//
// invalidate();
// }
//
// @Override
// protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
// canvas.drawLine(0, blankTB, width, blankTB, linePaint);
// canvas.drawLine(0, height-blankTB, width, height-blankTB, linePaint);
//
// canvas.drawPath(path, pathPaint);
// }
//
// private int dip2px(float dpValue) {
// final float scale = context.getResources()
// .getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
// }
// Path: XDroidAnimationExample/src/com/xdroid/animation/sample/interpolate/EaseAdapter.java
import java.util.List;
import com.xdroid.animation.sample.R;
import com.xdroid.animation.sample.view.CursorView;
import com.xdroid.animation.sample.view.EaseView;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Interpolator;
import android.view.animation.TranslateAnimation;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
package com.xdroid.animation.sample.interpolate;
/**
* Created by cimi on 15/7/7.
*/
public class EaseAdapter extends BaseAdapter {
private Context mContext;
private LayoutInflater mInflater;
private List<String> mNameList;
private List<Interpolator> mInterpolatorList;
private long duration;
private int selectIndex = -1;
public EaseAdapter(Context context, List<String> nameList, List<Interpolator> interpolatorList, long duration) {
mContext = context;
mInflater = LayoutInflater.from(context);
mNameList = nameList;
mInterpolatorList = interpolatorList;
this.duration = duration;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
mHolder = new ViewHolder();
convertView = mInflater.inflate(R.layout.adapter, null);
convertView.setBackgroundColor(Color.WHITE);
mHolder.easeName = (TextView) convertView.findViewById(R.id.easeName);
mHolder.easeView = (EaseView) convertView.findViewById(R.id.easeView); | mHolder.cursor = (CursorView) convertView.findViewById(R.id.cursor); |
robinxdroid/XDroidAnimation | XDroidAnimation/src/com/xdroid/animation/anim/ColorAnimation.java | // Path: XDroidAnimation/src/com/xdroid/animation/base/AnimationBase.java
// public abstract class AnimationBase<T> implements CombinableMethod<T>{
//
// /** 目标动画view */
// protected View targetView;
//
// /** 插值器 */
// protected TimeInterpolator interpolator;
//
// /** 动画时间 */
// protected long duration;
//
// /** 动画执行回调 */
// protected AnimatorListener listener;
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setInterpolator(TimeInterpolator interpolator) {
// this.interpolator = interpolator;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setDuration(long duration) {
// this.duration = duration;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setListener(AnimatorListener listener) {
// this.listener = listener;
// return (T) this;
// }
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotX(int pivotX) {
// ViewHelper.setPivotX(targetView, pivotX);
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotY(int pivotY) {
// ViewHelper.setPivotY(targetView, pivotY);
// return (T) this;
// }
//
// @Override
// public long getDuration() {
// return duration;
// }
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Duration.java
// public interface Duration {
//
// public static final int DURATION_DEFAULT = 300;
// public static final int DURATION_SHORT = 100;
// public static final int DURATION_LONG = 500;
//
// }
| import com.xdroid.animation.base.AnimationBase;
import com.xdroid.animation.interfaces.Duration;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.graphics.Color;
import android.view.View;
import android.view.animation.LinearInterpolator; | package com.xdroid.animation.anim;
/**
* Color Animation ,can set up a View of the text color or background color transformation, etc
* @author Robin
* @since 2015-08-07 10:31:40
*
*/
public class ColorAnimation extends AnimationBase<ColorAnimation>{
private int[] values;
private String propertiesName;
/*
* ==================================================================
* Constructor
* ==================================================================
*/
public ColorAnimation(View targetView) {
this.targetView = targetView;
interpolator = new LinearInterpolator(); | // Path: XDroidAnimation/src/com/xdroid/animation/base/AnimationBase.java
// public abstract class AnimationBase<T> implements CombinableMethod<T>{
//
// /** 目标动画view */
// protected View targetView;
//
// /** 插值器 */
// protected TimeInterpolator interpolator;
//
// /** 动画时间 */
// protected long duration;
//
// /** 动画执行回调 */
// protected AnimatorListener listener;
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setInterpolator(TimeInterpolator interpolator) {
// this.interpolator = interpolator;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setDuration(long duration) {
// this.duration = duration;
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setListener(AnimatorListener listener) {
// this.listener = listener;
// return (T) this;
// }
//
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotX(int pivotX) {
// ViewHelper.setPivotX(targetView, pivotX);
// return (T) this;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T setPivotY(int pivotY) {
// ViewHelper.setPivotY(targetView, pivotY);
// return (T) this;
// }
//
// @Override
// public long getDuration() {
// return duration;
// }
//
// }
//
// Path: XDroidAnimation/src/com/xdroid/animation/interfaces/Duration.java
// public interface Duration {
//
// public static final int DURATION_DEFAULT = 300;
// public static final int DURATION_SHORT = 100;
// public static final int DURATION_LONG = 500;
//
// }
// Path: XDroidAnimation/src/com/xdroid/animation/anim/ColorAnimation.java
import com.xdroid.animation.base.AnimationBase;
import com.xdroid.animation.interfaces.Duration;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.graphics.Color;
import android.view.View;
import android.view.animation.LinearInterpolator;
package com.xdroid.animation.anim;
/**
* Color Animation ,can set up a View of the text color or background color transformation, etc
* @author Robin
* @since 2015-08-07 10:31:40
*
*/
public class ColorAnimation extends AnimationBase<ColorAnimation>{
private int[] values;
private String propertiesName;
/*
* ==================================================================
* Constructor
* ==================================================================
*/
public ColorAnimation(View targetView) {
this.targetView = targetView;
interpolator = new LinearInterpolator(); | duration = Duration.DURATION_LONG; |
tfmorris/Names | eval/src/main/java/org/folg/names/eval/SimilarNameAdder.java | // Path: score/src/main/java/org/folg/names/score/Scorer.java
// public class Scorer {
// private static Logger logger = Logger.getLogger("org.folg.names.score");
// private static final Scorer surnameScorer = new Scorer(true);
// private static final Scorer givennameScorer = new Scorer(false);
// public static Scorer getGivennameInstance() {
// return givennameScorer;
// }
// public static Scorer getSurnameInstance() {
// return surnameScorer;
// }
//
// private final FeaturesGenerator featuresGenerator;
// private final FeaturesScorer featuresScorer;
//
// private Scorer(final boolean isSurname) {
// this.featuresGenerator = new FeaturesGenerator(isSurname);
// this.featuresScorer = new FeaturesScorer(isSurname);
// }
//
// /**
// * Score two name pieces to see how close they are.
// *
// * @param namePiece1 normalized name piece
// * @param namePiece2 another normalized name piece
// * @return score, higher value indicates more-similar names
// */
// public double scoreNamePair(String namePiece1, String namePiece2) {
// Codes codes1 = featuresGenerator.getCodes(namePiece1);
// Codes codes2 = featuresGenerator.getCodes(namePiece2);
// Features features = new Features();
// featuresGenerator.setFeatures(namePiece1, codes1, namePiece2, codes2, features);
// return featuresScorer.score(features);
// }
// }
//
// Path: score/src/main/java/org/folg/names/score/Utils.java
// public class Utils {
// public static String join(String glue, Collection c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, Object[] c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, int[] c) {
// StringBuilder buf = new StringBuilder();
// for (int o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o);
// }
// return buf.toString();
// }
//
// @SuppressWarnings("unchecked")
// public static Collection intersect(Collection c1, Collection c2) {
// Set result = new HashSet();
// for (Object o : c1) {
// if (c2.contains(o)) {
// result.add(o);
// }
// }
// return result;
// }
// }
| import org.folg.names.score.Scorer;
import org.folg.names.score.Utils;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.*;
import java.util.*;
import java.util.logging.Logger; | /*
* Copyright 2011 Foundation for On-Line Genealogy, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.folg.names.eval;
/**
* Create a similar names file by including all names scoring above a threshold
* If you want to augment (expand) a similar-names file with additional names on existing lines, use SimilarNameAugmenter.
*/
public class SimilarNameAdder {
private static Logger logger = Logger.getLogger("org.folg.names.score");
@Option(name="-i", required=true, usage="common names in")
private File commonNamesFile = null;
@Option(name="-o", required=true, usage="similar names out")
private File similarNamesFile = null;
@Option(name="-t", required=false, usage="min score threshold")
private double threshold = 0.0;
@Option(name="-s", required=false, usage="is surname")
private boolean isSurname = false;
@Option(name="-b", required=false, usage="beginning name to generate")
private int begin = 0;
@Option(name="-n", required=false, usage="number of names to generate")
private int maxNames = Integer.MAX_VALUE;
private void doMain() { | // Path: score/src/main/java/org/folg/names/score/Scorer.java
// public class Scorer {
// private static Logger logger = Logger.getLogger("org.folg.names.score");
// private static final Scorer surnameScorer = new Scorer(true);
// private static final Scorer givennameScorer = new Scorer(false);
// public static Scorer getGivennameInstance() {
// return givennameScorer;
// }
// public static Scorer getSurnameInstance() {
// return surnameScorer;
// }
//
// private final FeaturesGenerator featuresGenerator;
// private final FeaturesScorer featuresScorer;
//
// private Scorer(final boolean isSurname) {
// this.featuresGenerator = new FeaturesGenerator(isSurname);
// this.featuresScorer = new FeaturesScorer(isSurname);
// }
//
// /**
// * Score two name pieces to see how close they are.
// *
// * @param namePiece1 normalized name piece
// * @param namePiece2 another normalized name piece
// * @return score, higher value indicates more-similar names
// */
// public double scoreNamePair(String namePiece1, String namePiece2) {
// Codes codes1 = featuresGenerator.getCodes(namePiece1);
// Codes codes2 = featuresGenerator.getCodes(namePiece2);
// Features features = new Features();
// featuresGenerator.setFeatures(namePiece1, codes1, namePiece2, codes2, features);
// return featuresScorer.score(features);
// }
// }
//
// Path: score/src/main/java/org/folg/names/score/Utils.java
// public class Utils {
// public static String join(String glue, Collection c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, Object[] c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, int[] c) {
// StringBuilder buf = new StringBuilder();
// for (int o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o);
// }
// return buf.toString();
// }
//
// @SuppressWarnings("unchecked")
// public static Collection intersect(Collection c1, Collection c2) {
// Set result = new HashSet();
// for (Object o : c1) {
// if (c2.contains(o)) {
// result.add(o);
// }
// }
// return result;
// }
// }
// Path: eval/src/main/java/org/folg/names/eval/SimilarNameAdder.java
import org.folg.names.score.Scorer;
import org.folg.names.score.Utils;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.*;
import java.util.*;
import java.util.logging.Logger;
/*
* Copyright 2011 Foundation for On-Line Genealogy, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.folg.names.eval;
/**
* Create a similar names file by including all names scoring above a threshold
* If you want to augment (expand) a similar-names file with additional names on existing lines, use SimilarNameAugmenter.
*/
public class SimilarNameAdder {
private static Logger logger = Logger.getLogger("org.folg.names.score");
@Option(name="-i", required=true, usage="common names in")
private File commonNamesFile = null;
@Option(name="-o", required=true, usage="similar names out")
private File similarNamesFile = null;
@Option(name="-t", required=false, usage="min score threshold")
private double threshold = 0.0;
@Option(name="-s", required=false, usage="is surname")
private boolean isSurname = false;
@Option(name="-b", required=false, usage="beginning name to generate")
private int begin = 0;
@Option(name="-n", required=false, usage="number of names to generate")
private int maxNames = Integer.MAX_VALUE;
private void doMain() { | Scorer scorer = isSurname ? Scorer.getSurnameInstance() : Scorer.getGivennameInstance(); |
tfmorris/Names | eval/src/main/java/org/folg/names/eval/SimilarNameAdder.java | // Path: score/src/main/java/org/folg/names/score/Scorer.java
// public class Scorer {
// private static Logger logger = Logger.getLogger("org.folg.names.score");
// private static final Scorer surnameScorer = new Scorer(true);
// private static final Scorer givennameScorer = new Scorer(false);
// public static Scorer getGivennameInstance() {
// return givennameScorer;
// }
// public static Scorer getSurnameInstance() {
// return surnameScorer;
// }
//
// private final FeaturesGenerator featuresGenerator;
// private final FeaturesScorer featuresScorer;
//
// private Scorer(final boolean isSurname) {
// this.featuresGenerator = new FeaturesGenerator(isSurname);
// this.featuresScorer = new FeaturesScorer(isSurname);
// }
//
// /**
// * Score two name pieces to see how close they are.
// *
// * @param namePiece1 normalized name piece
// * @param namePiece2 another normalized name piece
// * @return score, higher value indicates more-similar names
// */
// public double scoreNamePair(String namePiece1, String namePiece2) {
// Codes codes1 = featuresGenerator.getCodes(namePiece1);
// Codes codes2 = featuresGenerator.getCodes(namePiece2);
// Features features = new Features();
// featuresGenerator.setFeatures(namePiece1, codes1, namePiece2, codes2, features);
// return featuresScorer.score(features);
// }
// }
//
// Path: score/src/main/java/org/folg/names/score/Utils.java
// public class Utils {
// public static String join(String glue, Collection c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, Object[] c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, int[] c) {
// StringBuilder buf = new StringBuilder();
// for (int o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o);
// }
// return buf.toString();
// }
//
// @SuppressWarnings("unchecked")
// public static Collection intersect(Collection c1, Collection c2) {
// Set result = new HashSet();
// for (Object o : c1) {
// if (c2.contains(o)) {
// result.add(o);
// }
// }
// return result;
// }
// }
| import org.folg.names.score.Scorer;
import org.folg.names.score.Utils;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.*;
import java.util.*;
import java.util.logging.Logger; | private void doMain() {
Scorer scorer = isSurname ? Scorer.getSurnameInstance() : Scorer.getGivennameInstance();
BufferedReader commonNamesReader = null;
PrintWriter similarNamesWriter = null;
try {
// read common names into a list (assume common names are already normalized)
commonNamesReader = new BufferedReader(new FileReader(commonNamesFile));
List<String> commonNames = new ArrayList<String>();
String line;
while ((line = commonNamesReader.readLine()) != null) {
commonNames.add(line);
}
// for each common name, find other common names scoring above threshold and print
similarNamesWriter = new PrintWriter(similarNamesFile);
int cnt = 0;
for (String name : commonNames) {
if (cnt >= begin && cnt < begin + maxNames) {
Set<String> similarNames = new TreeSet<String>();
for (String otherName : commonNames) {
// Test only otherNames that this name is less than
// We'll run SimilarNameAugmenter later to add the reverse relationships
if (name.compareTo(otherName) < 0) {
double score = scorer.scoreNamePair(name, otherName);
if (score >= threshold) {
similarNames.add(otherName);
}
}
} | // Path: score/src/main/java/org/folg/names/score/Scorer.java
// public class Scorer {
// private static Logger logger = Logger.getLogger("org.folg.names.score");
// private static final Scorer surnameScorer = new Scorer(true);
// private static final Scorer givennameScorer = new Scorer(false);
// public static Scorer getGivennameInstance() {
// return givennameScorer;
// }
// public static Scorer getSurnameInstance() {
// return surnameScorer;
// }
//
// private final FeaturesGenerator featuresGenerator;
// private final FeaturesScorer featuresScorer;
//
// private Scorer(final boolean isSurname) {
// this.featuresGenerator = new FeaturesGenerator(isSurname);
// this.featuresScorer = new FeaturesScorer(isSurname);
// }
//
// /**
// * Score two name pieces to see how close they are.
// *
// * @param namePiece1 normalized name piece
// * @param namePiece2 another normalized name piece
// * @return score, higher value indicates more-similar names
// */
// public double scoreNamePair(String namePiece1, String namePiece2) {
// Codes codes1 = featuresGenerator.getCodes(namePiece1);
// Codes codes2 = featuresGenerator.getCodes(namePiece2);
// Features features = new Features();
// featuresGenerator.setFeatures(namePiece1, codes1, namePiece2, codes2, features);
// return featuresScorer.score(features);
// }
// }
//
// Path: score/src/main/java/org/folg/names/score/Utils.java
// public class Utils {
// public static String join(String glue, Collection c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, Object[] c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, int[] c) {
// StringBuilder buf = new StringBuilder();
// for (int o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o);
// }
// return buf.toString();
// }
//
// @SuppressWarnings("unchecked")
// public static Collection intersect(Collection c1, Collection c2) {
// Set result = new HashSet();
// for (Object o : c1) {
// if (c2.contains(o)) {
// result.add(o);
// }
// }
// return result;
// }
// }
// Path: eval/src/main/java/org/folg/names/eval/SimilarNameAdder.java
import org.folg.names.score.Scorer;
import org.folg.names.score.Utils;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.*;
import java.util.*;
import java.util.logging.Logger;
private void doMain() {
Scorer scorer = isSurname ? Scorer.getSurnameInstance() : Scorer.getGivennameInstance();
BufferedReader commonNamesReader = null;
PrintWriter similarNamesWriter = null;
try {
// read common names into a list (assume common names are already normalized)
commonNamesReader = new BufferedReader(new FileReader(commonNamesFile));
List<String> commonNames = new ArrayList<String>();
String line;
while ((line = commonNamesReader.readLine()) != null) {
commonNames.add(line);
}
// for each common name, find other common names scoring above threshold and print
similarNamesWriter = new PrintWriter(similarNamesFile);
int cnt = 0;
for (String name : commonNames) {
if (cnt >= begin && cnt < begin + maxNames) {
Set<String> similarNames = new TreeSet<String>();
for (String otherName : commonNames) {
// Test only otherNames that this name is less than
// We'll run SimilarNameAugmenter later to add the reverse relationships
if (name.compareTo(otherName) < 0) {
double score = scorer.scoreNamePair(name, otherName);
if (score >= threshold) {
similarNames.add(otherName);
}
}
} | similarNamesWriter.println("\""+name+"\",\""+ Utils.join(" ", similarNames)+"\""); |
tfmorris/Names | eval/src/main/java/org/folg/names/eval/SimilarNameRemover.java | // Path: score/src/main/java/org/folg/names/score/Scorer.java
// public class Scorer {
// private static Logger logger = Logger.getLogger("org.folg.names.score");
// private static final Scorer surnameScorer = new Scorer(true);
// private static final Scorer givennameScorer = new Scorer(false);
// public static Scorer getGivennameInstance() {
// return givennameScorer;
// }
// public static Scorer getSurnameInstance() {
// return surnameScorer;
// }
//
// private final FeaturesGenerator featuresGenerator;
// private final FeaturesScorer featuresScorer;
//
// private Scorer(final boolean isSurname) {
// this.featuresGenerator = new FeaturesGenerator(isSurname);
// this.featuresScorer = new FeaturesScorer(isSurname);
// }
//
// /**
// * Score two name pieces to see how close they are.
// *
// * @param namePiece1 normalized name piece
// * @param namePiece2 another normalized name piece
// * @return score, higher value indicates more-similar names
// */
// public double scoreNamePair(String namePiece1, String namePiece2) {
// Codes codes1 = featuresGenerator.getCodes(namePiece1);
// Codes codes2 = featuresGenerator.getCodes(namePiece2);
// Features features = new Features();
// featuresGenerator.setFeatures(namePiece1, codes1, namePiece2, codes2, features);
// return featuresScorer.score(features);
// }
// }
//
// Path: score/src/main/java/org/folg/names/score/Utils.java
// public class Utils {
// public static String join(String glue, Collection c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, Object[] c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, int[] c) {
// StringBuilder buf = new StringBuilder();
// for (int o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o);
// }
// return buf.toString();
// }
//
// @SuppressWarnings("unchecked")
// public static Collection intersect(Collection c1, Collection c2) {
// Set result = new HashSet();
// for (Object o : c1) {
// if (c2.contains(o)) {
// result.add(o);
// }
// }
// return result;
// }
// }
| import org.folg.names.score.Scorer;
import org.folg.names.score.Utils;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.*;
import java.util.*;
import java.util.logging.Logger; | /*
* Copyright 2011 Foundation for On-Line Genealogy, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.folg.names.eval;
/**
* Remove names from a similar-names file, so that each name has a max of N similar names
* Names are removed using a greedy algorithm, removing the lowest-scoring similar names from the name with the most names
* until all names have no greater than N similar names
*/
public class SimilarNameRemover {
private static Logger logger = Logger.getLogger("org.folg.names.score");
@Option(name="-i", required=true, usage="similar names in")
private File similarNamesInFile = null;
@Option(name="-o", required=true, usage="similar names out")
private File similarNamesOutFile = null;
@Option(name="-s", required=false, usage="is surname")
private boolean isSurname = false;
@Option(name="-m", required=false, usage="max number of names")
private int namesToKeep = 50;
| // Path: score/src/main/java/org/folg/names/score/Scorer.java
// public class Scorer {
// private static Logger logger = Logger.getLogger("org.folg.names.score");
// private static final Scorer surnameScorer = new Scorer(true);
// private static final Scorer givennameScorer = new Scorer(false);
// public static Scorer getGivennameInstance() {
// return givennameScorer;
// }
// public static Scorer getSurnameInstance() {
// return surnameScorer;
// }
//
// private final FeaturesGenerator featuresGenerator;
// private final FeaturesScorer featuresScorer;
//
// private Scorer(final boolean isSurname) {
// this.featuresGenerator = new FeaturesGenerator(isSurname);
// this.featuresScorer = new FeaturesScorer(isSurname);
// }
//
// /**
// * Score two name pieces to see how close they are.
// *
// * @param namePiece1 normalized name piece
// * @param namePiece2 another normalized name piece
// * @return score, higher value indicates more-similar names
// */
// public double scoreNamePair(String namePiece1, String namePiece2) {
// Codes codes1 = featuresGenerator.getCodes(namePiece1);
// Codes codes2 = featuresGenerator.getCodes(namePiece2);
// Features features = new Features();
// featuresGenerator.setFeatures(namePiece1, codes1, namePiece2, codes2, features);
// return featuresScorer.score(features);
// }
// }
//
// Path: score/src/main/java/org/folg/names/score/Utils.java
// public class Utils {
// public static String join(String glue, Collection c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, Object[] c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, int[] c) {
// StringBuilder buf = new StringBuilder();
// for (int o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o);
// }
// return buf.toString();
// }
//
// @SuppressWarnings("unchecked")
// public static Collection intersect(Collection c1, Collection c2) {
// Set result = new HashSet();
// for (Object o : c1) {
// if (c2.contains(o)) {
// result.add(o);
// }
// }
// return result;
// }
// }
// Path: eval/src/main/java/org/folg/names/eval/SimilarNameRemover.java
import org.folg.names.score.Scorer;
import org.folg.names.score.Utils;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.*;
import java.util.*;
import java.util.logging.Logger;
/*
* Copyright 2011 Foundation for On-Line Genealogy, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.folg.names.eval;
/**
* Remove names from a similar-names file, so that each name has a max of N similar names
* Names are removed using a greedy algorithm, removing the lowest-scoring similar names from the name with the most names
* until all names have no greater than N similar names
*/
public class SimilarNameRemover {
private static Logger logger = Logger.getLogger("org.folg.names.score");
@Option(name="-i", required=true, usage="similar names in")
private File similarNamesInFile = null;
@Option(name="-o", required=true, usage="similar names out")
private File similarNamesOutFile = null;
@Option(name="-s", required=false, usage="is surname")
private boolean isSurname = false;
@Option(name="-m", required=false, usage="max number of names")
private int namesToKeep = 50;
| private Scorer scorer; |
tfmorris/Names | eval/src/main/java/org/folg/names/eval/SimilarNameRemover.java | // Path: score/src/main/java/org/folg/names/score/Scorer.java
// public class Scorer {
// private static Logger logger = Logger.getLogger("org.folg.names.score");
// private static final Scorer surnameScorer = new Scorer(true);
// private static final Scorer givennameScorer = new Scorer(false);
// public static Scorer getGivennameInstance() {
// return givennameScorer;
// }
// public static Scorer getSurnameInstance() {
// return surnameScorer;
// }
//
// private final FeaturesGenerator featuresGenerator;
// private final FeaturesScorer featuresScorer;
//
// private Scorer(final boolean isSurname) {
// this.featuresGenerator = new FeaturesGenerator(isSurname);
// this.featuresScorer = new FeaturesScorer(isSurname);
// }
//
// /**
// * Score two name pieces to see how close they are.
// *
// * @param namePiece1 normalized name piece
// * @param namePiece2 another normalized name piece
// * @return score, higher value indicates more-similar names
// */
// public double scoreNamePair(String namePiece1, String namePiece2) {
// Codes codes1 = featuresGenerator.getCodes(namePiece1);
// Codes codes2 = featuresGenerator.getCodes(namePiece2);
// Features features = new Features();
// featuresGenerator.setFeatures(namePiece1, codes1, namePiece2, codes2, features);
// return featuresScorer.score(features);
// }
// }
//
// Path: score/src/main/java/org/folg/names/score/Utils.java
// public class Utils {
// public static String join(String glue, Collection c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, Object[] c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, int[] c) {
// StringBuilder buf = new StringBuilder();
// for (int o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o);
// }
// return buf.toString();
// }
//
// @SuppressWarnings("unchecked")
// public static Collection intersect(Collection c1, Collection c2) {
// Set result = new HashSet();
// for (Object o : c1) {
// if (c2.contains(o)) {
// result.add(o);
// }
// }
// return result;
// }
// }
| import org.folg.names.score.Scorer;
import org.folg.names.score.Utils;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.*;
import java.util.*;
import java.util.logging.Logger; | String name = fields[0].substring(1, fields[0].length() - 1);
Set<String> similarNames = new TreeSet<String>();
if (fields[1].length() > 2) {
similarNames.addAll(Arrays.asList(fields[1].substring(1, fields[1].length() - 1).split(" ")));
}
similarNamesMap.put(name, similarNames);
}
// greedily remove names above threshold
while (true) {
String name = getNameWithMostSimilarNames(similarNamesMap);
Set<String> similarNames = similarNamesMap.get(name);
if (similarNames.size() <= namesToKeep) {
break;
}
Set<String> notSimilarNames = getLeastSimilarNames(name, similarNames, similarNames.size() - namesToKeep);
for (String notSimilarName : notSimilarNames) {
similarNames.remove(notSimilarName);
Set<String> notSimilarNameSimilarNames = similarNamesMap.get(notSimilarName);
if (notSimilarNameSimilarNames == null) {
logger.warning("Not found: "+notSimilarName+" for name="+name);
}
if (!notSimilarNameSimilarNames.remove(name)) {
logger.warning("Name "+name+" not found in "+notSimilarName);
}
}
}
// write similar names
for (String name : similarNamesMap.keySet()) { | // Path: score/src/main/java/org/folg/names/score/Scorer.java
// public class Scorer {
// private static Logger logger = Logger.getLogger("org.folg.names.score");
// private static final Scorer surnameScorer = new Scorer(true);
// private static final Scorer givennameScorer = new Scorer(false);
// public static Scorer getGivennameInstance() {
// return givennameScorer;
// }
// public static Scorer getSurnameInstance() {
// return surnameScorer;
// }
//
// private final FeaturesGenerator featuresGenerator;
// private final FeaturesScorer featuresScorer;
//
// private Scorer(final boolean isSurname) {
// this.featuresGenerator = new FeaturesGenerator(isSurname);
// this.featuresScorer = new FeaturesScorer(isSurname);
// }
//
// /**
// * Score two name pieces to see how close they are.
// *
// * @param namePiece1 normalized name piece
// * @param namePiece2 another normalized name piece
// * @return score, higher value indicates more-similar names
// */
// public double scoreNamePair(String namePiece1, String namePiece2) {
// Codes codes1 = featuresGenerator.getCodes(namePiece1);
// Codes codes2 = featuresGenerator.getCodes(namePiece2);
// Features features = new Features();
// featuresGenerator.setFeatures(namePiece1, codes1, namePiece2, codes2, features);
// return featuresScorer.score(features);
// }
// }
//
// Path: score/src/main/java/org/folg/names/score/Utils.java
// public class Utils {
// public static String join(String glue, Collection c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, Object[] c) {
// StringBuilder buf = new StringBuilder();
// for (Object o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o.toString());
// }
// return buf.toString();
// }
//
// public static String join(String glue, int[] c) {
// StringBuilder buf = new StringBuilder();
// for (int o : c) {
// if (buf.length() > 0) buf.append(glue);
// buf.append(o);
// }
// return buf.toString();
// }
//
// @SuppressWarnings("unchecked")
// public static Collection intersect(Collection c1, Collection c2) {
// Set result = new HashSet();
// for (Object o : c1) {
// if (c2.contains(o)) {
// result.add(o);
// }
// }
// return result;
// }
// }
// Path: eval/src/main/java/org/folg/names/eval/SimilarNameRemover.java
import org.folg.names.score.Scorer;
import org.folg.names.score.Utils;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.*;
import java.util.*;
import java.util.logging.Logger;
String name = fields[0].substring(1, fields[0].length() - 1);
Set<String> similarNames = new TreeSet<String>();
if (fields[1].length() > 2) {
similarNames.addAll(Arrays.asList(fields[1].substring(1, fields[1].length() - 1).split(" ")));
}
similarNamesMap.put(name, similarNames);
}
// greedily remove names above threshold
while (true) {
String name = getNameWithMostSimilarNames(similarNamesMap);
Set<String> similarNames = similarNamesMap.get(name);
if (similarNames.size() <= namesToKeep) {
break;
}
Set<String> notSimilarNames = getLeastSimilarNames(name, similarNames, similarNames.size() - namesToKeep);
for (String notSimilarName : notSimilarNames) {
similarNames.remove(notSimilarName);
Set<String> notSimilarNameSimilarNames = similarNamesMap.get(notSimilarName);
if (notSimilarNameSimilarNames == null) {
logger.warning("Not found: "+notSimilarName+" for name="+name);
}
if (!notSimilarNameSimilarNames.remove(name)) {
logger.warning("Name "+name+" not found in "+notSimilarName);
}
}
}
// write similar names
for (String name : similarNamesMap.keySet()) { | similarNamesWriter.println("\""+name+"\",\""+ Utils.join(" ", similarNamesMap.get(name))+"\""); |
gr8pefish/IronBackpacks | src/main/java/gr8pefish/ironbackpacks/util/Predicates.java | // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/IBackpack.java
// public interface IBackpack {
//
// /**
// * Gets the container object for all backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The container object for all backpack data
// */
// @Nonnull
// default BackpackInfo getBackpackInfo(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.fromStack(stack);
// }
//
// /**
// * Gets the color backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The RGB color; -1 if none
// */
// default int getBackpackColor(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.getColor(stack);
// }
//
// /**
// * Writes the modified backpack data back to the stack. Must be called after any changes are made to the BackpackInfo
// *
// * @param stack - Stack to write backpack data to
// * @param backpackInfo - Modified data to write to stack
// */
// default void updateBackpack(@Nonnull ItemStack stack, @Nonnull BackpackInfo backpackInfo) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
// Preconditions.checkNotNull(backpackInfo, "BackpackInfo cannot be null");
//
// IronBackpacksAPI.applyPackInfo(stack, backpackInfo);
// }
// }
//
// Path: src/main/java/gr8pefish/ironbackpacks/api/upgrade/BackpackUpgrade.java
// public class BackpackUpgrade extends IForgeRegistryEntry.Impl<BackpackUpgrade> {
//
// private final ResourceLocation identifier;
// private final int applicationCost;
// private final int minimumTier;
// private final Set<BackpackUpgrade> conflicting;
// private int maxApplications = 1;
//
// public BackpackUpgrade(@Nonnull ResourceLocation identifier, int applicationCost, @Nonnegative int minimumTier) {
// Preconditions.checkNotNull(identifier, "Identifier cannot be null");
// Preconditions.checkArgument(minimumTier >= 0, "Minimum tier cannot be negative");
//
// this.applicationCost = applicationCost;
// this.minimumTier = minimumTier;
// this.identifier = identifier;
// this.conflicting = Sets.newHashSet();
//
// setRegistryName(identifier);
// }
//
// /**
// * Called during valid points where the player's inventory has been modified. Adjust your logic according to the
// * ModifyMethod.
// *
// * @param method - How the inventory was modified
// * @param stack - The stack that was modified
// * @param player - The player who's inventory was modified
// * @param backpackInfo - All data relevant to the active backpack
// */
// public void onInventory(@Nonnull ModifyMethod method, @Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull BackpackInfo backpackInfo) {
// // No-op
// }
//
// public final int getApplicationCost() {
// return applicationCost;
// }
//
// @Nonnegative
// public final int getMinimumTier() {
// return minimumTier;
// }
//
// @Nonnull
// public ResourceLocation getIdentifier() {
// return identifier;
// }
//
// public boolean isConflicting(@Nullable BackpackUpgrade backpackUpgrade) {
// return backpackUpgrade == null || conflicting.contains(backpackUpgrade);
// }
//
// @Nonnull
// public BackpackUpgrade addConflicting(@Nonnull BackpackUpgrade backpackUpgrade) {
// Preconditions.checkNotNull(backpackUpgrade, "BackpackUpgrade cannot be null");
//
// conflicting.add(backpackUpgrade);
// return this;
// }
//
// public BackpackUpgrade withMaxApplications(int maxApplications) {
// this.maxApplications = maxApplications;
// return this;
// }
//
// public int getMaxApplications() {
// return maxApplications;
// }
//
// public boolean isNull() {
// return getIdentifier().equals(IronBackpacksAPI.NULL);
// }
//
// @Override
// public String toString() {
// return new ToStringBuilder(this)
// .append("identifier", identifier)
// .toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof BackpackUpgrade)) return false;
//
// BackpackUpgrade that = (BackpackUpgrade) o;
//
// return identifier.equals(that.identifier);
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
// }
| import gr8pefish.ironbackpacks.api.backpack.IBackpack;
import gr8pefish.ironbackpacks.api.upgrade.BackpackUpgrade;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.Pair;
import java.util.Objects;
import java.util.function.Predicate; | package gr8pefish.ironbackpacks.util;
public class Predicates {
public static <T> Predicate<T> alwaysTrue() {
return o -> true;
}
public static <T> Predicate<T> alwaysFalse() {
return o -> false;
}
public static <T> Predicate<T> isNull() {
return Objects::isNull;
}
public static <T> Predicate<T> notNull() {
return Objects::nonNull;
}
| // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/IBackpack.java
// public interface IBackpack {
//
// /**
// * Gets the container object for all backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The container object for all backpack data
// */
// @Nonnull
// default BackpackInfo getBackpackInfo(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.fromStack(stack);
// }
//
// /**
// * Gets the color backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The RGB color; -1 if none
// */
// default int getBackpackColor(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.getColor(stack);
// }
//
// /**
// * Writes the modified backpack data back to the stack. Must be called after any changes are made to the BackpackInfo
// *
// * @param stack - Stack to write backpack data to
// * @param backpackInfo - Modified data to write to stack
// */
// default void updateBackpack(@Nonnull ItemStack stack, @Nonnull BackpackInfo backpackInfo) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
// Preconditions.checkNotNull(backpackInfo, "BackpackInfo cannot be null");
//
// IronBackpacksAPI.applyPackInfo(stack, backpackInfo);
// }
// }
//
// Path: src/main/java/gr8pefish/ironbackpacks/api/upgrade/BackpackUpgrade.java
// public class BackpackUpgrade extends IForgeRegistryEntry.Impl<BackpackUpgrade> {
//
// private final ResourceLocation identifier;
// private final int applicationCost;
// private final int minimumTier;
// private final Set<BackpackUpgrade> conflicting;
// private int maxApplications = 1;
//
// public BackpackUpgrade(@Nonnull ResourceLocation identifier, int applicationCost, @Nonnegative int minimumTier) {
// Preconditions.checkNotNull(identifier, "Identifier cannot be null");
// Preconditions.checkArgument(minimumTier >= 0, "Minimum tier cannot be negative");
//
// this.applicationCost = applicationCost;
// this.minimumTier = minimumTier;
// this.identifier = identifier;
// this.conflicting = Sets.newHashSet();
//
// setRegistryName(identifier);
// }
//
// /**
// * Called during valid points where the player's inventory has been modified. Adjust your logic according to the
// * ModifyMethod.
// *
// * @param method - How the inventory was modified
// * @param stack - The stack that was modified
// * @param player - The player who's inventory was modified
// * @param backpackInfo - All data relevant to the active backpack
// */
// public void onInventory(@Nonnull ModifyMethod method, @Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull BackpackInfo backpackInfo) {
// // No-op
// }
//
// public final int getApplicationCost() {
// return applicationCost;
// }
//
// @Nonnegative
// public final int getMinimumTier() {
// return minimumTier;
// }
//
// @Nonnull
// public ResourceLocation getIdentifier() {
// return identifier;
// }
//
// public boolean isConflicting(@Nullable BackpackUpgrade backpackUpgrade) {
// return backpackUpgrade == null || conflicting.contains(backpackUpgrade);
// }
//
// @Nonnull
// public BackpackUpgrade addConflicting(@Nonnull BackpackUpgrade backpackUpgrade) {
// Preconditions.checkNotNull(backpackUpgrade, "BackpackUpgrade cannot be null");
//
// conflicting.add(backpackUpgrade);
// return this;
// }
//
// public BackpackUpgrade withMaxApplications(int maxApplications) {
// this.maxApplications = maxApplications;
// return this;
// }
//
// public int getMaxApplications() {
// return maxApplications;
// }
//
// public boolean isNull() {
// return getIdentifier().equals(IronBackpacksAPI.NULL);
// }
//
// @Override
// public String toString() {
// return new ToStringBuilder(this)
// .append("identifier", identifier)
// .toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof BackpackUpgrade)) return false;
//
// BackpackUpgrade that = (BackpackUpgrade) o;
//
// return identifier.equals(that.identifier);
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
// }
// Path: src/main/java/gr8pefish/ironbackpacks/util/Predicates.java
import gr8pefish.ironbackpacks.api.backpack.IBackpack;
import gr8pefish.ironbackpacks.api.upgrade.BackpackUpgrade;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.Pair;
import java.util.Objects;
import java.util.function.Predicate;
package gr8pefish.ironbackpacks.util;
public class Predicates {
public static <T> Predicate<T> alwaysTrue() {
return o -> true;
}
public static <T> Predicate<T> alwaysFalse() {
return o -> false;
}
public static <T> Predicate<T> isNull() {
return Objects::isNull;
}
public static <T> Predicate<T> notNull() {
return Objects::nonNull;
}
| public static Predicate<Pair<ItemStack, IBackpack>> hasUpgrade(BackpackUpgrade upgrade) { |
gr8pefish/IronBackpacks | src/main/java/gr8pefish/ironbackpacks/util/Predicates.java | // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/IBackpack.java
// public interface IBackpack {
//
// /**
// * Gets the container object for all backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The container object for all backpack data
// */
// @Nonnull
// default BackpackInfo getBackpackInfo(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.fromStack(stack);
// }
//
// /**
// * Gets the color backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The RGB color; -1 if none
// */
// default int getBackpackColor(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.getColor(stack);
// }
//
// /**
// * Writes the modified backpack data back to the stack. Must be called after any changes are made to the BackpackInfo
// *
// * @param stack - Stack to write backpack data to
// * @param backpackInfo - Modified data to write to stack
// */
// default void updateBackpack(@Nonnull ItemStack stack, @Nonnull BackpackInfo backpackInfo) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
// Preconditions.checkNotNull(backpackInfo, "BackpackInfo cannot be null");
//
// IronBackpacksAPI.applyPackInfo(stack, backpackInfo);
// }
// }
//
// Path: src/main/java/gr8pefish/ironbackpacks/api/upgrade/BackpackUpgrade.java
// public class BackpackUpgrade extends IForgeRegistryEntry.Impl<BackpackUpgrade> {
//
// private final ResourceLocation identifier;
// private final int applicationCost;
// private final int minimumTier;
// private final Set<BackpackUpgrade> conflicting;
// private int maxApplications = 1;
//
// public BackpackUpgrade(@Nonnull ResourceLocation identifier, int applicationCost, @Nonnegative int minimumTier) {
// Preconditions.checkNotNull(identifier, "Identifier cannot be null");
// Preconditions.checkArgument(minimumTier >= 0, "Minimum tier cannot be negative");
//
// this.applicationCost = applicationCost;
// this.minimumTier = minimumTier;
// this.identifier = identifier;
// this.conflicting = Sets.newHashSet();
//
// setRegistryName(identifier);
// }
//
// /**
// * Called during valid points where the player's inventory has been modified. Adjust your logic according to the
// * ModifyMethod.
// *
// * @param method - How the inventory was modified
// * @param stack - The stack that was modified
// * @param player - The player who's inventory was modified
// * @param backpackInfo - All data relevant to the active backpack
// */
// public void onInventory(@Nonnull ModifyMethod method, @Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull BackpackInfo backpackInfo) {
// // No-op
// }
//
// public final int getApplicationCost() {
// return applicationCost;
// }
//
// @Nonnegative
// public final int getMinimumTier() {
// return minimumTier;
// }
//
// @Nonnull
// public ResourceLocation getIdentifier() {
// return identifier;
// }
//
// public boolean isConflicting(@Nullable BackpackUpgrade backpackUpgrade) {
// return backpackUpgrade == null || conflicting.contains(backpackUpgrade);
// }
//
// @Nonnull
// public BackpackUpgrade addConflicting(@Nonnull BackpackUpgrade backpackUpgrade) {
// Preconditions.checkNotNull(backpackUpgrade, "BackpackUpgrade cannot be null");
//
// conflicting.add(backpackUpgrade);
// return this;
// }
//
// public BackpackUpgrade withMaxApplications(int maxApplications) {
// this.maxApplications = maxApplications;
// return this;
// }
//
// public int getMaxApplications() {
// return maxApplications;
// }
//
// public boolean isNull() {
// return getIdentifier().equals(IronBackpacksAPI.NULL);
// }
//
// @Override
// public String toString() {
// return new ToStringBuilder(this)
// .append("identifier", identifier)
// .toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof BackpackUpgrade)) return false;
//
// BackpackUpgrade that = (BackpackUpgrade) o;
//
// return identifier.equals(that.identifier);
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
// }
| import gr8pefish.ironbackpacks.api.backpack.IBackpack;
import gr8pefish.ironbackpacks.api.upgrade.BackpackUpgrade;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.Pair;
import java.util.Objects;
import java.util.function.Predicate; | package gr8pefish.ironbackpacks.util;
public class Predicates {
public static <T> Predicate<T> alwaysTrue() {
return o -> true;
}
public static <T> Predicate<T> alwaysFalse() {
return o -> false;
}
public static <T> Predicate<T> isNull() {
return Objects::isNull;
}
public static <T> Predicate<T> notNull() {
return Objects::nonNull;
}
| // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/IBackpack.java
// public interface IBackpack {
//
// /**
// * Gets the container object for all backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The container object for all backpack data
// */
// @Nonnull
// default BackpackInfo getBackpackInfo(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.fromStack(stack);
// }
//
// /**
// * Gets the color backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The RGB color; -1 if none
// */
// default int getBackpackColor(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.getColor(stack);
// }
//
// /**
// * Writes the modified backpack data back to the stack. Must be called after any changes are made to the BackpackInfo
// *
// * @param stack - Stack to write backpack data to
// * @param backpackInfo - Modified data to write to stack
// */
// default void updateBackpack(@Nonnull ItemStack stack, @Nonnull BackpackInfo backpackInfo) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
// Preconditions.checkNotNull(backpackInfo, "BackpackInfo cannot be null");
//
// IronBackpacksAPI.applyPackInfo(stack, backpackInfo);
// }
// }
//
// Path: src/main/java/gr8pefish/ironbackpacks/api/upgrade/BackpackUpgrade.java
// public class BackpackUpgrade extends IForgeRegistryEntry.Impl<BackpackUpgrade> {
//
// private final ResourceLocation identifier;
// private final int applicationCost;
// private final int minimumTier;
// private final Set<BackpackUpgrade> conflicting;
// private int maxApplications = 1;
//
// public BackpackUpgrade(@Nonnull ResourceLocation identifier, int applicationCost, @Nonnegative int minimumTier) {
// Preconditions.checkNotNull(identifier, "Identifier cannot be null");
// Preconditions.checkArgument(minimumTier >= 0, "Minimum tier cannot be negative");
//
// this.applicationCost = applicationCost;
// this.minimumTier = minimumTier;
// this.identifier = identifier;
// this.conflicting = Sets.newHashSet();
//
// setRegistryName(identifier);
// }
//
// /**
// * Called during valid points where the player's inventory has been modified. Adjust your logic according to the
// * ModifyMethod.
// *
// * @param method - How the inventory was modified
// * @param stack - The stack that was modified
// * @param player - The player who's inventory was modified
// * @param backpackInfo - All data relevant to the active backpack
// */
// public void onInventory(@Nonnull ModifyMethod method, @Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull BackpackInfo backpackInfo) {
// // No-op
// }
//
// public final int getApplicationCost() {
// return applicationCost;
// }
//
// @Nonnegative
// public final int getMinimumTier() {
// return minimumTier;
// }
//
// @Nonnull
// public ResourceLocation getIdentifier() {
// return identifier;
// }
//
// public boolean isConflicting(@Nullable BackpackUpgrade backpackUpgrade) {
// return backpackUpgrade == null || conflicting.contains(backpackUpgrade);
// }
//
// @Nonnull
// public BackpackUpgrade addConflicting(@Nonnull BackpackUpgrade backpackUpgrade) {
// Preconditions.checkNotNull(backpackUpgrade, "BackpackUpgrade cannot be null");
//
// conflicting.add(backpackUpgrade);
// return this;
// }
//
// public BackpackUpgrade withMaxApplications(int maxApplications) {
// this.maxApplications = maxApplications;
// return this;
// }
//
// public int getMaxApplications() {
// return maxApplications;
// }
//
// public boolean isNull() {
// return getIdentifier().equals(IronBackpacksAPI.NULL);
// }
//
// @Override
// public String toString() {
// return new ToStringBuilder(this)
// .append("identifier", identifier)
// .toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof BackpackUpgrade)) return false;
//
// BackpackUpgrade that = (BackpackUpgrade) o;
//
// return identifier.equals(that.identifier);
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
// }
// Path: src/main/java/gr8pefish/ironbackpacks/util/Predicates.java
import gr8pefish.ironbackpacks.api.backpack.IBackpack;
import gr8pefish.ironbackpacks.api.upgrade.BackpackUpgrade;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.Pair;
import java.util.Objects;
import java.util.function.Predicate;
package gr8pefish.ironbackpacks.util;
public class Predicates {
public static <T> Predicate<T> alwaysTrue() {
return o -> true;
}
public static <T> Predicate<T> alwaysFalse() {
return o -> false;
}
public static <T> Predicate<T> isNull() {
return Objects::isNull;
}
public static <T> Predicate<T> notNull() {
return Objects::nonNull;
}
| public static Predicate<Pair<ItemStack, IBackpack>> hasUpgrade(BackpackUpgrade upgrade) { |
gr8pefish/IronBackpacks | src/main/java/gr8pefish/ironbackpacks/util/ColorUtil.java | // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/IBackpack.java
// public interface IBackpack {
//
// /**
// * Gets the container object for all backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The container object for all backpack data
// */
// @Nonnull
// default BackpackInfo getBackpackInfo(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.fromStack(stack);
// }
//
// /**
// * Gets the color backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The RGB color; -1 if none
// */
// default int getBackpackColor(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.getColor(stack);
// }
//
// /**
// * Writes the modified backpack data back to the stack. Must be called after any changes are made to the BackpackInfo
// *
// * @param stack - Stack to write backpack data to
// * @param backpackInfo - Modified data to write to stack
// */
// default void updateBackpack(@Nonnull ItemStack stack, @Nonnull BackpackInfo backpackInfo) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
// Preconditions.checkNotNull(backpackInfo, "BackpackInfo cannot be null");
//
// IronBackpacksAPI.applyPackInfo(stack, backpackInfo);
// }
// }
| import gr8pefish.ironbackpacks.api.backpack.IBackpack;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull; | package gr8pefish.ironbackpacks.util;
public class ColorUtil {
/**
* Gets the color for the specified backpack.
* Does so via a direct call to the backpack's color data to ensure a performant lookup
*
* @param backpackStack - the backpack to target
* @param tintindex - the tintindex, which refers to the layer# in the model json
* @return - RGB value as an {@link int}
*/
public static int getBackpackColor(ItemStack backpackStack, int tintindex) {
if (tintindex < 1) return -1;
return getBackpackColorFromStack(backpackStack);
}
/**
* Gets the RGB color of the backpack.
*
* @param stack - the backpack item stack to check
* @return the RGB color, -1 if none
*/
public static int getBackpackColorFromStack(@Nonnull ItemStack stack) { | // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/IBackpack.java
// public interface IBackpack {
//
// /**
// * Gets the container object for all backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The container object for all backpack data
// */
// @Nonnull
// default BackpackInfo getBackpackInfo(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.fromStack(stack);
// }
//
// /**
// * Gets the color backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The RGB color; -1 if none
// */
// default int getBackpackColor(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.getColor(stack);
// }
//
// /**
// * Writes the modified backpack data back to the stack. Must be called after any changes are made to the BackpackInfo
// *
// * @param stack - Stack to write backpack data to
// * @param backpackInfo - Modified data to write to stack
// */
// default void updateBackpack(@Nonnull ItemStack stack, @Nonnull BackpackInfo backpackInfo) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
// Preconditions.checkNotNull(backpackInfo, "BackpackInfo cannot be null");
//
// IronBackpacksAPI.applyPackInfo(stack, backpackInfo);
// }
// }
// Path: src/main/java/gr8pefish/ironbackpacks/util/ColorUtil.java
import gr8pefish.ironbackpacks.api.backpack.IBackpack;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
package gr8pefish.ironbackpacks.util;
public class ColorUtil {
/**
* Gets the color for the specified backpack.
* Does so via a direct call to the backpack's color data to ensure a performant lookup
*
* @param backpackStack - the backpack to target
* @param tintindex - the tintindex, which refers to the layer# in the model json
* @return - RGB value as an {@link int}
*/
public static int getBackpackColor(ItemStack backpackStack, int tintindex) {
if (tintindex < 1) return -1;
return getBackpackColorFromStack(backpackStack);
}
/**
* Gets the RGB color of the backpack.
*
* @param stack - the backpack item stack to check
* @return the RGB color, -1 if none
*/
public static int getBackpackColorFromStack(@Nonnull ItemStack stack) { | if (!stack.isEmpty() && stack.getItem() instanceof IBackpack) { |
gr8pefish/IronBackpacks | src/main/java/gr8pefish/ironbackpacks/capabilities/IronBackpacksCapabilities.java | // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/inventory/IBackpackInventoryProvider.java
// public interface IBackpackInventoryProvider {
//
// /**
// * Gets the inventory of the backpack given the variant.
// * Note: Modifying this Client Side is not advised
// *
// * @return The inventory representing this backpack, as an {@link IItemHandler}
// */
// @Nonnull
// IItemHandler getInventory();
// }
| import gr8pefish.ironbackpacks.api.backpack.inventory.IBackpackInventoryProvider;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import javax.annotation.Nullable; | package gr8pefish.ironbackpacks.capabilities;
public class IronBackpacksCapabilities {
//TODO: Refactor to API eventually
//Inject capabilities
@CapabilityInject(ItemBackpackHandler.class)
public static final Capability<ItemBackpackHandler> ITEM_BACKPACK_HANDLER_CAPABILITY = null;
@CapabilityInject(PlayerBackpackHandler.class)
public static final Capability<PlayerBackpackHandler> PLAYER_BACKPACK_HANDLER_CAPABILITY = null;
//Registration
public static void registerAllCapabilities() { | // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/inventory/IBackpackInventoryProvider.java
// public interface IBackpackInventoryProvider {
//
// /**
// * Gets the inventory of the backpack given the variant.
// * Note: Modifying this Client Side is not advised
// *
// * @return The inventory representing this backpack, as an {@link IItemHandler}
// */
// @Nonnull
// IItemHandler getInventory();
// }
// Path: src/main/java/gr8pefish/ironbackpacks/capabilities/IronBackpacksCapabilities.java
import gr8pefish.ironbackpacks.api.backpack.inventory.IBackpackInventoryProvider;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import javax.annotation.Nullable;
package gr8pefish.ironbackpacks.capabilities;
public class IronBackpacksCapabilities {
//TODO: Refactor to API eventually
//Inject capabilities
@CapabilityInject(ItemBackpackHandler.class)
public static final Capability<ItemBackpackHandler> ITEM_BACKPACK_HANDLER_CAPABILITY = null;
@CapabilityInject(PlayerBackpackHandler.class)
public static final Capability<PlayerBackpackHandler> PLAYER_BACKPACK_HANDLER_CAPABILITY = null;
//Registration
public static void registerAllCapabilities() { | CapabilityManager.INSTANCE.register(IBackpackInventoryProvider.class, new Capability.IStorage<IBackpackInventoryProvider>() { |
gr8pefish/IronBackpacks | src/main/java/gr8pefish/ironbackpacks/integration/jei/recipe/upgrade/RecipeWrapperTier.java | // Path: src/main/java/gr8pefish/ironbackpacks/core/recipe/BackpackTierRecipe.java
// public class BackpackTierRecipe extends ShapedOreRecipe {
//
// private final BackpackType resultType;
// private final BackpackSpecialty resultSpecialty;
//
// public BackpackTierRecipe(@Nonnull BackpackType resultType, @Nonnull BackpackSpecialty resultSpecialty, Object... recipe) {
// super(new ResourceLocation(IronBackpacks.MODID, "tier"), IronBackpacksAPI.getStack(resultType, resultSpecialty), recipe);
//
// this.resultType = resultType;
// this.resultSpecialty = resultSpecialty;
// }
//
// @Nonnull
// @Override
// public ItemStack getCraftingResult(@Nonnull InventoryCrafting matrix) {
// ItemStack backpack = matrix.getStackInRowAndColumn(1, 1);
// if (!(backpack.getItem() instanceof IBackpack))
// return super.getCraftingResult(matrix);
//
// ItemStack upgraded = getRecipeOutput().copy();
// BackpackInfo upgradedInfo = BackpackInfo.upgradeTo(((IBackpack) backpack.getItem()).getBackpackInfo(backpack), getResultType(), getResultSpecialty());
// return IronBackpacksAPI.applyPackInfo(upgraded, upgradedInfo);
// }
//
// public BackpackType getResultType() {
// return resultType;
// }
//
// public BackpackSpecialty getResultSpecialty() {
// return resultSpecialty;
// }
// }
//
// Path: src/main/java/gr8pefish/ironbackpacks/integration/jei/IronBackpacksJEIPlugin.java
// @JEIPlugin
// public class IronBackpacksJEIPlugin implements IModPlugin {
//
// public static IJeiRuntime runtime;
// public static IJeiHelpers helpers;
//
// @Override
// public void register(IModRegistry registry) {
// helpers = registry.getJeiHelpers();
//
// registry.handleRecipes(BackpackTierRecipe.class, RecipeWrapperTier::new, RecipeCategoryTier.ID);
// registry.addRecipeCatalyst(new ItemStack(Blocks.CRAFTING_TABLE), RecipeCategoryTier.ID);
// }
//
// @Override
// public void registerCategories(IRecipeCategoryRegistration registry) {
// registry.addRecipeCategories(new RecipeCategoryTier(registry.getJeiHelpers().getGuiHelper()));
// }
//
// @Override
// public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
// subtypeRegistry.useNbtForSubtypes(RegistrarIronBackpacks.UPGRADE);
// subtypeRegistry.registerSubtypeInterpreter(RegistrarIronBackpacks.BACKPACK, s -> {
// if (!(s.getItem() instanceof IBackpack))
// return ISubtypeRegistry.ISubtypeInterpreter.NONE;
//
// BackpackInfo backpackInfo = ((IBackpack) s.getItem()).getBackpackInfo(s);
// return backpackInfo.getVariant().getBackpackType().getIdentifier().toString() + "|" + backpackInfo.getVariant().getBackpackSpecialty();
// });
// }
//
// @Override
// public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
// runtime = jeiRuntime;
// }
// }
| import com.google.common.collect.Lists;
import gr8pefish.ironbackpacks.core.recipe.BackpackTierRecipe;
import gr8pefish.ironbackpacks.integration.jei.IronBackpacksJEIPlugin;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.IStackHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import java.util.List; | package gr8pefish.ironbackpacks.integration.jei.recipe.upgrade;
public class RecipeWrapperTier implements IRecipeWrapper {
private final BackpackTierRecipe backpackTierRecipe;
public RecipeWrapperTier(BackpackTierRecipe backpackTierRecipe) {
this.backpackTierRecipe = backpackTierRecipe;
}
@Override
public void getIngredients(IIngredients ingredients) { | // Path: src/main/java/gr8pefish/ironbackpacks/core/recipe/BackpackTierRecipe.java
// public class BackpackTierRecipe extends ShapedOreRecipe {
//
// private final BackpackType resultType;
// private final BackpackSpecialty resultSpecialty;
//
// public BackpackTierRecipe(@Nonnull BackpackType resultType, @Nonnull BackpackSpecialty resultSpecialty, Object... recipe) {
// super(new ResourceLocation(IronBackpacks.MODID, "tier"), IronBackpacksAPI.getStack(resultType, resultSpecialty), recipe);
//
// this.resultType = resultType;
// this.resultSpecialty = resultSpecialty;
// }
//
// @Nonnull
// @Override
// public ItemStack getCraftingResult(@Nonnull InventoryCrafting matrix) {
// ItemStack backpack = matrix.getStackInRowAndColumn(1, 1);
// if (!(backpack.getItem() instanceof IBackpack))
// return super.getCraftingResult(matrix);
//
// ItemStack upgraded = getRecipeOutput().copy();
// BackpackInfo upgradedInfo = BackpackInfo.upgradeTo(((IBackpack) backpack.getItem()).getBackpackInfo(backpack), getResultType(), getResultSpecialty());
// return IronBackpacksAPI.applyPackInfo(upgraded, upgradedInfo);
// }
//
// public BackpackType getResultType() {
// return resultType;
// }
//
// public BackpackSpecialty getResultSpecialty() {
// return resultSpecialty;
// }
// }
//
// Path: src/main/java/gr8pefish/ironbackpacks/integration/jei/IronBackpacksJEIPlugin.java
// @JEIPlugin
// public class IronBackpacksJEIPlugin implements IModPlugin {
//
// public static IJeiRuntime runtime;
// public static IJeiHelpers helpers;
//
// @Override
// public void register(IModRegistry registry) {
// helpers = registry.getJeiHelpers();
//
// registry.handleRecipes(BackpackTierRecipe.class, RecipeWrapperTier::new, RecipeCategoryTier.ID);
// registry.addRecipeCatalyst(new ItemStack(Blocks.CRAFTING_TABLE), RecipeCategoryTier.ID);
// }
//
// @Override
// public void registerCategories(IRecipeCategoryRegistration registry) {
// registry.addRecipeCategories(new RecipeCategoryTier(registry.getJeiHelpers().getGuiHelper()));
// }
//
// @Override
// public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
// subtypeRegistry.useNbtForSubtypes(RegistrarIronBackpacks.UPGRADE);
// subtypeRegistry.registerSubtypeInterpreter(RegistrarIronBackpacks.BACKPACK, s -> {
// if (!(s.getItem() instanceof IBackpack))
// return ISubtypeRegistry.ISubtypeInterpreter.NONE;
//
// BackpackInfo backpackInfo = ((IBackpack) s.getItem()).getBackpackInfo(s);
// return backpackInfo.getVariant().getBackpackType().getIdentifier().toString() + "|" + backpackInfo.getVariant().getBackpackSpecialty();
// });
// }
//
// @Override
// public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
// runtime = jeiRuntime;
// }
// }
// Path: src/main/java/gr8pefish/ironbackpacks/integration/jei/recipe/upgrade/RecipeWrapperTier.java
import com.google.common.collect.Lists;
import gr8pefish.ironbackpacks.core.recipe.BackpackTierRecipe;
import gr8pefish.ironbackpacks.integration.jei.IronBackpacksJEIPlugin;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.IStackHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import java.util.List;
package gr8pefish.ironbackpacks.integration.jei.recipe.upgrade;
public class RecipeWrapperTier implements IRecipeWrapper {
private final BackpackTierRecipe backpackTierRecipe;
public RecipeWrapperTier(BackpackTierRecipe backpackTierRecipe) {
this.backpackTierRecipe = backpackTierRecipe;
}
@Override
public void getIngredients(IIngredients ingredients) { | IStackHelper stackHelper = IronBackpacksJEIPlugin.helpers.getStackHelper(); |
gr8pefish/IronBackpacks | src/main/java/gr8pefish/ironbackpacks/client/gui/GuiTextureResource.java | // Path: src/main/java/gr8pefish/ironbackpacks/IronBackpacks.java
// @Mod(modid = IronBackpacks.MODID, name = IronBackpacks.NAME, version = IronBackpacks.VERSION, dependencies = IronBackpacks.DEPEND, acceptedMinecraftVersions = "[1.12,1.13)")
// public class IronBackpacks {
//
// public static final String MODID = "ironbackpacks";
// public static final String NAME = "Iron Backpacks";
// public static final String VERSION = "@VERSION@";
// public static final String DEPEND = "";
// public static final Logger LOGGER = LogManager.getLogger(NAME);
// public static final SimpleNetworkWrapper NETWORK = new SimpleNetworkWrapper(MODID);
// public static final CreativeTabs TAB_IB = new CreativeTabs(MODID) {
// @Override
// public ItemStack getTabIconItem() {
// return IronBackpacksAPI.getStack(RegistrarIronBackpacks.PACK_IRON /*im not null don't worry*/, BackpackSpecialty.STORAGE);
// }
// };
//
// @SidedProxy(clientSide = "gr8pefish.ironbackpacks.proxy.ClientProxy", serverSide = "gr8pefish.ironbackpacks.proxy.CommonProxy")
// public static CommonProxy PROXY;
//
// @Mod.Instance(MODID)
// public static IronBackpacks INSTANCE;
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PROXY.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// PROXY.postInit(event);
// }
//
// @Mod.EventHandler
// public void onServerStart(FMLServerStartingEvent event) {
//
// }
// }
| import com.google.common.base.Preconditions;
import gr8pefish.ironbackpacks.IronBackpacks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull; | package gr8pefish.ironbackpacks.client.gui;
/**
* Class used as a helper to facilitate building the backpacks' GUIs
* Credit goes to copygirl for this code, copied with permission.
*/
@SideOnly(Side.CLIENT)
public class GuiTextureResource extends ResourceLocation {
@Nonnegative
public final int defaultWidth;
@Nonnegative
public final int defaultHeight;
public GuiTextureResource(@Nonnull String location, @Nonnegative int defaultWidth, @Nonnegative int defaultHeight) { | // Path: src/main/java/gr8pefish/ironbackpacks/IronBackpacks.java
// @Mod(modid = IronBackpacks.MODID, name = IronBackpacks.NAME, version = IronBackpacks.VERSION, dependencies = IronBackpacks.DEPEND, acceptedMinecraftVersions = "[1.12,1.13)")
// public class IronBackpacks {
//
// public static final String MODID = "ironbackpacks";
// public static final String NAME = "Iron Backpacks";
// public static final String VERSION = "@VERSION@";
// public static final String DEPEND = "";
// public static final Logger LOGGER = LogManager.getLogger(NAME);
// public static final SimpleNetworkWrapper NETWORK = new SimpleNetworkWrapper(MODID);
// public static final CreativeTabs TAB_IB = new CreativeTabs(MODID) {
// @Override
// public ItemStack getTabIconItem() {
// return IronBackpacksAPI.getStack(RegistrarIronBackpacks.PACK_IRON /*im not null don't worry*/, BackpackSpecialty.STORAGE);
// }
// };
//
// @SidedProxy(clientSide = "gr8pefish.ironbackpacks.proxy.ClientProxy", serverSide = "gr8pefish.ironbackpacks.proxy.CommonProxy")
// public static CommonProxy PROXY;
//
// @Mod.Instance(MODID)
// public static IronBackpacks INSTANCE;
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PROXY.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// PROXY.postInit(event);
// }
//
// @Mod.EventHandler
// public void onServerStart(FMLServerStartingEvent event) {
//
// }
// }
// Path: src/main/java/gr8pefish/ironbackpacks/client/gui/GuiTextureResource.java
import com.google.common.base.Preconditions;
import gr8pefish.ironbackpacks.IronBackpacks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
package gr8pefish.ironbackpacks.client.gui;
/**
* Class used as a helper to facilitate building the backpacks' GUIs
* Credit goes to copygirl for this code, copied with permission.
*/
@SideOnly(Side.CLIENT)
public class GuiTextureResource extends ResourceLocation {
@Nonnegative
public final int defaultWidth;
@Nonnegative
public final int defaultHeight;
public GuiTextureResource(@Nonnull String location, @Nonnegative int defaultWidth, @Nonnegative int defaultHeight) { | super(IronBackpacks.MODID, "textures/gui/" + location + ".png"); |
gr8pefish/IronBackpacks | src/main/java/gr8pefish/ironbackpacks/api/backpack/variant/BackpackVariant.java | // Path: src/main/java/gr8pefish/ironbackpacks/IronBackpacks.java
// @Mod(modid = IronBackpacks.MODID, name = IronBackpacks.NAME, version = IronBackpacks.VERSION, dependencies = IronBackpacks.DEPEND, acceptedMinecraftVersions = "[1.12,1.13)")
// public class IronBackpacks {
//
// public static final String MODID = "ironbackpacks";
// public static final String NAME = "Iron Backpacks";
// public static final String VERSION = "@VERSION@";
// public static final String DEPEND = "";
// public static final Logger LOGGER = LogManager.getLogger(NAME);
// public static final SimpleNetworkWrapper NETWORK = new SimpleNetworkWrapper(MODID);
// public static final CreativeTabs TAB_IB = new CreativeTabs(MODID) {
// @Override
// public ItemStack getTabIconItem() {
// return IronBackpacksAPI.getStack(RegistrarIronBackpacks.PACK_IRON /*im not null don't worry*/, BackpackSpecialty.STORAGE);
// }
// };
//
// @SidedProxy(clientSide = "gr8pefish.ironbackpacks.proxy.ClientProxy", serverSide = "gr8pefish.ironbackpacks.proxy.CommonProxy")
// public static CommonProxy PROXY;
//
// @Mod.Instance(MODID)
// public static IronBackpacks INSTANCE;
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PROXY.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// PROXY.postInit(event);
// }
//
// @Mod.EventHandler
// public void onServerStart(FMLServerStartingEvent event) {
//
// }
// }
| import com.google.common.base.Preconditions;
import gr8pefish.ironbackpacks.IronBackpacks;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import java.util.Objects; | package gr8pefish.ironbackpacks.api.backpack.variant;
/**
* Class to hold the variant of a backpack.
*
* Each variant is determined by the backpackType and backpackSpecialty.
* Using this data, the maxUpgradePoints, backpackSize, and identifier are constructed.
* There is only one of each variant (e.g. IRON_STORAGE).
*/
public class BackpackVariant {
// Fields
@Nonnull
private final BackpackType backpackType;
@Nonnull
private final BackpackSpecialty backpackSpecialty;
@Nonnull
private final BackpackSize backpackSize; //This is with the backpackSpecialty modifying it
@Nonnegative
private final int maxUpgradePoints; //This is with the backpackSpecialty modifying it
@Nonnull
private final ResourceLocation identifier; //TODO: will be used for serialization once implemented
// Constructor
public BackpackVariant(@Nonnull BackpackType type, @Nonnull BackpackSpecialty backpackSpecialty) {
Preconditions.checkNotNull(type, "Type cannot be null");
Preconditions.checkNotNull(backpackSpecialty, "Specialty cannot be null");
this.backpackType = type;
this.maxUpgradePoints = type.applyDefaultUpgradePointModifierFromBackpackSpecialty(backpackSpecialty);
this.backpackSpecialty = backpackSpecialty;
this.backpackSize = type.getBaseBackpackSize().applyDefaultSizeModifierFromBackpackSpecialty(backpackSpecialty);
//Generate a unique identifier from the backpackType and backpackSpecialty, ends up looking like: "ironbackpacks:variant_iron_storage" | // Path: src/main/java/gr8pefish/ironbackpacks/IronBackpacks.java
// @Mod(modid = IronBackpacks.MODID, name = IronBackpacks.NAME, version = IronBackpacks.VERSION, dependencies = IronBackpacks.DEPEND, acceptedMinecraftVersions = "[1.12,1.13)")
// public class IronBackpacks {
//
// public static final String MODID = "ironbackpacks";
// public static final String NAME = "Iron Backpacks";
// public static final String VERSION = "@VERSION@";
// public static final String DEPEND = "";
// public static final Logger LOGGER = LogManager.getLogger(NAME);
// public static final SimpleNetworkWrapper NETWORK = new SimpleNetworkWrapper(MODID);
// public static final CreativeTabs TAB_IB = new CreativeTabs(MODID) {
// @Override
// public ItemStack getTabIconItem() {
// return IronBackpacksAPI.getStack(RegistrarIronBackpacks.PACK_IRON /*im not null don't worry*/, BackpackSpecialty.STORAGE);
// }
// };
//
// @SidedProxy(clientSide = "gr8pefish.ironbackpacks.proxy.ClientProxy", serverSide = "gr8pefish.ironbackpacks.proxy.CommonProxy")
// public static CommonProxy PROXY;
//
// @Mod.Instance(MODID)
// public static IronBackpacks INSTANCE;
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PROXY.preInit(event);
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event) {
// PROXY.init(event);
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// PROXY.postInit(event);
// }
//
// @Mod.EventHandler
// public void onServerStart(FMLServerStartingEvent event) {
//
// }
// }
// Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/variant/BackpackVariant.java
import com.google.common.base.Preconditions;
import gr8pefish.ironbackpacks.IronBackpacks;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import java.util.Objects;
package gr8pefish.ironbackpacks.api.backpack.variant;
/**
* Class to hold the variant of a backpack.
*
* Each variant is determined by the backpackType and backpackSpecialty.
* Using this data, the maxUpgradePoints, backpackSize, and identifier are constructed.
* There is only one of each variant (e.g. IRON_STORAGE).
*/
public class BackpackVariant {
// Fields
@Nonnull
private final BackpackType backpackType;
@Nonnull
private final BackpackSpecialty backpackSpecialty;
@Nonnull
private final BackpackSize backpackSize; //This is with the backpackSpecialty modifying it
@Nonnegative
private final int maxUpgradePoints; //This is with the backpackSpecialty modifying it
@Nonnull
private final ResourceLocation identifier; //TODO: will be used for serialization once implemented
// Constructor
public BackpackVariant(@Nonnull BackpackType type, @Nonnull BackpackSpecialty backpackSpecialty) {
Preconditions.checkNotNull(type, "Type cannot be null");
Preconditions.checkNotNull(backpackSpecialty, "Specialty cannot be null");
this.backpackType = type;
this.maxUpgradePoints = type.applyDefaultUpgradePointModifierFromBackpackSpecialty(backpackSpecialty);
this.backpackSpecialty = backpackSpecialty;
this.backpackSize = type.getBaseBackpackSize().applyDefaultSizeModifierFromBackpackSpecialty(backpackSpecialty);
//Generate a unique identifier from the backpackType and backpackSpecialty, ends up looking like: "ironbackpacks:variant_iron_storage" | this.identifier = new ResourceLocation(IronBackpacks.MODID, "variant_" + type.getIdentifier().getResourcePath() + "_" + backpackSpecialty.getName()); |
gr8pefish/IronBackpacks | src/main/java/gr8pefish/ironbackpacks/core/recipe/RecipeUtil.java | // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/IBackpack.java
// public interface IBackpack {
//
// /**
// * Gets the container object for all backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The container object for all backpack data
// */
// @Nonnull
// default BackpackInfo getBackpackInfo(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.fromStack(stack);
// }
//
// /**
// * Gets the color backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The RGB color; -1 if none
// */
// default int getBackpackColor(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.getColor(stack);
// }
//
// /**
// * Writes the modified backpack data back to the stack. Must be called after any changes are made to the BackpackInfo
// *
// * @param stack - Stack to write backpack data to
// * @param backpackInfo - Modified data to write to stack
// */
// default void updateBackpack(@Nonnull ItemStack stack, @Nonnull BackpackInfo backpackInfo) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
// Preconditions.checkNotNull(backpackInfo, "BackpackInfo cannot be null");
//
// IronBackpacksAPI.applyPackInfo(stack, backpackInfo);
// }
// }
| import gr8pefish.ironbackpacks.api.backpack.IBackpack;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull; | package gr8pefish.ironbackpacks.core.recipe;
/**
* Helper methods for recipes
*/
public class RecipeUtil {
/**
* Gets the first backpack ItemStack in a crafting grid.
*
* @param matrix - the crafting inventory to search
* @return - a ItemStack which is known to be a backpack
*/
@Nonnull
public static ItemStack getFirstBackpackInGrid(@Nonnull InventoryCrafting matrix) {
ItemStack stack = ItemStack.EMPTY;
for (int i=0; i < matrix.getSizeInventory(); i++ ) {
stack = matrix.getStackInSlot(i); | // Path: src/main/java/gr8pefish/ironbackpacks/api/backpack/IBackpack.java
// public interface IBackpack {
//
// /**
// * Gets the container object for all backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The container object for all backpack data
// */
// @Nonnull
// default BackpackInfo getBackpackInfo(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.fromStack(stack);
// }
//
// /**
// * Gets the color backpack data from the stack.
// *
// * @param stack - The stack to get the backpack information from
// * @return - The RGB color; -1 if none
// */
// default int getBackpackColor(@Nonnull ItemStack stack) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
//
// return BackpackInfo.getColor(stack);
// }
//
// /**
// * Writes the modified backpack data back to the stack. Must be called after any changes are made to the BackpackInfo
// *
// * @param stack - Stack to write backpack data to
// * @param backpackInfo - Modified data to write to stack
// */
// default void updateBackpack(@Nonnull ItemStack stack, @Nonnull BackpackInfo backpackInfo) {
// Preconditions.checkNotNull(stack, "ItemStack cannot be null");
// Preconditions.checkNotNull(backpackInfo, "BackpackInfo cannot be null");
//
// IronBackpacksAPI.applyPackInfo(stack, backpackInfo);
// }
// }
// Path: src/main/java/gr8pefish/ironbackpacks/core/recipe/RecipeUtil.java
import gr8pefish.ironbackpacks.api.backpack.IBackpack;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
package gr8pefish.ironbackpacks.core.recipe;
/**
* Helper methods for recipes
*/
public class RecipeUtil {
/**
* Gets the first backpack ItemStack in a crafting grid.
*
* @param matrix - the crafting inventory to search
* @return - a ItemStack which is known to be a backpack
*/
@Nonnull
public static ItemStack getFirstBackpackInGrid(@Nonnull InventoryCrafting matrix) {
ItemStack stack = ItemStack.EMPTY;
for (int i=0; i < matrix.getSizeInventory(); i++ ) {
stack = matrix.getStackInSlot(i); | if (!stack.isEmpty() && stack.getItem() instanceof IBackpack) { |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/tools/Axe.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import java.util.Locale;
import net.minecraft.item.ItemAxe;
import com.teammetallurgy.metallurgy.Metallurgy; | package com.teammetallurgy.metallurgy.tools;
public class Axe extends ItemAxe
{
public Axe(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/tools/Axe.java
import java.util.Locale;
import net.minecraft.item.ItemAxe;
import com.teammetallurgy.metallurgy.Metallurgy;
package com.teammetallurgy.metallurgy.tools;
public class Axe extends ItemAxe
{
public Axe(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | this.setUnlocalizedName(Metallurgy.MODID.toLowerCase(Locale.US) + "." + unlocalizedName); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/world/WorldGenMetals.java | // Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
| import java.util.ArrayList;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import com.teammetallurgy.metallurgy.lib.Configs;
import cpw.mods.fml.common.IWorldGenerator; |
WorldGenMetals.generators.add(this);
}
private long genBlockSeed(Block block, int meta)
{
long seed = 0L;
String blockUName = block.getUnlocalizedName();
char[] name = blockUName.toCharArray();
long hash = 0L;
if (name.length > 0)
{
for (int i = 0; i < name.length; i++)
{
hash = 31 * hash + name[i];
}
}
seed = hash * 31;
seed = seed + meta;
return seed;
}
public void generate(Random random, int chunkX, int chunkZ, World world, boolean firstGenerate)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/world/WorldGenMetals.java
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import com.teammetallurgy.metallurgy.lib.Configs;
import cpw.mods.fml.common.IWorldGenerator;
WorldGenMetals.generators.add(this);
}
private long genBlockSeed(Block block, int meta)
{
long seed = 0L;
String blockUName = block.getUnlocalizedName();
char[] name = blockUName.toCharArray();
long hash = 0L;
if (name.length > 0)
{
for (int i = 0; i < name.length; i++)
{
hash = 31 * hash + name[i];
}
}
seed = hash * 31;
seed = seed + meta;
return seed;
}
public void generate(Random random, int chunkX, int chunkZ, World world, boolean firstGenerate)
{ | if (firstGenerate || Configs.regen) |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/armor/ItemMetallurgyArmor.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import java.util.Locale;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import com.teammetallurgy.metallurgy.Metallurgy; | package com.teammetallurgy.metallurgy.armor;
public class ItemMetallurgyArmor extends ItemArmor
{
private String modelTexture;
public ItemMetallurgyArmor(ArmorMaterial armorMaterial, int renderIndex, int armorPart, String modelTexture)
{
super(armorMaterial, renderIndex, armorPart); | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/armor/ItemMetallurgyArmor.java
import java.util.Locale;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import com.teammetallurgy.metallurgy.Metallurgy;
package com.teammetallurgy.metallurgy.armor;
public class ItemMetallurgyArmor extends ItemArmor
{
private String modelTexture;
public ItemMetallurgyArmor(ArmorMaterial armorMaterial, int renderIndex, int armorPart, String modelTexture)
{
super(armorMaterial, renderIndex, armorPart); | this.modelTexture = Metallurgy.MODID.toLowerCase(Locale.US) + ":" + "textures/models/armor/"; |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/metals/MetalItem.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import com.teammetallurgy.metallurgy.Metallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; | }
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (this.names.get(meta) != null)
{
String unlocalizedName = this.names.get(meta);
unlocalizedName = unlocalizedName.replace(" ", ".").toLowerCase(Locale.US);
String itemType = "";
switch (this.itemTypes.get(meta))
{
case 0:
itemType = ".dust";
break;
case 1:
itemType = ".ingot";
break;
case 2:
// for item/drop
itemType = "";
break;
case 3:
itemType = ".nugget";
break;
}
| // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/metals/MetalItem.java
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import com.teammetallurgy.metallurgy.Metallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (this.names.get(meta) != null)
{
String unlocalizedName = this.names.get(meta);
unlocalizedName = unlocalizedName.replace(" ", ".").toLowerCase(Locale.US);
String itemType = "";
switch (this.itemTypes.get(meta))
{
case 0:
itemType = ".dust";
break;
case 1:
itemType = ".ingot";
break;
case 2:
// for item/drop
itemType = "";
break;
case 3:
itemType = ".nugget";
break;
}
| String prefix = "item." + Metallurgy.MODID.toLowerCase(Locale.US) + "."; |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/networking/CommonProxy.java | // Path: src/main/java/com/teammetallurgy/metallurgy/handlers/FuelHandler.java
// public class FuelHandler implements IFuelHandler
// {
//
// @Override
// public int getBurnTime(ItemStack fuel)
// {
//
// ItemStack charcoalBlock = new ItemStack(BlockList.getExtraStorageBlock(), 1, 0);
// if (fuel.isItemEqual(charcoalBlock))
// {
// return 16000;
// }
//
// return 0;
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/handlers/WorldTickerMetallurgy.java
// public class WorldTickerMetallurgy extends WorldTicker
// {
// public static HashMap<Integer, ArrayList<ChunkLoc>> chunksToGenerate = new HashMap<Integer, ArrayList<ChunkLoc>>();
//
// @SubscribeEvent
//
// public void worldRetroGen(WorldTickEvent event)
// {
// if (!(event.world instanceof WorldServer))
// {
// return;
// }
//
// WorldServer world = (WorldServer) event.world;
// int dim = world.provider.dimensionId;
// System.currentTimeMillis();
//
// int count = 0;
// ArrayList<ChunkLoc> chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks != null && chunks.size() > 0)
// {
// for (int a = 0; a < 10; a++)
// {
// chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks == null || chunks.size() <= 0)
// {
// break;
// }
// count++;
// ChunkLoc loc = chunks.get(0);
// long worldSeed = world.getSeed();
// Random fmlRandom = new Random(worldSeed);
// long xSeed = fmlRandom.nextLong() >> 3;
// long zSeed = fmlRandom.nextLong() >> 3;
// fmlRandom.setSeed(xSeed * loc.chunkXPos + zSeed * loc.chunkZPos ^ worldSeed);
// this.worldGenerator(world, loc, fmlRandom);
// chunks.remove(0);
// WorldTickerMetallurgy.chunksToGenerate.put(Integer.valueOf(dim), chunks);
// }
//
// if (count > 0)
// {
// LogHandler.log("Regenerated " + count + " chunks. " + Math.max(0, chunks.size()) + " chunks left");
// }
// }
// }
//
// @Override
// public void worldGenerator(WorldServer world, ChunkLoc loc, Random fmlRandom)
// {
// WorldGenMetals.generateAll(fmlRandom, loc.chunkXPos, loc.chunkZPos, world, false);
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
| import com.teammetallurgy.metallurgy.handlers.FuelHandler;
import com.teammetallurgy.metallurgy.handlers.WorldTickerMetallurgy;
import com.teammetallurgy.metallurgy.lib.Configs;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry; | package com.teammetallurgy.metallurgy.networking;
public class CommonProxy
{
public void injectZipAsResource(String zipDir)
{
// TODO Auto-generated method stub
}
public void reloadResources()
{
// Client only
}
public void registerTickHandlers()
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/handlers/FuelHandler.java
// public class FuelHandler implements IFuelHandler
// {
//
// @Override
// public int getBurnTime(ItemStack fuel)
// {
//
// ItemStack charcoalBlock = new ItemStack(BlockList.getExtraStorageBlock(), 1, 0);
// if (fuel.isItemEqual(charcoalBlock))
// {
// return 16000;
// }
//
// return 0;
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/handlers/WorldTickerMetallurgy.java
// public class WorldTickerMetallurgy extends WorldTicker
// {
// public static HashMap<Integer, ArrayList<ChunkLoc>> chunksToGenerate = new HashMap<Integer, ArrayList<ChunkLoc>>();
//
// @SubscribeEvent
//
// public void worldRetroGen(WorldTickEvent event)
// {
// if (!(event.world instanceof WorldServer))
// {
// return;
// }
//
// WorldServer world = (WorldServer) event.world;
// int dim = world.provider.dimensionId;
// System.currentTimeMillis();
//
// int count = 0;
// ArrayList<ChunkLoc> chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks != null && chunks.size() > 0)
// {
// for (int a = 0; a < 10; a++)
// {
// chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks == null || chunks.size() <= 0)
// {
// break;
// }
// count++;
// ChunkLoc loc = chunks.get(0);
// long worldSeed = world.getSeed();
// Random fmlRandom = new Random(worldSeed);
// long xSeed = fmlRandom.nextLong() >> 3;
// long zSeed = fmlRandom.nextLong() >> 3;
// fmlRandom.setSeed(xSeed * loc.chunkXPos + zSeed * loc.chunkZPos ^ worldSeed);
// this.worldGenerator(world, loc, fmlRandom);
// chunks.remove(0);
// WorldTickerMetallurgy.chunksToGenerate.put(Integer.valueOf(dim), chunks);
// }
//
// if (count > 0)
// {
// LogHandler.log("Regenerated " + count + " chunks. " + Math.max(0, chunks.size()) + " chunks left");
// }
// }
// }
//
// @Override
// public void worldGenerator(WorldServer world, ChunkLoc loc, Random fmlRandom)
// {
// WorldGenMetals.generateAll(fmlRandom, loc.chunkXPos, loc.chunkZPos, world, false);
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/networking/CommonProxy.java
import com.teammetallurgy.metallurgy.handlers.FuelHandler;
import com.teammetallurgy.metallurgy.handlers.WorldTickerMetallurgy;
import com.teammetallurgy.metallurgy.lib.Configs;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
package com.teammetallurgy.metallurgy.networking;
public class CommonProxy
{
public void injectZipAsResource(String zipDir)
{
// TODO Auto-generated method stub
}
public void reloadResources()
{
// Client only
}
public void registerTickHandlers()
{ | if (Configs.regen) |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/networking/CommonProxy.java | // Path: src/main/java/com/teammetallurgy/metallurgy/handlers/FuelHandler.java
// public class FuelHandler implements IFuelHandler
// {
//
// @Override
// public int getBurnTime(ItemStack fuel)
// {
//
// ItemStack charcoalBlock = new ItemStack(BlockList.getExtraStorageBlock(), 1, 0);
// if (fuel.isItemEqual(charcoalBlock))
// {
// return 16000;
// }
//
// return 0;
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/handlers/WorldTickerMetallurgy.java
// public class WorldTickerMetallurgy extends WorldTicker
// {
// public static HashMap<Integer, ArrayList<ChunkLoc>> chunksToGenerate = new HashMap<Integer, ArrayList<ChunkLoc>>();
//
// @SubscribeEvent
//
// public void worldRetroGen(WorldTickEvent event)
// {
// if (!(event.world instanceof WorldServer))
// {
// return;
// }
//
// WorldServer world = (WorldServer) event.world;
// int dim = world.provider.dimensionId;
// System.currentTimeMillis();
//
// int count = 0;
// ArrayList<ChunkLoc> chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks != null && chunks.size() > 0)
// {
// for (int a = 0; a < 10; a++)
// {
// chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks == null || chunks.size() <= 0)
// {
// break;
// }
// count++;
// ChunkLoc loc = chunks.get(0);
// long worldSeed = world.getSeed();
// Random fmlRandom = new Random(worldSeed);
// long xSeed = fmlRandom.nextLong() >> 3;
// long zSeed = fmlRandom.nextLong() >> 3;
// fmlRandom.setSeed(xSeed * loc.chunkXPos + zSeed * loc.chunkZPos ^ worldSeed);
// this.worldGenerator(world, loc, fmlRandom);
// chunks.remove(0);
// WorldTickerMetallurgy.chunksToGenerate.put(Integer.valueOf(dim), chunks);
// }
//
// if (count > 0)
// {
// LogHandler.log("Regenerated " + count + " chunks. " + Math.max(0, chunks.size()) + " chunks left");
// }
// }
// }
//
// @Override
// public void worldGenerator(WorldServer world, ChunkLoc loc, Random fmlRandom)
// {
// WorldGenMetals.generateAll(fmlRandom, loc.chunkXPos, loc.chunkZPos, world, false);
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
| import com.teammetallurgy.metallurgy.handlers.FuelHandler;
import com.teammetallurgy.metallurgy.handlers.WorldTickerMetallurgy;
import com.teammetallurgy.metallurgy.lib.Configs;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry; | package com.teammetallurgy.metallurgy.networking;
public class CommonProxy
{
public void injectZipAsResource(String zipDir)
{
// TODO Auto-generated method stub
}
public void reloadResources()
{
// Client only
}
public void registerTickHandlers()
{
if (Configs.regen)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/handlers/FuelHandler.java
// public class FuelHandler implements IFuelHandler
// {
//
// @Override
// public int getBurnTime(ItemStack fuel)
// {
//
// ItemStack charcoalBlock = new ItemStack(BlockList.getExtraStorageBlock(), 1, 0);
// if (fuel.isItemEqual(charcoalBlock))
// {
// return 16000;
// }
//
// return 0;
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/handlers/WorldTickerMetallurgy.java
// public class WorldTickerMetallurgy extends WorldTicker
// {
// public static HashMap<Integer, ArrayList<ChunkLoc>> chunksToGenerate = new HashMap<Integer, ArrayList<ChunkLoc>>();
//
// @SubscribeEvent
//
// public void worldRetroGen(WorldTickEvent event)
// {
// if (!(event.world instanceof WorldServer))
// {
// return;
// }
//
// WorldServer world = (WorldServer) event.world;
// int dim = world.provider.dimensionId;
// System.currentTimeMillis();
//
// int count = 0;
// ArrayList<ChunkLoc> chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks != null && chunks.size() > 0)
// {
// for (int a = 0; a < 10; a++)
// {
// chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks == null || chunks.size() <= 0)
// {
// break;
// }
// count++;
// ChunkLoc loc = chunks.get(0);
// long worldSeed = world.getSeed();
// Random fmlRandom = new Random(worldSeed);
// long xSeed = fmlRandom.nextLong() >> 3;
// long zSeed = fmlRandom.nextLong() >> 3;
// fmlRandom.setSeed(xSeed * loc.chunkXPos + zSeed * loc.chunkZPos ^ worldSeed);
// this.worldGenerator(world, loc, fmlRandom);
// chunks.remove(0);
// WorldTickerMetallurgy.chunksToGenerate.put(Integer.valueOf(dim), chunks);
// }
//
// if (count > 0)
// {
// LogHandler.log("Regenerated " + count + " chunks. " + Math.max(0, chunks.size()) + " chunks left");
// }
// }
// }
//
// @Override
// public void worldGenerator(WorldServer world, ChunkLoc loc, Random fmlRandom)
// {
// WorldGenMetals.generateAll(fmlRandom, loc.chunkXPos, loc.chunkZPos, world, false);
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/networking/CommonProxy.java
import com.teammetallurgy.metallurgy.handlers.FuelHandler;
import com.teammetallurgy.metallurgy.handlers.WorldTickerMetallurgy;
import com.teammetallurgy.metallurgy.lib.Configs;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
package com.teammetallurgy.metallurgy.networking;
public class CommonProxy
{
public void injectZipAsResource(String zipDir)
{
// TODO Auto-generated method stub
}
public void reloadResources()
{
// Client only
}
public void registerTickHandlers()
{
if (Configs.regen)
{ | FMLCommonHandler.instance().bus().register(new WorldTickerMetallurgy()); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/networking/CommonProxy.java | // Path: src/main/java/com/teammetallurgy/metallurgy/handlers/FuelHandler.java
// public class FuelHandler implements IFuelHandler
// {
//
// @Override
// public int getBurnTime(ItemStack fuel)
// {
//
// ItemStack charcoalBlock = new ItemStack(BlockList.getExtraStorageBlock(), 1, 0);
// if (fuel.isItemEqual(charcoalBlock))
// {
// return 16000;
// }
//
// return 0;
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/handlers/WorldTickerMetallurgy.java
// public class WorldTickerMetallurgy extends WorldTicker
// {
// public static HashMap<Integer, ArrayList<ChunkLoc>> chunksToGenerate = new HashMap<Integer, ArrayList<ChunkLoc>>();
//
// @SubscribeEvent
//
// public void worldRetroGen(WorldTickEvent event)
// {
// if (!(event.world instanceof WorldServer))
// {
// return;
// }
//
// WorldServer world = (WorldServer) event.world;
// int dim = world.provider.dimensionId;
// System.currentTimeMillis();
//
// int count = 0;
// ArrayList<ChunkLoc> chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks != null && chunks.size() > 0)
// {
// for (int a = 0; a < 10; a++)
// {
// chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks == null || chunks.size() <= 0)
// {
// break;
// }
// count++;
// ChunkLoc loc = chunks.get(0);
// long worldSeed = world.getSeed();
// Random fmlRandom = new Random(worldSeed);
// long xSeed = fmlRandom.nextLong() >> 3;
// long zSeed = fmlRandom.nextLong() >> 3;
// fmlRandom.setSeed(xSeed * loc.chunkXPos + zSeed * loc.chunkZPos ^ worldSeed);
// this.worldGenerator(world, loc, fmlRandom);
// chunks.remove(0);
// WorldTickerMetallurgy.chunksToGenerate.put(Integer.valueOf(dim), chunks);
// }
//
// if (count > 0)
// {
// LogHandler.log("Regenerated " + count + " chunks. " + Math.max(0, chunks.size()) + " chunks left");
// }
// }
// }
//
// @Override
// public void worldGenerator(WorldServer world, ChunkLoc loc, Random fmlRandom)
// {
// WorldGenMetals.generateAll(fmlRandom, loc.chunkXPos, loc.chunkZPos, world, false);
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
| import com.teammetallurgy.metallurgy.handlers.FuelHandler;
import com.teammetallurgy.metallurgy.handlers.WorldTickerMetallurgy;
import com.teammetallurgy.metallurgy.lib.Configs;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry; | package com.teammetallurgy.metallurgy.networking;
public class CommonProxy
{
public void injectZipAsResource(String zipDir)
{
// TODO Auto-generated method stub
}
public void reloadResources()
{
// Client only
}
public void registerTickHandlers()
{
if (Configs.regen)
{
FMLCommonHandler.instance().bus().register(new WorldTickerMetallurgy());
}
}
public void registerBlockRenderers()
{
}
public void registerEntityRenderers()
{
}
public void registerFuelHandlers()
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/handlers/FuelHandler.java
// public class FuelHandler implements IFuelHandler
// {
//
// @Override
// public int getBurnTime(ItemStack fuel)
// {
//
// ItemStack charcoalBlock = new ItemStack(BlockList.getExtraStorageBlock(), 1, 0);
// if (fuel.isItemEqual(charcoalBlock))
// {
// return 16000;
// }
//
// return 0;
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/handlers/WorldTickerMetallurgy.java
// public class WorldTickerMetallurgy extends WorldTicker
// {
// public static HashMap<Integer, ArrayList<ChunkLoc>> chunksToGenerate = new HashMap<Integer, ArrayList<ChunkLoc>>();
//
// @SubscribeEvent
//
// public void worldRetroGen(WorldTickEvent event)
// {
// if (!(event.world instanceof WorldServer))
// {
// return;
// }
//
// WorldServer world = (WorldServer) event.world;
// int dim = world.provider.dimensionId;
// System.currentTimeMillis();
//
// int count = 0;
// ArrayList<ChunkLoc> chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks != null && chunks.size() > 0)
// {
// for (int a = 0; a < 10; a++)
// {
// chunks = WorldTickerMetallurgy.chunksToGenerate.get(Integer.valueOf(dim));
// if (chunks == null || chunks.size() <= 0)
// {
// break;
// }
// count++;
// ChunkLoc loc = chunks.get(0);
// long worldSeed = world.getSeed();
// Random fmlRandom = new Random(worldSeed);
// long xSeed = fmlRandom.nextLong() >> 3;
// long zSeed = fmlRandom.nextLong() >> 3;
// fmlRandom.setSeed(xSeed * loc.chunkXPos + zSeed * loc.chunkZPos ^ worldSeed);
// this.worldGenerator(world, loc, fmlRandom);
// chunks.remove(0);
// WorldTickerMetallurgy.chunksToGenerate.put(Integer.valueOf(dim), chunks);
// }
//
// if (count > 0)
// {
// LogHandler.log("Regenerated " + count + " chunks. " + Math.max(0, chunks.size()) + " chunks left");
// }
// }
// }
//
// @Override
// public void worldGenerator(WorldServer world, ChunkLoc loc, Random fmlRandom)
// {
// WorldGenMetals.generateAll(fmlRandom, loc.chunkXPos, loc.chunkZPos, world, false);
// }
//
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/networking/CommonProxy.java
import com.teammetallurgy.metallurgy.handlers.FuelHandler;
import com.teammetallurgy.metallurgy.handlers.WorldTickerMetallurgy;
import com.teammetallurgy.metallurgy.lib.Configs;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
package com.teammetallurgy.metallurgy.networking;
public class CommonProxy
{
public void injectZipAsResource(String zipDir)
{
// TODO Auto-generated method stub
}
public void reloadResources()
{
// Client only
}
public void registerTickHandlers()
{
if (Configs.regen)
{
FMLCommonHandler.instance().bus().register(new WorldTickerMetallurgy());
}
}
public void registerBlockRenderers()
{
}
public void registerEntityRenderers()
{
}
public void registerFuelHandlers()
{ | GameRegistry.registerFuelHandler(new FuelHandler()); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/tnt/BlockExplosive.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTNT;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; | package com.teammetallurgy.metallurgy.tnt;
public class BlockExplosive extends BlockTNT
{
private IIcon topIcon;
private IIcon bottomIcon;
private String[] types = { "he", "le", "m", "de", "pe" };
private IIcon[] topIcons = new IIcon[types.length];
private IIcon[] bottomIcons = new IIcon[types.length];
private IIcon[] sideIcons = new IIcon[types.length];
public BlockExplosive()
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/tnt/BlockExplosive.java
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTNT;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
package com.teammetallurgy.metallurgy.tnt;
public class BlockExplosive extends BlockTNT
{
private IIcon topIcon;
private IIcon bottomIcon;
private String[] types = { "he", "le", "m", "de", "pe" };
private IIcon[] topIcons = new IIcon[types.length];
private IIcon[] bottomIcons = new IIcon[types.length];
private IIcon[] sideIcons = new IIcon[types.length];
public BlockExplosive()
{ | this.setCreativeTab(Metallurgy.instance.creativeTabBlocks); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/tools/Shovel.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import java.util.Locale;
import net.minecraft.item.ItemSpade;
import com.teammetallurgy.metallurgy.Metallurgy; | package com.teammetallurgy.metallurgy.tools;
public class Shovel extends ItemSpade
{
public Shovel(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/tools/Shovel.java
import java.util.Locale;
import net.minecraft.item.ItemSpade;
import com.teammetallurgy.metallurgy.Metallurgy;
package com.teammetallurgy.metallurgy.tools;
public class Shovel extends ItemSpade
{
public Shovel(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | this.setUnlocalizedName(Metallurgy.MODID.toLowerCase(Locale.US) + "." + unlocalizedName); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/tools/Hoe.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import java.util.Locale;
import net.minecraft.item.ItemHoe;
import com.teammetallurgy.metallurgy.Metallurgy; | package com.teammetallurgy.metallurgy.tools;
public class Hoe extends ItemHoe
{
public Hoe(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/tools/Hoe.java
import java.util.Locale;
import net.minecraft.item.ItemHoe;
import com.teammetallurgy.metallurgy.Metallurgy;
package com.teammetallurgy.metallurgy.tools;
public class Hoe extends ItemHoe
{
public Hoe(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | this.setUnlocalizedName(Metallurgy.MODID.toLowerCase(Locale.US) + "." + unlocalizedName); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/items/ItemDrawer.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
| import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds; | package com.teammetallurgy.metallurgy.items;
public class ItemDrawer extends Item
{
public ItemDrawer()
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/items/ItemDrawer.java
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
package com.teammetallurgy.metallurgy.items;
public class ItemDrawer extends Item
{
public ItemDrawer()
{ | this.setCreativeTab(Metallurgy.instance.creativeTabItems); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/items/ItemDrawer.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
| import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds; | package com.teammetallurgy.metallurgy.items;
public class ItemDrawer extends Item
{
public ItemDrawer()
{
this.setCreativeTab(Metallurgy.instance.creativeTabItems);
// TODO Change to actual texture when ready
this.iconString = "metallurgy:metal_item_default";
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if (!world.isRemote)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/items/ItemDrawer.java
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
package com.teammetallurgy.metallurgy.items;
public class ItemDrawer extends Item
{
public ItemDrawer()
{
this.setCreativeTab(Metallurgy.instance.creativeTabItems);
// TODO Change to actual texture when ready
this.iconString = "metallurgy:metal_item_default";
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if (!world.isRemote)
{ | player.openGui(Metallurgy.instance, GUIIds.DRAWER, world, (int) player.posX, (int) player.posY, (int) player.posZ); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/tools/Pickaxe.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import java.util.Locale;
import net.minecraft.item.ItemPickaxe;
import com.teammetallurgy.metallurgy.Metallurgy; | package com.teammetallurgy.metallurgy.tools;
public class Pickaxe extends ItemPickaxe
{
public Pickaxe(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/tools/Pickaxe.java
import java.util.Locale;
import net.minecraft.item.ItemPickaxe;
import com.teammetallurgy.metallurgy.Metallurgy;
package com.teammetallurgy.metallurgy.tools;
public class Pickaxe extends ItemPickaxe
{
public Pickaxe(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | this.setUnlocalizedName(Metallurgy.MODID.toLowerCase(Locale.US) + "." + unlocalizedName); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/tools/Sword.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import java.util.List;
import java.util.Locale;
import java.util.Random;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.StatCollector;
import com.teammetallurgy.metallurgy.Metallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; | package com.teammetallurgy.metallurgy.tools;
public class Sword extends ItemSword
{
private int effectId = 0;
private int effectDura = 0;
private int effectAmp = 0;
private int effectReceiver = 0;
public Sword(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/tools/Sword.java
import java.util.List;
import java.util.Locale;
import java.util.Random;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.StatCollector;
import com.teammetallurgy.metallurgy.Metallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
package com.teammetallurgy.metallurgy.tools;
public class Sword extends ItemSword
{
private int effectId = 0;
private int effectDura = 0;
private int effectAmp = 0;
private int effectReceiver = 0;
public Sword(ToolMaterial toolMaterial, String unlocalizedName, String texture)
{
super(toolMaterial);
this.setTextureName(texture); | this.setUnlocalizedName(Metallurgy.MODID.toLowerCase(Locale.US) + "." + unlocalizedName); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import net.minecraft.creativetab.CreativeTabs;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgycore.machines.BlockMetallurgyCore;
| package com.teammetallurgy.metallurgy.machines;
public abstract class BlockMetallurgy extends BlockMetallurgyCore
{
public BlockMetallurgy()
{
this.textureName = "metallurgy:metal_block_default";
this.setHardness(3.5F);
}
@Override
public CreativeTabs getCreativeTabToDisplayOn()
{
| // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
import net.minecraft.creativetab.CreativeTabs;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgycore.machines.BlockMetallurgyCore;
package com.teammetallurgy.metallurgy.machines;
public abstract class BlockMetallurgy extends BlockMetallurgyCore
{
public BlockMetallurgy()
{
this.textureName = "metallurgy:metal_block_default";
this.setHardness(3.5F);
}
@Override
public CreativeTabs getCreativeTabToDisplayOn()
{
| return Metallurgy.instance.creativeTabMachines;
|
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/items/ItemTar.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import com.teammetallurgy.metallurgy.Metallurgy;
import net.minecraft.item.Item; | package com.teammetallurgy.metallurgy.items;
public class ItemTar extends Item
{
public ItemTar()
{
this.setTextureName("metallurgy:misc/tar");
this.setUnlocalizedName("metallurgy.tar");
this.setMaxStackSize(64); | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/items/ItemTar.java
import com.teammetallurgy.metallurgy.Metallurgy;
import net.minecraft.item.Item;
package com.teammetallurgy.metallurgy.items;
public class ItemTar extends Item
{
public ItemTar()
{
this.setTextureName("metallurgy:misc/tar");
this.setUnlocalizedName("metallurgy.tar");
this.setMaxStackSize(64); | this.setCreativeTab(Metallurgy.instance.creativeTabItems); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/nei/CrusherHandler.java | // Path: src/main/java/com/teammetallurgy/metallurgy/recipes/CrusherRecipes.java
// public class CrusherRecipes
// {
// private static CrusherRecipes instance = new CrusherRecipes();
//
// public static CrusherRecipes getInstance()
// {
// return CrusherRecipes.instance;
// }
//
// private final HashMap<String, ItemStack> metaList = new HashMap<String, ItemStack>();
// private final HashMap<String, ItemStack[]> inputList = new HashMap<String, ItemStack[]>();
//
// @Deprecated
// public void addRecipe(int itemID, int itemDamage, ItemStack itemStack)
// {
// this.addRecipe(new ItemStack(Item.getItemById(itemID), 1, itemDamage), itemStack);
// }
//
// public ItemStack getCrushingResult(ItemStack itemStack)
// {
// if (itemStack == null) { return null; }
// return this.metaList.get(itemStack.getUnlocalizedName());
//
// }
//
// public void addRecipe(ItemStack oreItem, ItemStack ret)
// {
// this.metaList.put(oreItem.getUnlocalizedName(), ret);
//
// ItemStack[] inputList = this.inputList.get(ret.getUnlocalizedName());
//
// if (inputList == null)
// {
// inputList = new ItemStack[1];
// inputList[0] = oreItem;
// }
// else
// {
// ItemStack[] newList = new ItemStack[inputList.length + 1];
// for (int i = 0; i < inputList.length; i++)
// {
// newList[i] = inputList[i];
// }
//
// newList[inputList.length] = oreItem;
//
// inputList = newList;
// }
//
// this.inputList.put(ret.getUnlocalizedName(), inputList);
// }
//
// public boolean hasUsage(ItemStack itemStack)
// {
//
// return metaList.containsKey(itemStack.getUnlocalizedName());
//
// }
//
// public HashMap<ItemStack, ItemStack> getInput(ItemStack itemStack)
// {
//
// if (itemStack == null) { return null; }
//
// HashMap<ItemStack, ItemStack> result = new HashMap<ItemStack, ItemStack>();
//
// ItemStack[] inputList = this.inputList.get(itemStack.getUnlocalizedName());
//
// if (inputList == null) { return null; }
//
// for (int i = 0; i < inputList.length; i++)
// {
// result.put(inputList[i], this.getCrushingResult(inputList[i]));
// }
//
// return result;
// }
//
// public HashMap<ItemStack, ItemStack> getRecipes()
// {
// HashMap<ItemStack, ItemStack> recipes = new HashMap<ItemStack, ItemStack>();
//
// for (Entry<String, ItemStack[]> entry : inputList.entrySet())
// {
// ItemStack[] inputs = entry.getValue();
// if (inputs != null && inputs.length > 0)
// {
// for (ItemStack input : inputs)
// {
// recipes.put(input, getCrushingResult(input));
//
// }
// }
// }
// return recipes;
// }
//
// }
| import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import com.teammetallurgy.metallurgy.machines.crusher.GUICrusher;
import com.teammetallurgy.metallurgy.recipes.CrusherRecipes; |
@Override
public String getGuiTexture()
{
return "metallurgy:textures/gui/nei_crusher.png";
}
@Override
public void drawExtras(int recipe)
{
drawProgressBar(77, 22, 176, 14, 12, 24, 48, 1);
}
@Override
public String getRecipeName()
{
return NEIClientUtils.translate("recipe.metallurgy.crusher");
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GUICrusher.class;
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if (outputId.equals("metallurgy.crusher") && getClass() == CrusherHandler.class)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/recipes/CrusherRecipes.java
// public class CrusherRecipes
// {
// private static CrusherRecipes instance = new CrusherRecipes();
//
// public static CrusherRecipes getInstance()
// {
// return CrusherRecipes.instance;
// }
//
// private final HashMap<String, ItemStack> metaList = new HashMap<String, ItemStack>();
// private final HashMap<String, ItemStack[]> inputList = new HashMap<String, ItemStack[]>();
//
// @Deprecated
// public void addRecipe(int itemID, int itemDamage, ItemStack itemStack)
// {
// this.addRecipe(new ItemStack(Item.getItemById(itemID), 1, itemDamage), itemStack);
// }
//
// public ItemStack getCrushingResult(ItemStack itemStack)
// {
// if (itemStack == null) { return null; }
// return this.metaList.get(itemStack.getUnlocalizedName());
//
// }
//
// public void addRecipe(ItemStack oreItem, ItemStack ret)
// {
// this.metaList.put(oreItem.getUnlocalizedName(), ret);
//
// ItemStack[] inputList = this.inputList.get(ret.getUnlocalizedName());
//
// if (inputList == null)
// {
// inputList = new ItemStack[1];
// inputList[0] = oreItem;
// }
// else
// {
// ItemStack[] newList = new ItemStack[inputList.length + 1];
// for (int i = 0; i < inputList.length; i++)
// {
// newList[i] = inputList[i];
// }
//
// newList[inputList.length] = oreItem;
//
// inputList = newList;
// }
//
// this.inputList.put(ret.getUnlocalizedName(), inputList);
// }
//
// public boolean hasUsage(ItemStack itemStack)
// {
//
// return metaList.containsKey(itemStack.getUnlocalizedName());
//
// }
//
// public HashMap<ItemStack, ItemStack> getInput(ItemStack itemStack)
// {
//
// if (itemStack == null) { return null; }
//
// HashMap<ItemStack, ItemStack> result = new HashMap<ItemStack, ItemStack>();
//
// ItemStack[] inputList = this.inputList.get(itemStack.getUnlocalizedName());
//
// if (inputList == null) { return null; }
//
// for (int i = 0; i < inputList.length; i++)
// {
// result.put(inputList[i], this.getCrushingResult(inputList[i]));
// }
//
// return result;
// }
//
// public HashMap<ItemStack, ItemStack> getRecipes()
// {
// HashMap<ItemStack, ItemStack> recipes = new HashMap<ItemStack, ItemStack>();
//
// for (Entry<String, ItemStack[]> entry : inputList.entrySet())
// {
// ItemStack[] inputs = entry.getValue();
// if (inputs != null && inputs.length > 0)
// {
// for (ItemStack input : inputs)
// {
// recipes.put(input, getCrushingResult(input));
//
// }
// }
// }
// return recipes;
// }
//
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/nei/CrusherHandler.java
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import com.teammetallurgy.metallurgy.machines.crusher.GUICrusher;
import com.teammetallurgy.metallurgy.recipes.CrusherRecipes;
@Override
public String getGuiTexture()
{
return "metallurgy:textures/gui/nei_crusher.png";
}
@Override
public void drawExtras(int recipe)
{
drawProgressBar(77, 22, 176, 14, 12, 24, 48, 1);
}
@Override
public String getRecipeName()
{
return NEIClientUtils.translate("recipe.metallurgy.crusher");
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GUICrusher.class;
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if (outputId.equals("metallurgy.crusher") && getClass() == CrusherHandler.class)
{ | HashMap<ItemStack, ItemStack> recipes = CrusherRecipes.getInstance().getRecipes(); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/machines/abstractor/BlockAbstrator.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
| import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy; | package com.teammetallurgy.metallurgy.machines.abstractor;
public class BlockAbstrator extends BlockMetallurgy
{
public BlockAbstrator()
{
super();
this.textureName = "metallurgy:machines/abstractor";
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityAbstractor();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/abstractor/BlockAbstrator.java
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
package com.teammetallurgy.metallurgy.machines.abstractor;
public class BlockAbstrator extends BlockMetallurgy
{
public BlockAbstrator()
{
super();
this.textureName = "metallurgy:machines/abstractor";
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityAbstractor();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | player.openGui(Metallurgy.instance, GUIIds.ABSTRACTOR, world, x, y, z); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/machines/abstractor/BlockAbstrator.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
| import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy; | package com.teammetallurgy.metallurgy.machines.abstractor;
public class BlockAbstrator extends BlockMetallurgy
{
public BlockAbstrator()
{
super();
this.textureName = "metallurgy:machines/abstractor";
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityAbstractor();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/abstractor/BlockAbstrator.java
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
package com.teammetallurgy.metallurgy.machines.abstractor;
public class BlockAbstrator extends BlockMetallurgy
{
public BlockAbstrator()
{
super();
this.textureName = "metallurgy:machines/abstractor";
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityAbstractor();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | player.openGui(Metallurgy.instance, GUIIds.ABSTRACTOR, world, x, y, z); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/machines/crusher/BlockCrusher.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
| import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; | package com.teammetallurgy.metallurgy.machines.crusher;
public class BlockCrusher extends BlockMetallurgy
{
private String topTexture = "metallurgy:machines/mframe_top";
private String sideTexture = "metallurgy:machines/mframe_side";
private String frontTexture = "metallurgy:machines/crusher_front";
private String bottomTexture = "metallurgy:machines/mframe_bottom";
private String frontOnTexture = "metallurgy:machines/crusher_front_on";
private IIcon topIcon;
private IIcon sideIcon;
private IIcon frontIcon;
private IIcon bottomIcon;
private IIcon frontOnIcon;
public BlockCrusher()
{
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityCrusher();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/crusher/BlockCrusher.java
import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
package com.teammetallurgy.metallurgy.machines.crusher;
public class BlockCrusher extends BlockMetallurgy
{
private String topTexture = "metallurgy:machines/mframe_top";
private String sideTexture = "metallurgy:machines/mframe_side";
private String frontTexture = "metallurgy:machines/crusher_front";
private String bottomTexture = "metallurgy:machines/mframe_bottom";
private String frontOnTexture = "metallurgy:machines/crusher_front_on";
private IIcon topIcon;
private IIcon sideIcon;
private IIcon frontIcon;
private IIcon bottomIcon;
private IIcon frontOnIcon;
public BlockCrusher()
{
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityCrusher();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | player.openGui(Metallurgy.instance, GUIIds.CRUSHER, world, x, y, z); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/machines/crusher/BlockCrusher.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
| import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; | package com.teammetallurgy.metallurgy.machines.crusher;
public class BlockCrusher extends BlockMetallurgy
{
private String topTexture = "metallurgy:machines/mframe_top";
private String sideTexture = "metallurgy:machines/mframe_side";
private String frontTexture = "metallurgy:machines/crusher_front";
private String bottomTexture = "metallurgy:machines/mframe_bottom";
private String frontOnTexture = "metallurgy:machines/crusher_front_on";
private IIcon topIcon;
private IIcon sideIcon;
private IIcon frontIcon;
private IIcon bottomIcon;
private IIcon frontOnIcon;
public BlockCrusher()
{
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityCrusher();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/crusher/BlockCrusher.java
import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
package com.teammetallurgy.metallurgy.machines.crusher;
public class BlockCrusher extends BlockMetallurgy
{
private String topTexture = "metallurgy:machines/mframe_top";
private String sideTexture = "metallurgy:machines/mframe_side";
private String frontTexture = "metallurgy:machines/crusher_front";
private String bottomTexture = "metallurgy:machines/mframe_bottom";
private String frontOnTexture = "metallurgy:machines/crusher_front_on";
private IIcon topIcon;
private IIcon sideIcon;
private IIcon frontIcon;
private IIcon bottomIcon;
private IIcon frontOnIcon;
public BlockCrusher()
{
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityCrusher();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | player.openGui(Metallurgy.instance, GUIIds.CRUSHER, world, x, y, z); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/metals/Metal.java | // Path: src/main/java/com/teammetallurgy/metallurgy/api/IMetalInfo.java
// public interface IMetalInfo
// {
// public String getName();
//
// public MetalType getType();
//
// public int getBlockLevel();
//
// /**
// * Gets the tool's attack damage
// *
// * @return
// * The tool's attack damage, and -1 if invalid
// */
// public int getToolDamage();
//
// /**
// * Gets the tool's durability
// *
// * @return
// * The tool's durability, and -1 if invalid
// */
// public int getToolDurability();
//
// /**
// * Gets the tool's efficiency (speed)
// *
// * @return
// * The tool's efficiency , and -1 if invalid
// */
// public int getToolEfficiency();
//
// /**
// * Gets the tool's efficiency (speed)
// *
// * @return
// * The tool's efficiency , and -1 if invalid
// */
// public int getToolEncantabilty();
//
// /**
// * Gets the tool's harvest level
// *
// * @return
// * the tool's harvest level, and -1 if invalid
// */
// public int getToolHarvestLevel();
//
// public boolean haveTools();
//
// public boolean haveArmor();
//
// /**
// * Gets the Armor Multiplier
// *
// * @return
// * the armor's multiplier, and -1 if invalid.
// */
// public int getArmorMultiplier();
//
// /**
// * Gets the Armor Damage Reduction array
// *
// * @return
// * The armor's Damage Reduction array, and null if invalid.
// */
// public int[] getArmorDamageReduction();
//
// /**
// * Gets the Armor enchantability
// *
// * @return
// * the armor's enchantability, and -1 if invalid.
// */
// public int getArmorEnchantability();
//
// public boolean isAlloyerRequired();
//
// public String[] getAliases();
//
// public String[] getDropOreDicNames();
//
// /**
// * Gets Generation information
// *
// * @return
// * An integer array with the following: <br />
// * 0: Veins Pre Chunk, 1: ores Pre Chunk, 2: minLvl, 3:maxLvl, <br />
// * 4: Vein Chance PreChunk, 5: Vine Density
// */
// public int[] getGeneration();
//
// public String getDimentions();
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/api/MetalType.java
// public enum MetalType
// {
// Respawn, Ore, Catalyst, Alloy, Drop, Default, Unknown
// }
| import com.teammetallurgy.metallurgy.api.IMetalInfo;
import com.teammetallurgy.metallurgy.api.MetalType; | package com.teammetallurgy.metallurgy.metals;
public class Metal implements IMetalInfo
{
private String name;
private String[] nameAliases; | // Path: src/main/java/com/teammetallurgy/metallurgy/api/IMetalInfo.java
// public interface IMetalInfo
// {
// public String getName();
//
// public MetalType getType();
//
// public int getBlockLevel();
//
// /**
// * Gets the tool's attack damage
// *
// * @return
// * The tool's attack damage, and -1 if invalid
// */
// public int getToolDamage();
//
// /**
// * Gets the tool's durability
// *
// * @return
// * The tool's durability, and -1 if invalid
// */
// public int getToolDurability();
//
// /**
// * Gets the tool's efficiency (speed)
// *
// * @return
// * The tool's efficiency , and -1 if invalid
// */
// public int getToolEfficiency();
//
// /**
// * Gets the tool's efficiency (speed)
// *
// * @return
// * The tool's efficiency , and -1 if invalid
// */
// public int getToolEncantabilty();
//
// /**
// * Gets the tool's harvest level
// *
// * @return
// * the tool's harvest level, and -1 if invalid
// */
// public int getToolHarvestLevel();
//
// public boolean haveTools();
//
// public boolean haveArmor();
//
// /**
// * Gets the Armor Multiplier
// *
// * @return
// * the armor's multiplier, and -1 if invalid.
// */
// public int getArmorMultiplier();
//
// /**
// * Gets the Armor Damage Reduction array
// *
// * @return
// * The armor's Damage Reduction array, and null if invalid.
// */
// public int[] getArmorDamageReduction();
//
// /**
// * Gets the Armor enchantability
// *
// * @return
// * the armor's enchantability, and -1 if invalid.
// */
// public int getArmorEnchantability();
//
// public boolean isAlloyerRequired();
//
// public String[] getAliases();
//
// public String[] getDropOreDicNames();
//
// /**
// * Gets Generation information
// *
// * @return
// * An integer array with the following: <br />
// * 0: Veins Pre Chunk, 1: ores Pre Chunk, 2: minLvl, 3:maxLvl, <br />
// * 4: Vein Chance PreChunk, 5: Vine Density
// */
// public int[] getGeneration();
//
// public String getDimentions();
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/api/MetalType.java
// public enum MetalType
// {
// Respawn, Ore, Catalyst, Alloy, Drop, Default, Unknown
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/metals/Metal.java
import com.teammetallurgy.metallurgy.api.IMetalInfo;
import com.teammetallurgy.metallurgy.api.MetalType;
package com.teammetallurgy.metallurgy.metals;
public class Metal implements IMetalInfo
{
private String name;
private String[] nameAliases; | public MetalType type; |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/machines/alloyer/BlockAlloyer.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
| import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; | package com.teammetallurgy.metallurgy.machines.alloyer;
public class BlockAlloyer extends BlockMetallurgy
{
private String topTexture = "metallurgy:machines/alloyer_top";
private String sideTexture = "metallurgy:machines/alloyer_side";
private String frontTexture = "metallurgy:machines/alloyer_front";
private String bottomTexture = "metallurgy:machines/alloyer_bottom";
private String frontOnTexture = "metallurgy:machines/alloyer_front_on";
private IIcon topIcon;
private IIcon sideIcon;
private IIcon frontIcon;
private IIcon bottomIcon;
private IIcon frontOnIcon;
public BlockAlloyer()
{
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityAlloyer();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/alloyer/BlockAlloyer.java
import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
package com.teammetallurgy.metallurgy.machines.alloyer;
public class BlockAlloyer extends BlockMetallurgy
{
private String topTexture = "metallurgy:machines/alloyer_top";
private String sideTexture = "metallurgy:machines/alloyer_side";
private String frontTexture = "metallurgy:machines/alloyer_front";
private String bottomTexture = "metallurgy:machines/alloyer_bottom";
private String frontOnTexture = "metallurgy:machines/alloyer_front_on";
private IIcon topIcon;
private IIcon sideIcon;
private IIcon frontIcon;
private IIcon bottomIcon;
private IIcon frontOnIcon;
public BlockAlloyer()
{
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityAlloyer();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | player.openGui(Metallurgy.instance, GUIIds.ALLOYER, world, x, y, z); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/machines/alloyer/BlockAlloyer.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
| import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; | package com.teammetallurgy.metallurgy.machines.alloyer;
public class BlockAlloyer extends BlockMetallurgy
{
private String topTexture = "metallurgy:machines/alloyer_top";
private String sideTexture = "metallurgy:machines/alloyer_side";
private String frontTexture = "metallurgy:machines/alloyer_front";
private String bottomTexture = "metallurgy:machines/alloyer_bottom";
private String frontOnTexture = "metallurgy:machines/alloyer_front_on";
private IIcon topIcon;
private IIcon sideIcon;
private IIcon frontIcon;
private IIcon bottomIcon;
private IIcon frontOnIcon;
public BlockAlloyer()
{
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityAlloyer();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/lib/GUIIds.java
// public class GUIIds
// {
// public static final int CRUSHER = 0;
// public static final int ALLOYER = 1;
// public static final int FORGE = 2;
// public static final int DRAWER = 3;
// public static final int ABSTRACTOR = 4;
// }
//
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/BlockMetallurgy.java
// public abstract class BlockMetallurgy extends BlockMetallurgyCore
// {
//
// public BlockMetallurgy()
// {
// this.textureName = "metallurgy:metal_block_default";
// this.setHardness(3.5F);
//
// }
//
// @Override
// public CreativeTabs getCreativeTabToDisplayOn()
// {
// return Metallurgy.instance.creativeTabMachines;
// }
//
// @Override
// public int getRenderType()
// {
// return RenderBlockMachine.renderId;
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/alloyer/BlockAlloyer.java
import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.teammetallurgy.metallurgy.Metallurgy;
import com.teammetallurgy.metallurgy.lib.GUIIds;
import com.teammetallurgy.metallurgy.machines.BlockMetallurgy;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
package com.teammetallurgy.metallurgy.machines.alloyer;
public class BlockAlloyer extends BlockMetallurgy
{
private String topTexture = "metallurgy:machines/alloyer_top";
private String sideTexture = "metallurgy:machines/alloyer_side";
private String frontTexture = "metallurgy:machines/alloyer_front";
private String bottomTexture = "metallurgy:machines/alloyer_bottom";
private String frontOnTexture = "metallurgy:machines/alloyer_front_on";
private IIcon topIcon;
private IIcon sideIcon;
private IIcon frontIcon;
private IIcon bottomIcon;
private IIcon frontOnIcon;
public BlockAlloyer()
{
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityAlloyer();
}
@Override
protected void doOnActivate(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
{ | player.openGui(Metallurgy.instance, GUIIds.ALLOYER, world, x, y, z); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/nei/AbstractorHandler.java | // Path: src/main/java/com/teammetallurgy/metallurgy/machines/abstractor/GUIAbstrator.java
// public class GUIAbstrator extends GUIMetallurgyMachine
// {
//
// public GUIAbstrator(ContainerMetallurgyMachine container)
// {
// super(container, "metallurgy:textures/gui/abstractor.png");
// }
//
// @Override
// public void initGui()
// {
// super.initGui();
// this.xSize = 175;
// this.ySize = 165;
// }
//
// @Override
// protected void drawGuiContainerBackgroundLayer(float renderTicks, int x, int y)
// {
// super.drawGuiContainerBackgroundLayer(renderTicks, x, y);
//
// // draw the background of the slots if they are empty
//
// // Fuel
// if (this.tileEntity.getStackInSlot(0) == null)
// this.drawTexturedModalRect(this.guiLeft + 25, this.guiTop + 55, 194, 47, 18, 18);
//
// // Catalyst
// if (this.tileEntity.getStackInSlot(1) == null)
// this.drawTexturedModalRect(this.guiLeft + 16, this.guiTop + 18, 176, 29, 18, 18);
//
// // Ingot
// if (this.tileEntity.getStackInSlot(2) == null)
// this.drawTexturedModalRect(this.guiLeft + 35, this.guiTop + 18, 194, 29, 18, 18);
//
// // Bottle
// if (this.tileEntity.getStackInSlot(3) == null)
// this.drawTexturedModalRect(this.guiLeft + 61, this.guiTop + 55, 176, 47, 18, 18);
//
//
// // Progress bars
//
// // Burning
// int burning = 0;
// int maxBurning = 15;
//
// if (burning < 0)
// burning = 0;
// if (burning > maxBurning)
// burning = maxBurning;
//
// this.drawTexturedModalRect(this.guiLeft + 27, this.guiTop + 40 + maxBurning - burning, 176, 0, 15, burning);
//
// // Processing
// int processing = 0;
// int maxProcessing = 30;
//
// if (processing < 0)
// processing = 0;
// if (processing > maxProcessing)
// processing = maxProcessing;
//
// this.drawTexturedModalRect(this.guiLeft + 59, this.guiTop + 20, 177, 15, processing, 14);
//
// // Essence Tank
// int essenceLevel = 0;
// int maxEssenceLevel = 53;
//
// if (essenceLevel < 0)
// essenceLevel = 0;
// if (essenceLevel > maxEssenceLevel)
// essenceLevel = maxEssenceLevel;
//
// this.drawTexturedModalRect(this.guiLeft + 98, this.guiTop + 19 + maxEssenceLevel - essenceLevel, 176, 65, 16, essenceLevel);
//
// }
//
// @Override
// protected void drawTitle(int x, int y)
// {
// // no needs to display the title
// }
// }
| import java.util.List;
import com.teammetallurgy.metallurgy.machines.abstractor.GUIAbstrator;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler; | package com.teammetallurgy.metallurgy.nei;
public class AbstractorHandler extends TemplateRecipeHandler
{
@Override
public String getRecipeName()
{
return NEIClientUtils.translate("recipe.metallurgy.abstractor");
}
@Override
public String getGuiTexture()
{
return "metallurgy:textures/gui/abstractor.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/machines/abstractor/GUIAbstrator.java
// public class GUIAbstrator extends GUIMetallurgyMachine
// {
//
// public GUIAbstrator(ContainerMetallurgyMachine container)
// {
// super(container, "metallurgy:textures/gui/abstractor.png");
// }
//
// @Override
// public void initGui()
// {
// super.initGui();
// this.xSize = 175;
// this.ySize = 165;
// }
//
// @Override
// protected void drawGuiContainerBackgroundLayer(float renderTicks, int x, int y)
// {
// super.drawGuiContainerBackgroundLayer(renderTicks, x, y);
//
// // draw the background of the slots if they are empty
//
// // Fuel
// if (this.tileEntity.getStackInSlot(0) == null)
// this.drawTexturedModalRect(this.guiLeft + 25, this.guiTop + 55, 194, 47, 18, 18);
//
// // Catalyst
// if (this.tileEntity.getStackInSlot(1) == null)
// this.drawTexturedModalRect(this.guiLeft + 16, this.guiTop + 18, 176, 29, 18, 18);
//
// // Ingot
// if (this.tileEntity.getStackInSlot(2) == null)
// this.drawTexturedModalRect(this.guiLeft + 35, this.guiTop + 18, 194, 29, 18, 18);
//
// // Bottle
// if (this.tileEntity.getStackInSlot(3) == null)
// this.drawTexturedModalRect(this.guiLeft + 61, this.guiTop + 55, 176, 47, 18, 18);
//
//
// // Progress bars
//
// // Burning
// int burning = 0;
// int maxBurning = 15;
//
// if (burning < 0)
// burning = 0;
// if (burning > maxBurning)
// burning = maxBurning;
//
// this.drawTexturedModalRect(this.guiLeft + 27, this.guiTop + 40 + maxBurning - burning, 176, 0, 15, burning);
//
// // Processing
// int processing = 0;
// int maxProcessing = 30;
//
// if (processing < 0)
// processing = 0;
// if (processing > maxProcessing)
// processing = maxProcessing;
//
// this.drawTexturedModalRect(this.guiLeft + 59, this.guiTop + 20, 177, 15, processing, 14);
//
// // Essence Tank
// int essenceLevel = 0;
// int maxEssenceLevel = 53;
//
// if (essenceLevel < 0)
// essenceLevel = 0;
// if (essenceLevel > maxEssenceLevel)
// essenceLevel = maxEssenceLevel;
//
// this.drawTexturedModalRect(this.guiLeft + 98, this.guiTop + 19 + maxEssenceLevel - essenceLevel, 176, 65, 16, essenceLevel);
//
// }
//
// @Override
// protected void drawTitle(int x, int y)
// {
// // no needs to display the title
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/nei/AbstractorHandler.java
import java.util.List;
import com.teammetallurgy.metallurgy.machines.abstractor.GUIAbstrator;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
package com.teammetallurgy.metallurgy.nei;
public class AbstractorHandler extends TemplateRecipeHandler
{
@Override
public String getRecipeName()
{
return NEIClientUtils.translate("recipe.metallurgy.abstractor");
}
@Override
public String getGuiTexture()
{
return "metallurgy:textures/gui/abstractor.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{ | return GUIAbstrator.class; |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/items/ItemFeritilizer.java | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
| import com.teammetallurgy.metallurgy.Metallurgy;
import cpw.mods.fml.common.eventhandler.Event.Result;
import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.BonemealEvent; | package com.teammetallurgy.metallurgy.items;
public class ItemFeritilizer extends Item
{
public ItemFeritilizer()
{
this.setTextureName("metallurgy:misc/fertilizer");
this.setUnlocalizedName("metallurgy.fertilizer");
this.setMaxStackSize(64); | // Path: src/main/java/com/teammetallurgy/metallurgy/Metallurgy.java
// @Mod(name = Metallurgy.MODNAME, modid = Metallurgy.MODID, version = Metallurgy.VERSION, dependencies = Metallurgy.DEPS)
// public class Metallurgy
// {
// public static final String MODNAME = "Metallurgy";
// public static final String MODID = "Metallurgy";
// public static final String VERSION = "4.0.9";
// public static final String DEPS = "required-after:MetallurgyCore@[4.0.5,];before:UndergroundBiomes;after:Botania;after:TConstruct";
//
// @Mod.Instance(Metallurgy.MODID)
// public static Metallurgy instance;
//
// @SidedProxy(clientSide = "com.teammetallurgy.metallurgy.networking.ClientProxy", serverSide = "com.teammetallurgy.metallurgy.networking.CommonProxy")
// public static CommonProxy proxy;
//
// public CreativeTab creativeTabMachines = new CreativeTab(Metallurgy.MODID + ".Machines");
// public CreativeTab creativeTabBlocks = new CreativeTab(Metallurgy.MODID + ".Blocks");
// public CreativeTab creativeTabItems = new CreativeTab(Metallurgy.MODID + ".Items");
// public CreativeTab creativeTabTools = new CreativeTab(Metallurgy.MODID + ".Tools");
// public CreativeTab creativeTabArmor = new CreativeTab(Metallurgy.MODID + ".Armor");
//
// private File modsFolder;
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent event)
// {
// VanillaMetals.initRecipes();
// ItemList.addRecipes();
// BlockList.initRecipies();
// MetalMaterials.Instance.addRecipes();
//
// NetworkRegistry.INSTANCE.registerGuiHandler(Metallurgy.instance, new GUIHandlerMetallurgy());
// Metallurgy.proxy.registerTickHandlers();
// Metallurgy.proxy.registerBlockRenderers();
// Metallurgy.proxy.registerEntityRenderers();
// Metallurgy.proxy.registerFuelHandlers();
// MinecraftForge.EVENT_BUS.register(new EventHandlerMetallurgy());
//
// Integration.init(event);
// }
//
// private void initTabs()
// {
// creativeTabMachines.setItem(BlockList.getAlloyer());
// creativeTabBlocks.setItemStack(new ItemStack(BlockList.tabBlock));
// creativeTabItems.setItemStack(new ItemStack(ItemList.tabItem));
// creativeTabTools.setItemStack(new ItemStack(ItemList.tabItem,1,1));
// creativeTabArmor.setItemStack(new ItemStack(ItemList.tabItem,1,2));
// }
//
// public String modsPath()
// {
// try
// {
// return this.modsFolder.getCanonicalPath();
// }
// catch (IOException e)
// {
// return "";
// }
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event)
// {
// Utils.injectOreDictionaryRecipes();
// Integration.postinit(event);
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// LogHandler.setLog(event.getModLog());
// ConfigHandler.setFile(event.getSuggestedConfigurationFile());
//
// Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");
//
// if (value instanceof File)
// {
// this.modsFolder = (File) value;
// }
//
// Configs.init();
// BlockList.init();
// ItemList.init();
// BucketsHandler.instance.init();
//
// initTabs();
//
// Integration.preinit(event);
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/items/ItemFeritilizer.java
import com.teammetallurgy.metallurgy.Metallurgy;
import cpw.mods.fml.common.eventhandler.Event.Result;
import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.BonemealEvent;
package com.teammetallurgy.metallurgy.items;
public class ItemFeritilizer extends Item
{
public ItemFeritilizer()
{
this.setTextureName("metallurgy:misc/fertilizer");
this.setUnlocalizedName("metallurgy.fertilizer");
this.setMaxStackSize(64); | this.setCreativeTab(Metallurgy.instance.creativeTabItems); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/machines/alloyer/TileEntityAlloyer.java | // Path: src/main/java/com/teammetallurgy/metallurgy/recipes/AlloyerRecipes.java
// public class AlloyerRecipes
// {
//
// public class AlloyRecipe
// {
// private final ItemStack baseItem;
// private final ItemStack first;
// private final ItemStack result;
//
// public AlloyRecipe(final ItemStack first, final ItemStack baseItem, final ItemStack result)
// {
// this.first = first;
// this.baseItem = baseItem;
// this.result = result;
// }
//
// public ItemStack getCraftingResult()
// {
// return this.result.copy();
// }
//
// public ItemStack[] getIngredients()
// {
// return new ItemStack[] { this.first, this.baseItem };
// }
//
// public boolean matches(final ItemStack first, final ItemStack second)
// {
// if (first.isItemEqual(second)) { return false; }
//
// if (this.uses(first) && this.uses(second)) { return true; }
//
// if (this.uses(first) && (second == null)) { return true; }
//
// if (this.uses(second) && (first == null)) { return true; }
//
// return this.matchesOreDict(first, second);
// }
//
// private boolean matchesOreDict(final ItemStack first, final ItemStack second)
// {
// if (RecipeUtils.matchesOreDict(first,this.first) && RecipeUtils.matchesOreDict(second, this.baseItem)) { return true; }
//
// if (RecipeUtils.matchesOreDict(first,this.baseItem) && RecipeUtils.matchesOreDict(second, this.first)) { return true; }
//
// if (RecipeUtils.matchesOreDict(first, this.first) && (second == null)) { return true; }
//
// if (RecipeUtils.matchesOreDict(second, this.first) && (first == null)) { return true; }
//
// return false;
// }
//
// public boolean uses(final ItemStack ingredient)
// {
// if (ingredient == null) { return false; }
//
// if ((this.first != null) && this.first.isItemEqual(ingredient))
// {
// return true;
// }
// else if ((this.baseItem != null) && this.baseItem.isItemEqual(ingredient)) { return true; }
//
// return false;
// }
// }
//
// private static AlloyerRecipes instance = new AlloyerRecipes();
//
// public static AlloyerRecipes getInstance()
// {
// return AlloyerRecipes.instance;
// }
//
// private final ArrayList<AlloyRecipe> recipes = new ArrayList<AlloyRecipe>();
//
// public void addRecipe(ItemStack itemStack, ItemStack otherItemStack, ItemStack output)
// {
// this.recipes.add(new AlloyRecipe(itemStack, otherItemStack, output));
// }
//
// public ItemStack getAlloyResult(ItemStack itemStack, ItemStack otherItemStack)
// {
// for (int j = 0; j < this.recipes.size(); ++j)
// {
// AlloyRecipe irecipe = this.recipes.get(j);
//
// if (irecipe.matches(itemStack, otherItemStack)) { return irecipe.getCraftingResult(); }
// }
//
// return null;
// }
//
// public boolean hasUsage(ItemStack itemStack)
// {
// for (int j = 0; j < this.recipes.size(); ++j)
// {
// AlloyRecipe irecipe = this.recipes.get(j);
//
// if (irecipe.uses(itemStack)) { return true; }
// }
// return false;
// }
//
// public ArrayList<AlloyRecipe> getRecipesFor(ItemStack output)
// {
// ArrayList<AlloyRecipe> list = new ArrayList<AlloyRecipe>();
//
// for (AlloyRecipe alloyRecipe : this.recipes)
// {
// if (alloyRecipe.result.isItemEqual(output) && alloyRecipe.result.stackTagCompound == output.stackTagCompound)
// {
// list.add(alloyRecipe);
// }
// }
// return list;
// }
//
// public ArrayList<AlloyRecipe> getRecipesUsing(ItemStack ingredient)
// {
// ArrayList<AlloyRecipe> list = new ArrayList<AlloyRecipe>();
//
// for (AlloyRecipe alloyRecipe : this.recipes)
// {
// if (alloyRecipe.uses(ingredient))
// {
// list.add(alloyRecipe);
// continue;
// }
//
// if (RecipeUtils.matchesOreDict(ingredient, alloyRecipe.first))
// {
// list.add(new AlloyRecipe(ingredient, alloyRecipe.baseItem.copy(), alloyRecipe.result.copy()));
// continue;
// }
//
// if (RecipeUtils.matchesOreDict(ingredient, alloyRecipe.baseItem))
// {
// list.add(new AlloyRecipe(alloyRecipe.first.copy(), ingredient, alloyRecipe.result.copy()));
// }
// }
// return list;
// }
//
// public ArrayList<AlloyRecipe> getRecipes()
// {
// return recipes;
// }
// }
| import net.minecraft.item.ItemStack;
import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgySided; | package com.teammetallurgy.metallurgy.machines.alloyer;
public class TileEntityAlloyer extends TileEntityMetallurgySided
{
private static final int FUEL_SLOT = 1;
public TileEntityAlloyer()
{
super(4, new int[] { 0, 2 }, new int[] { TileEntityAlloyer.FUEL_SLOT }, new int[] { TileEntityAlloyer.FUEL_SLOT, 3 });
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public String getInventoryName()
{
return "container.alloyer";
}
@Override
public ItemStack getSmeltingResult(ItemStack... itemStack)
{ | // Path: src/main/java/com/teammetallurgy/metallurgy/recipes/AlloyerRecipes.java
// public class AlloyerRecipes
// {
//
// public class AlloyRecipe
// {
// private final ItemStack baseItem;
// private final ItemStack first;
// private final ItemStack result;
//
// public AlloyRecipe(final ItemStack first, final ItemStack baseItem, final ItemStack result)
// {
// this.first = first;
// this.baseItem = baseItem;
// this.result = result;
// }
//
// public ItemStack getCraftingResult()
// {
// return this.result.copy();
// }
//
// public ItemStack[] getIngredients()
// {
// return new ItemStack[] { this.first, this.baseItem };
// }
//
// public boolean matches(final ItemStack first, final ItemStack second)
// {
// if (first.isItemEqual(second)) { return false; }
//
// if (this.uses(first) && this.uses(second)) { return true; }
//
// if (this.uses(first) && (second == null)) { return true; }
//
// if (this.uses(second) && (first == null)) { return true; }
//
// return this.matchesOreDict(first, second);
// }
//
// private boolean matchesOreDict(final ItemStack first, final ItemStack second)
// {
// if (RecipeUtils.matchesOreDict(first,this.first) && RecipeUtils.matchesOreDict(second, this.baseItem)) { return true; }
//
// if (RecipeUtils.matchesOreDict(first,this.baseItem) && RecipeUtils.matchesOreDict(second, this.first)) { return true; }
//
// if (RecipeUtils.matchesOreDict(first, this.first) && (second == null)) { return true; }
//
// if (RecipeUtils.matchesOreDict(second, this.first) && (first == null)) { return true; }
//
// return false;
// }
//
// public boolean uses(final ItemStack ingredient)
// {
// if (ingredient == null) { return false; }
//
// if ((this.first != null) && this.first.isItemEqual(ingredient))
// {
// return true;
// }
// else if ((this.baseItem != null) && this.baseItem.isItemEqual(ingredient)) { return true; }
//
// return false;
// }
// }
//
// private static AlloyerRecipes instance = new AlloyerRecipes();
//
// public static AlloyerRecipes getInstance()
// {
// return AlloyerRecipes.instance;
// }
//
// private final ArrayList<AlloyRecipe> recipes = new ArrayList<AlloyRecipe>();
//
// public void addRecipe(ItemStack itemStack, ItemStack otherItemStack, ItemStack output)
// {
// this.recipes.add(new AlloyRecipe(itemStack, otherItemStack, output));
// }
//
// public ItemStack getAlloyResult(ItemStack itemStack, ItemStack otherItemStack)
// {
// for (int j = 0; j < this.recipes.size(); ++j)
// {
// AlloyRecipe irecipe = this.recipes.get(j);
//
// if (irecipe.matches(itemStack, otherItemStack)) { return irecipe.getCraftingResult(); }
// }
//
// return null;
// }
//
// public boolean hasUsage(ItemStack itemStack)
// {
// for (int j = 0; j < this.recipes.size(); ++j)
// {
// AlloyRecipe irecipe = this.recipes.get(j);
//
// if (irecipe.uses(itemStack)) { return true; }
// }
// return false;
// }
//
// public ArrayList<AlloyRecipe> getRecipesFor(ItemStack output)
// {
// ArrayList<AlloyRecipe> list = new ArrayList<AlloyRecipe>();
//
// for (AlloyRecipe alloyRecipe : this.recipes)
// {
// if (alloyRecipe.result.isItemEqual(output) && alloyRecipe.result.stackTagCompound == output.stackTagCompound)
// {
// list.add(alloyRecipe);
// }
// }
// return list;
// }
//
// public ArrayList<AlloyRecipe> getRecipesUsing(ItemStack ingredient)
// {
// ArrayList<AlloyRecipe> list = new ArrayList<AlloyRecipe>();
//
// for (AlloyRecipe alloyRecipe : this.recipes)
// {
// if (alloyRecipe.uses(ingredient))
// {
// list.add(alloyRecipe);
// continue;
// }
//
// if (RecipeUtils.matchesOreDict(ingredient, alloyRecipe.first))
// {
// list.add(new AlloyRecipe(ingredient, alloyRecipe.baseItem.copy(), alloyRecipe.result.copy()));
// continue;
// }
//
// if (RecipeUtils.matchesOreDict(ingredient, alloyRecipe.baseItem))
// {
// list.add(new AlloyRecipe(alloyRecipe.first.copy(), ingredient, alloyRecipe.result.copy()));
// }
// }
// return list;
// }
//
// public ArrayList<AlloyRecipe> getRecipes()
// {
// return recipes;
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/machines/alloyer/TileEntityAlloyer.java
import net.minecraft.item.ItemStack;
import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes;
import com.teammetallurgy.metallurgycore.machines.TileEntityMetallurgySided;
package com.teammetallurgy.metallurgy.machines.alloyer;
public class TileEntityAlloyer extends TileEntityMetallurgySided
{
private static final int FUEL_SLOT = 1;
public TileEntityAlloyer()
{
super(4, new int[] { 0, 2 }, new int[] { TileEntityAlloyer.FUEL_SLOT }, new int[] { TileEntityAlloyer.FUEL_SLOT, 3 });
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public String getInventoryName()
{
return "container.alloyer";
}
@Override
public ItemStack getSmeltingResult(ItemStack... itemStack)
{ | return AlloyerRecipes.getInstance().getAlloyResult(itemStack[0], itemStack[1]); |
TeamMetallurgy/Metallurgy4 | src/main/java/com/teammetallurgy/metallurgy/handlers/EventHandlerMetallurgy.java | // Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
| import java.util.ArrayList;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.event.world.ChunkDataEvent;
import com.teammetallurgy.metallurgy.lib.Configs;
import com.teammetallurgy.metallurgycore.handlers.ChunkLoc;
import com.teammetallurgy.metallurgycore.handlers.EventHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | package com.teammetallurgy.metallurgy.handlers;
public class EventHandlerMetallurgy extends EventHandler
{
@SubscribeEvent
@Override
public void chunkLoad(ChunkDataEvent.Load event)
{
int dim = event.world.provider.dimensionId;
Chunk regenChunk = event.getChunk();
NBTTagCompound chunkNBT = event.getData().getCompoundTag(this.getModTag()); | // Path: src/main/java/com/teammetallurgy/metallurgy/lib/Configs.java
// public class Configs
// {
// public static boolean enabledOreParticles = true;
// public static boolean regen = false;
// public static String regen_key = "DEFAULT";
//
// public static void init()
// {
// Configs.enabledOreParticles = ConfigHandler.clientEnabled("ore_particales", enabledOreParticles);
// Configs.regen = ConfigHandler.regen();
// Configs.regen_key = ConfigHandler.regenKey();
// }
// }
// Path: src/main/java/com/teammetallurgy/metallurgy/handlers/EventHandlerMetallurgy.java
import java.util.ArrayList;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.event.world.ChunkDataEvent;
import com.teammetallurgy.metallurgy.lib.Configs;
import com.teammetallurgy.metallurgycore.handlers.ChunkLoc;
import com.teammetallurgy.metallurgycore.handlers.EventHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
package com.teammetallurgy.metallurgy.handlers;
public class EventHandlerMetallurgy extends EventHandler
{
@SubscribeEvent
@Override
public void chunkLoad(ChunkDataEvent.Load event)
{
int dim = event.world.provider.dimensionId;
Chunk regenChunk = event.getChunk();
NBTTagCompound chunkNBT = event.getData().getCompoundTag(this.getModTag()); | if (Configs.regen && !Configs.regen_key.equals("") && !Configs.regen_key.equals(chunkNBT.getString("regen_key"))) |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/host/ExistingCloudHost.java | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
| import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.host;
class ExistingCloudHost implements CloudHost {
private final String hostname;
public ExistingCloudHost(String hostLabel) { | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
// Path: src/main/java/com/xebialabs/overcast/host/ExistingCloudHost.java
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.host;
class ExistingCloudHost implements CloudHost {
private final String hostname;
public ExistingCloudHost(String hostLabel) { | this.hostname = getOvercastProperty(hostLabel + ".hostname", hostLabel); |
xebialabs/overcast | src/test/java/com/xebialabs/overcast/command/CommandProcessorTest.java | // Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
| import org.junit.jupiter.api.Test;
import static com.xebialabs.overcast.command.Command.aCommand;
import static com.xebialabs.overcast.command.CommandProcessor.atLocation;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assumptions.assumeTrue; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.command;
public class CommandProcessorTest {
@Test
public void shouldThrowExceptionWhenCommandFailed() {
//Test only for UNIX
assumeTrue(System.getenv().containsKey("PATH"));
assertThrows(NonZeroCodeException.class, () -> { | // Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
// Path: src/test/java/com/xebialabs/overcast/command/CommandProcessorTest.java
import org.junit.jupiter.api.Test;
import static com.xebialabs.overcast.command.Command.aCommand;
import static com.xebialabs.overcast.command.CommandProcessor.atLocation;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.command;
public class CommandProcessorTest {
@Test
public void shouldThrowExceptionWhenCommandFailed() {
//Test only for UNIX
assumeTrue(System.getenv().containsKey("PATH"));
assertThrows(NonZeroCodeException.class, () -> { | atLocation("/tmp").run(aCommand("ls").withArguments("-wrong-argument")); |
xebialabs/overcast | src/test/java/com/xebialabs/overcast/command/CommandProcessorTest.java | // Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
| import org.junit.jupiter.api.Test;
import static com.xebialabs.overcast.command.Command.aCommand;
import static com.xebialabs.overcast.command.CommandProcessor.atLocation;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assumptions.assumeTrue; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.command;
public class CommandProcessorTest {
@Test
public void shouldThrowExceptionWhenCommandFailed() {
//Test only for UNIX
assumeTrue(System.getenv().containsKey("PATH"));
assertThrows(NonZeroCodeException.class, () -> { | // Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
// Path: src/test/java/com/xebialabs/overcast/command/CommandProcessorTest.java
import org.junit.jupiter.api.Test;
import static com.xebialabs.overcast.command.Command.aCommand;
import static com.xebialabs.overcast.command.CommandProcessor.atLocation;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.command;
public class CommandProcessorTest {
@Test
public void shouldThrowExceptionWhenCommandFailed() {
//Test only for UNIX
assumeTrue(System.getenv().containsKey("PATH"));
assertThrows(NonZeroCodeException.class, () -> { | atLocation("/tmp").run(aCommand("ls").withArguments("-wrong-argument")); |
xebialabs/overcast | src/test/java/com/xebialabs/overcast/support/libvirt/MetadataTest.java | // Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static String documentToRawString(Document xml) throws IOException {
// return documentToString(xml, Format.getRawFormat().setOmitDeclaration(true)).trim();
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static Document stringToDocument(String xml) {
// try {
// SAXBuilder sax = new SAXBuilder();
// return sax.build(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
// } catch (JDOMException | IOException e) {
// throw new IllegalArgumentException("Unable to parse xml", e);
// }
// }
| import org.jdom2.Document;
import org.junit.jupiter.api.Test;
import java.util.Date;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.documentToRawString;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.stringToDocument;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat; | + "</domain>";
private static final String EXPECTED_XML_WITH_METADATA = "<domain type=\"kvm\">"
+ "<name>centos6</name>"
+ "<uuid>e5905e8d-4698-2b41-59a7-f4a98d9aa61e</uuid>"
+ "<memory unit=\"KiB\">1048576</memory>"
+ "<metadata>"
+ "<overcast_metadata xmlns=\"http://www.xebialabs.com/overcast/metadata/v1\">"
+ "<parent_domain>basedom2</parent_domain>"
+ "<provisioned_with>provcmd2</provisioned_with>"
+ "<provisioned_checksum>expire2</provisioned_checksum>"
+ "<creation_time>2009-02-13T23:31:31Z</creation_time>"
+ "</overcast_metadata>"
+ "</metadata>"
+ "</domain>";
private static final String EXPECTED_XML_WITH_CLONE_METADATA = "<domain type=\"kvm\">"
+ "<name>centos6</name>"
+ "<uuid>e5905e8d-4698-2b41-59a7-f4a98d9aa61e</uuid>"
+ "<memory unit=\"KiB\">1048576</memory>"
+ "<metadata>"
+ "<overcast_metadata xmlns=\"http://www.xebialabs.com/overcast/metadata/v1\">"
+ "<parent_domain>basedom2</parent_domain>"
+ "<creation_time>2009-02-13T23:31:31Z</creation_time>"
+ "</overcast_metadata>"
+ "</metadata>"
+ "</domain>";
@Test
public void shouldUpdateXmlWithoutMetadataTag() throws Exception { | // Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static String documentToRawString(Document xml) throws IOException {
// return documentToString(xml, Format.getRawFormat().setOmitDeclaration(true)).trim();
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static Document stringToDocument(String xml) {
// try {
// SAXBuilder sax = new SAXBuilder();
// return sax.build(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
// } catch (JDOMException | IOException e) {
// throw new IllegalArgumentException("Unable to parse xml", e);
// }
// }
// Path: src/test/java/com/xebialabs/overcast/support/libvirt/MetadataTest.java
import org.jdom2.Document;
import org.junit.jupiter.api.Test;
import java.util.Date;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.documentToRawString;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.stringToDocument;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
+ "</domain>";
private static final String EXPECTED_XML_WITH_METADATA = "<domain type=\"kvm\">"
+ "<name>centos6</name>"
+ "<uuid>e5905e8d-4698-2b41-59a7-f4a98d9aa61e</uuid>"
+ "<memory unit=\"KiB\">1048576</memory>"
+ "<metadata>"
+ "<overcast_metadata xmlns=\"http://www.xebialabs.com/overcast/metadata/v1\">"
+ "<parent_domain>basedom2</parent_domain>"
+ "<provisioned_with>provcmd2</provisioned_with>"
+ "<provisioned_checksum>expire2</provisioned_checksum>"
+ "<creation_time>2009-02-13T23:31:31Z</creation_time>"
+ "</overcast_metadata>"
+ "</metadata>"
+ "</domain>";
private static final String EXPECTED_XML_WITH_CLONE_METADATA = "<domain type=\"kvm\">"
+ "<name>centos6</name>"
+ "<uuid>e5905e8d-4698-2b41-59a7-f4a98d9aa61e</uuid>"
+ "<memory unit=\"KiB\">1048576</memory>"
+ "<metadata>"
+ "<overcast_metadata xmlns=\"http://www.xebialabs.com/overcast/metadata/v1\">"
+ "<parent_domain>basedom2</parent_domain>"
+ "<creation_time>2009-02-13T23:31:31Z</creation_time>"
+ "</overcast_metadata>"
+ "</metadata>"
+ "</domain>";
@Test
public void shouldUpdateXmlWithoutMetadataTag() throws Exception { | Document doc = stringToDocument(XML_WITHOUT_METADATA); |
xebialabs/overcast | src/test/java/com/xebialabs/overcast/support/libvirt/MetadataTest.java | // Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static String documentToRawString(Document xml) throws IOException {
// return documentToString(xml, Format.getRawFormat().setOmitDeclaration(true)).trim();
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static Document stringToDocument(String xml) {
// try {
// SAXBuilder sax = new SAXBuilder();
// return sax.build(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
// } catch (JDOMException | IOException e) {
// throw new IllegalArgumentException("Unable to parse xml", e);
// }
// }
| import org.jdom2.Document;
import org.junit.jupiter.api.Test;
import java.util.Date;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.documentToRawString;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.stringToDocument;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat; | private static final String EXPECTED_XML_WITH_METADATA = "<domain type=\"kvm\">"
+ "<name>centos6</name>"
+ "<uuid>e5905e8d-4698-2b41-59a7-f4a98d9aa61e</uuid>"
+ "<memory unit=\"KiB\">1048576</memory>"
+ "<metadata>"
+ "<overcast_metadata xmlns=\"http://www.xebialabs.com/overcast/metadata/v1\">"
+ "<parent_domain>basedom2</parent_domain>"
+ "<provisioned_with>provcmd2</provisioned_with>"
+ "<provisioned_checksum>expire2</provisioned_checksum>"
+ "<creation_time>2009-02-13T23:31:31Z</creation_time>"
+ "</overcast_metadata>"
+ "</metadata>"
+ "</domain>";
private static final String EXPECTED_XML_WITH_CLONE_METADATA = "<domain type=\"kvm\">"
+ "<name>centos6</name>"
+ "<uuid>e5905e8d-4698-2b41-59a7-f4a98d9aa61e</uuid>"
+ "<memory unit=\"KiB\">1048576</memory>"
+ "<metadata>"
+ "<overcast_metadata xmlns=\"http://www.xebialabs.com/overcast/metadata/v1\">"
+ "<parent_domain>basedom2</parent_domain>"
+ "<creation_time>2009-02-13T23:31:31Z</creation_time>"
+ "</overcast_metadata>"
+ "</metadata>"
+ "</domain>";
@Test
public void shouldUpdateXmlWithoutMetadataTag() throws Exception {
Document doc = stringToDocument(XML_WITHOUT_METADATA);
Metadata.updateProvisioningMetadata(doc, "basedom", "provcmd", "expire", new Date(0)); | // Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static String documentToRawString(Document xml) throws IOException {
// return documentToString(xml, Format.getRawFormat().setOmitDeclaration(true)).trim();
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static Document stringToDocument(String xml) {
// try {
// SAXBuilder sax = new SAXBuilder();
// return sax.build(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
// } catch (JDOMException | IOException e) {
// throw new IllegalArgumentException("Unable to parse xml", e);
// }
// }
// Path: src/test/java/com/xebialabs/overcast/support/libvirt/MetadataTest.java
import org.jdom2.Document;
import org.junit.jupiter.api.Test;
import java.util.Date;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.documentToRawString;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.stringToDocument;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
private static final String EXPECTED_XML_WITH_METADATA = "<domain type=\"kvm\">"
+ "<name>centos6</name>"
+ "<uuid>e5905e8d-4698-2b41-59a7-f4a98d9aa61e</uuid>"
+ "<memory unit=\"KiB\">1048576</memory>"
+ "<metadata>"
+ "<overcast_metadata xmlns=\"http://www.xebialabs.com/overcast/metadata/v1\">"
+ "<parent_domain>basedom2</parent_domain>"
+ "<provisioned_with>provcmd2</provisioned_with>"
+ "<provisioned_checksum>expire2</provisioned_checksum>"
+ "<creation_time>2009-02-13T23:31:31Z</creation_time>"
+ "</overcast_metadata>"
+ "</metadata>"
+ "</domain>";
private static final String EXPECTED_XML_WITH_CLONE_METADATA = "<domain type=\"kvm\">"
+ "<name>centos6</name>"
+ "<uuid>e5905e8d-4698-2b41-59a7-f4a98d9aa61e</uuid>"
+ "<memory unit=\"KiB\">1048576</memory>"
+ "<metadata>"
+ "<overcast_metadata xmlns=\"http://www.xebialabs.com/overcast/metadata/v1\">"
+ "<parent_domain>basedom2</parent_domain>"
+ "<creation_time>2009-02-13T23:31:31Z</creation_time>"
+ "</overcast_metadata>"
+ "</metadata>"
+ "</domain>";
@Test
public void shouldUpdateXmlWithoutMetadataTag() throws Exception {
Document doc = stringToDocument(XML_WITHOUT_METADATA);
Metadata.updateProvisioningMetadata(doc, "basedom", "provcmd", "expire", new Date(0)); | String val = documentToRawString(doc); |
xebialabs/overcast | src/test/java/com/xebialabs/overcast/support/libvirt/jdom/FilesystemXmlTest.java | // Path: src/main/java/com/xebialabs/overcast/Resources.java
// public final class Resources {
// private Resources() {}
//
// public static URL getResource(String resourceName) {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) {
// loader = Resources.class.getClassLoader();
// }
// URL url = loader.getResource(resourceName);
// checkArgument(url != null, "resource %s not found.", resourceName);
// return url;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
//
// public String source;
// public String target;
// public AccessMode accessMode;
// public boolean readOnly;
//
// public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
// checkNotNullOrEmpty(source);
// checkNotNullOrEmpty(target);
//
// this.source = source;
// this.target = target;
// this.accessMode = accessMode;
// this.readOnly = readOnly;
// }
//
// @Override
// public String toString() {
// return "Filesystem{" +
// "source='" + source + '\'' +
// ", target='" + target + '\'' +
// ", accessMode=" + accessMode +
// ", readOnly=" + readOnly +
// '}';
// }
// }
| import java.util.Collections;
import java.util.Map;
import com.xebialabs.overcast.Resources;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt.jdom;
public class FilesystemXmlTest {
public Document getXml(String file) throws Exception {
SAXBuilder saxBuilder = new SAXBuilder(); | // Path: src/main/java/com/xebialabs/overcast/Resources.java
// public final class Resources {
// private Resources() {}
//
// public static URL getResource(String resourceName) {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) {
// loader = Resources.class.getClassLoader();
// }
// URL url = loader.getResource(resourceName);
// checkArgument(url != null, "resource %s not found.", resourceName);
// return url;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
//
// public String source;
// public String target;
// public AccessMode accessMode;
// public boolean readOnly;
//
// public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
// checkNotNullOrEmpty(source);
// checkNotNullOrEmpty(target);
//
// this.source = source;
// this.target = target;
// this.accessMode = accessMode;
// this.readOnly = readOnly;
// }
//
// @Override
// public String toString() {
// return "Filesystem{" +
// "source='" + source + '\'' +
// ", target='" + target + '\'' +
// ", accessMode=" + accessMode +
// ", readOnly=" + readOnly +
// '}';
// }
// }
// Path: src/test/java/com/xebialabs/overcast/support/libvirt/jdom/FilesystemXmlTest.java
import java.util.Collections;
import java.util.Map;
import com.xebialabs.overcast.Resources;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt.jdom;
public class FilesystemXmlTest {
public Document getXml(String file) throws Exception {
SAXBuilder saxBuilder = new SAXBuilder(); | return saxBuilder.build(Resources.getResource(file)); |
xebialabs/overcast | src/test/java/com/xebialabs/overcast/support/libvirt/jdom/FilesystemXmlTest.java | // Path: src/main/java/com/xebialabs/overcast/Resources.java
// public final class Resources {
// private Resources() {}
//
// public static URL getResource(String resourceName) {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) {
// loader = Resources.class.getClassLoader();
// }
// URL url = loader.getResource(resourceName);
// checkArgument(url != null, "resource %s not found.", resourceName);
// return url;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
//
// public String source;
// public String target;
// public AccessMode accessMode;
// public boolean readOnly;
//
// public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
// checkNotNullOrEmpty(source);
// checkNotNullOrEmpty(target);
//
// this.source = source;
// this.target = target;
// this.accessMode = accessMode;
// this.readOnly = readOnly;
// }
//
// @Override
// public String toString() {
// return "Filesystem{" +
// "source='" + source + '\'' +
// ", target='" + target + '\'' +
// ", accessMode=" + accessMode +
// ", readOnly=" + readOnly +
// '}';
// }
// }
| import java.util.Collections;
import java.util.Map;
import com.xebialabs.overcast.Resources;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt.jdom;
public class FilesystemXmlTest {
public Document getXml(String file) throws Exception {
SAXBuilder saxBuilder = new SAXBuilder();
return saxBuilder.build(Resources.getResource(file));
}
@Test
public void shouldReadNoFilesystems() throws Exception {
Document domainXml = getXml("libvirt-xml/simple-domain.xml"); | // Path: src/main/java/com/xebialabs/overcast/Resources.java
// public final class Resources {
// private Resources() {}
//
// public static URL getResource(String resourceName) {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) {
// loader = Resources.class.getClassLoader();
// }
// URL url = loader.getResource(resourceName);
// checkArgument(url != null, "resource %s not found.", resourceName);
// return url;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
//
// public String source;
// public String target;
// public AccessMode accessMode;
// public boolean readOnly;
//
// public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
// checkNotNullOrEmpty(source);
// checkNotNullOrEmpty(target);
//
// this.source = source;
// this.target = target;
// this.accessMode = accessMode;
// this.readOnly = readOnly;
// }
//
// @Override
// public String toString() {
// return "Filesystem{" +
// "source='" + source + '\'' +
// ", target='" + target + '\'' +
// ", accessMode=" + accessMode +
// ", readOnly=" + readOnly +
// '}';
// }
// }
// Path: src/test/java/com/xebialabs/overcast/support/libvirt/jdom/FilesystemXmlTest.java
import java.util.Collections;
import java.util.Map;
import com.xebialabs.overcast.Resources;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt.jdom;
public class FilesystemXmlTest {
public Document getXml(String file) throws Exception {
SAXBuilder saxBuilder = new SAXBuilder();
return saxBuilder.build(Resources.getResource(file));
}
@Test
public void shouldReadNoFilesystems() throws Exception {
Document domainXml = getXml("libvirt-xml/simple-domain.xml"); | Map<String, Filesystem> fs = FilesystemXml.getFilesystems(domainXml); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/host/Ec2CloudHost.java | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
| import java.util.Collections;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.*;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static java.util.Arrays.asList; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.host;
class Ec2CloudHost implements CloudHost {
public static final String AMI_AVAILABILITY_ZONE_PROPERTY_SUFFIX = ".amiAvailabilityZone";
public static final String AMI_BOOT_SECONDS_PROPERTY_SUFFIX = ".amiBootSeconds";
public static final String AMI_ID_PROPERTY_SUFFIX = ".amiId";
public static final String AMI_INSTANCE_TYPE_PROPERTY_SUFFIX = ".amiInstanceType";
public static final String AMI_KEY_NAME_PROPERTY_SUFFIX = ".amiKeyName";
public static final String AMI_SECURITY_GROUP_PROPERTY_SUFFIX = ".amiSecurityGroup";
public static final String AWS_ACCESS_KEY_PROPERTY = "aws.accessKey";
public static final String AWS_ENDPOINT_DEFAULT = "https://ec2.amazonaws.com";
public static final String AWS_ENDPOINT_PROPERTY = "aws.endpoint";
public static final String AWS_SECRET_KEY_PROPERTY = "aws.secretKey";
private final String hostLabel;
private final String amiId;
private final String awsEndpointURL;
private final String awsAccessKey;
private final String awsSecretKey;
private final String amiAvailabilityZone;
private final String amiInstanceType;
private final String amiSecurityGroup;
private final String amiKeyName;
private final int amiBootSeconds;
private final AmazonEC2Client ec2;
private String instanceId;
private String publicDnsAddress;
private static final Logger logger = LoggerFactory.getLogger(Ec2CloudHost.class);
public Ec2CloudHost(String hostLabel, String amiId) {
this.hostLabel = hostLabel;
this.amiId = amiId; | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
// Path: src/main/java/com/xebialabs/overcast/host/Ec2CloudHost.java
import java.util.Collections;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.*;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static java.util.Arrays.asList;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.host;
class Ec2CloudHost implements CloudHost {
public static final String AMI_AVAILABILITY_ZONE_PROPERTY_SUFFIX = ".amiAvailabilityZone";
public static final String AMI_BOOT_SECONDS_PROPERTY_SUFFIX = ".amiBootSeconds";
public static final String AMI_ID_PROPERTY_SUFFIX = ".amiId";
public static final String AMI_INSTANCE_TYPE_PROPERTY_SUFFIX = ".amiInstanceType";
public static final String AMI_KEY_NAME_PROPERTY_SUFFIX = ".amiKeyName";
public static final String AMI_SECURITY_GROUP_PROPERTY_SUFFIX = ".amiSecurityGroup";
public static final String AWS_ACCESS_KEY_PROPERTY = "aws.accessKey";
public static final String AWS_ENDPOINT_DEFAULT = "https://ec2.amazonaws.com";
public static final String AWS_ENDPOINT_PROPERTY = "aws.endpoint";
public static final String AWS_SECRET_KEY_PROPERTY = "aws.secretKey";
private final String hostLabel;
private final String amiId;
private final String awsEndpointURL;
private final String awsAccessKey;
private final String awsSecretKey;
private final String amiAvailabilityZone;
private final String amiInstanceType;
private final String amiSecurityGroup;
private final String amiKeyName;
private final int amiBootSeconds;
private final AmazonEC2Client ec2;
private String instanceId;
private String publicDnsAddress;
private static final Logger logger = LoggerFactory.getLogger(Ec2CloudHost.class);
public Ec2CloudHost(String hostLabel, String amiId) {
this.hostLabel = hostLabel;
this.amiId = amiId; | this.awsEndpointURL = getOvercastProperty(AWS_ENDPOINT_PROPERTY, AWS_ENDPOINT_DEFAULT); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/host/Ec2CloudHost.java | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
| import java.util.Collections;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.*;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static java.util.Arrays.asList; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.host;
class Ec2CloudHost implements CloudHost {
public static final String AMI_AVAILABILITY_ZONE_PROPERTY_SUFFIX = ".amiAvailabilityZone";
public static final String AMI_BOOT_SECONDS_PROPERTY_SUFFIX = ".amiBootSeconds";
public static final String AMI_ID_PROPERTY_SUFFIX = ".amiId";
public static final String AMI_INSTANCE_TYPE_PROPERTY_SUFFIX = ".amiInstanceType";
public static final String AMI_KEY_NAME_PROPERTY_SUFFIX = ".amiKeyName";
public static final String AMI_SECURITY_GROUP_PROPERTY_SUFFIX = ".amiSecurityGroup";
public static final String AWS_ACCESS_KEY_PROPERTY = "aws.accessKey";
public static final String AWS_ENDPOINT_DEFAULT = "https://ec2.amazonaws.com";
public static final String AWS_ENDPOINT_PROPERTY = "aws.endpoint";
public static final String AWS_SECRET_KEY_PROPERTY = "aws.secretKey";
private final String hostLabel;
private final String amiId;
private final String awsEndpointURL;
private final String awsAccessKey;
private final String awsSecretKey;
private final String amiAvailabilityZone;
private final String amiInstanceType;
private final String amiSecurityGroup;
private final String amiKeyName;
private final int amiBootSeconds;
private final AmazonEC2Client ec2;
private String instanceId;
private String publicDnsAddress;
private static final Logger logger = LoggerFactory.getLogger(Ec2CloudHost.class);
public Ec2CloudHost(String hostLabel, String amiId) {
this.hostLabel = hostLabel;
this.amiId = amiId;
this.awsEndpointURL = getOvercastProperty(AWS_ENDPOINT_PROPERTY, AWS_ENDPOINT_DEFAULT); | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
// Path: src/main/java/com/xebialabs/overcast/host/Ec2CloudHost.java
import java.util.Collections;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.*;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static java.util.Arrays.asList;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.host;
class Ec2CloudHost implements CloudHost {
public static final String AMI_AVAILABILITY_ZONE_PROPERTY_SUFFIX = ".amiAvailabilityZone";
public static final String AMI_BOOT_SECONDS_PROPERTY_SUFFIX = ".amiBootSeconds";
public static final String AMI_ID_PROPERTY_SUFFIX = ".amiId";
public static final String AMI_INSTANCE_TYPE_PROPERTY_SUFFIX = ".amiInstanceType";
public static final String AMI_KEY_NAME_PROPERTY_SUFFIX = ".amiKeyName";
public static final String AMI_SECURITY_GROUP_PROPERTY_SUFFIX = ".amiSecurityGroup";
public static final String AWS_ACCESS_KEY_PROPERTY = "aws.accessKey";
public static final String AWS_ENDPOINT_DEFAULT = "https://ec2.amazonaws.com";
public static final String AWS_ENDPOINT_PROPERTY = "aws.endpoint";
public static final String AWS_SECRET_KEY_PROPERTY = "aws.secretKey";
private final String hostLabel;
private final String amiId;
private final String awsEndpointURL;
private final String awsAccessKey;
private final String awsSecretKey;
private final String amiAvailabilityZone;
private final String amiInstanceType;
private final String amiSecurityGroup;
private final String amiKeyName;
private final int amiBootSeconds;
private final AmazonEC2Client ec2;
private String instanceId;
private String publicDnsAddress;
private static final Logger logger = LoggerFactory.getLogger(Ec2CloudHost.class);
public Ec2CloudHost(String hostLabel, String amiId) {
this.hostLabel = hostLabel;
this.amiId = amiId;
this.awsEndpointURL = getOvercastProperty(AWS_ENDPOINT_PROPERTY, AWS_ENDPOINT_DEFAULT); | this.awsAccessKey = getRequiredOvercastProperty(AWS_ACCESS_KEY_PROPERTY); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/libvirt/jdom/FilesystemXml.java | // Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
//
// public String source;
// public String target;
// public AccessMode accessMode;
// public boolean readOnly;
//
// public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
// checkNotNullOrEmpty(source);
// checkNotNullOrEmpty(target);
//
// this.source = source;
// this.target = target;
// this.accessMode = accessMode;
// this.readOnly = readOnly;
// }
//
// @Override
// public String toString() {
// return "Filesystem{" +
// "source='" + source + '\'' +
// ", target='" + target + '\'' +
// ", accessMode=" + accessMode +
// ", readOnly=" + readOnly +
// '}';
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.jdom2.Attribute;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.filter.Filters;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import com.xebialabs.overcast.support.libvirt.Filesystem.AccessMode; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt.jdom;
public final class FilesystemXml {
private static final String XPATH_FILESYSTEM = "/domain/devices/filesystem[@type='mount']";
private FilesystemXml() {
}
| // Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
//
// public String source;
// public String target;
// public AccessMode accessMode;
// public boolean readOnly;
//
// public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
// checkNotNullOrEmpty(source);
// checkNotNullOrEmpty(target);
//
// this.source = source;
// this.target = target;
// this.accessMode = accessMode;
// this.readOnly = readOnly;
// }
//
// @Override
// public String toString() {
// return "Filesystem{" +
// "source='" + source + '\'' +
// ", target='" + target + '\'' +
// ", accessMode=" + accessMode +
// ", readOnly=" + readOnly +
// '}';
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/jdom/FilesystemXml.java
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.jdom2.Attribute;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.filter.Filters;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import com.xebialabs.overcast.support.libvirt.Filesystem.AccessMode;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt.jdom;
public final class FilesystemXml {
private static final String XPATH_FILESYSTEM = "/domain/devices/filesystem[@type='mount']";
private FilesystemXml() {
}
| public static Element toFileSystemXml(Filesystem fs) { |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/libvirt/jdom/FilesystemXml.java | // Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
//
// public String source;
// public String target;
// public AccessMode accessMode;
// public boolean readOnly;
//
// public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
// checkNotNullOrEmpty(source);
// checkNotNullOrEmpty(target);
//
// this.source = source;
// this.target = target;
// this.accessMode = accessMode;
// this.readOnly = readOnly;
// }
//
// @Override
// public String toString() {
// return "Filesystem{" +
// "source='" + source + '\'' +
// ", target='" + target + '\'' +
// ", accessMode=" + accessMode +
// ", readOnly=" + readOnly +
// '}';
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.jdom2.Attribute;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.filter.Filters;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import com.xebialabs.overcast.support.libvirt.Filesystem.AccessMode; | if (fs.readOnly) {
filesystem.addContent(new Element("readonly"));
}
return filesystem;
}
public static void removeFilesystemsWithTarget(Document domainXml, String targetDir) {
XPathFactory xpf = XPathFactory.instance();
XPathExpression<Element> fsExpr = xpf.compile(String.format("/domain/devices/filesystem[@type='mount']/target[@dir='%s']", targetDir), Filters.element());
List<Element> tfs = fsExpr.evaluate(domainXml);
for (Element e : tfs) {
e.getParentElement().getParentElement().removeContent(e.getParentElement());
}
}
/**
* Get map of {@link Filesystem}s. The key in the map is the target inside the domain. This will only return
* filesystems of type 'mount'.
*/
public static Map<String, Filesystem> getFilesystems(Document domainXml) {
Map<String, Filesystem> ret = new HashMap<>();
XPathFactory xpf = XPathFactory.instance();
XPathExpression<Element> fsExpr = xpf.compile(XPATH_FILESYSTEM, Filters.element());
List<Element> filesystems = fsExpr.evaluate(domainXml);
for (Element fs : filesystems) {
Attribute accessMode = fs.getAttribute("accessmode");
String source = fs.getChild("source").getAttribute("dir").getValue();
String target = fs.getChild("target").getAttribute("dir").getValue();
boolean readOnly = fs.getChild("readonly") != null;
| // Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
//
// public String source;
// public String target;
// public AccessMode accessMode;
// public boolean readOnly;
//
// public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
// checkNotNullOrEmpty(source);
// checkNotNullOrEmpty(target);
//
// this.source = source;
// this.target = target;
// this.accessMode = accessMode;
// this.readOnly = readOnly;
// }
//
// @Override
// public String toString() {
// return "Filesystem{" +
// "source='" + source + '\'' +
// ", target='" + target + '\'' +
// ", accessMode=" + accessMode +
// ", readOnly=" + readOnly +
// '}';
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public enum AccessMode {
// /** The source is accessed with the permissions of the user inside the guest. This is the default. */
// PASSTHROUGH,
// /** The source is accessed with the permissions of the hypervisor (QEMU process). */
// MAPPED,
// /**
// * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
// * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
// */
// SQUASH,
// }
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/jdom/FilesystemXml.java
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.jdom2.Attribute;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.filter.Filters;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import com.xebialabs.overcast.support.libvirt.Filesystem.AccessMode;
if (fs.readOnly) {
filesystem.addContent(new Element("readonly"));
}
return filesystem;
}
public static void removeFilesystemsWithTarget(Document domainXml, String targetDir) {
XPathFactory xpf = XPathFactory.instance();
XPathExpression<Element> fsExpr = xpf.compile(String.format("/domain/devices/filesystem[@type='mount']/target[@dir='%s']", targetDir), Filters.element());
List<Element> tfs = fsExpr.evaluate(domainXml);
for (Element e : tfs) {
e.getParentElement().getParentElement().removeContent(e.getParentElement());
}
}
/**
* Get map of {@link Filesystem}s. The key in the map is the target inside the domain. This will only return
* filesystems of type 'mount'.
*/
public static Map<String, Filesystem> getFilesystems(Document domainXml) {
Map<String, Filesystem> ret = new HashMap<>();
XPathFactory xpf = XPathFactory.instance();
XPathExpression<Element> fsExpr = xpf.compile(XPATH_FILESYSTEM, Filters.element());
List<Element> filesystems = fsExpr.evaluate(domainXml);
for (Element fs : filesystems) {
Attribute accessMode = fs.getAttribute("accessmode");
String source = fs.getChild("source").getAttribute("dir").getValue();
String target = fs.getChild("target").getAttribute("dir").getValue();
boolean readOnly = fs.getChild("readonly") != null;
| ret.put(target, new Filesystem(source, target, AccessMode.valueOf(accessMode.getValue().toUpperCase(Locale.US)), readOnly)); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java | // Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNullOrEmpty(String s) {
// if (isNullOrEmpty(s)) {
// throw new NullPointerException();
// }
// }
| import static com.xebialabs.overcast.Preconditions.checkNotNullOrEmpty; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
public class Filesystem {
public enum AccessMode {
/** The source is accessed with the permissions of the user inside the guest. This is the default. */
PASSTHROUGH,
/** The source is accessed with the permissions of the hypervisor (QEMU process). */
MAPPED,
/**
* Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
* 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
*/
SQUASH,
}
public String source;
public String target;
public AccessMode accessMode;
public boolean readOnly;
public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) { | // Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNullOrEmpty(String s) {
// if (isNullOrEmpty(s)) {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
import static com.xebialabs.overcast.Preconditions.checkNotNullOrEmpty;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
public class Filesystem {
public enum AccessMode {
/** The source is accessed with the permissions of the user inside the guest. This is the default. */
PASSTHROUGH,
/** The source is accessed with the permissions of the hypervisor (QEMU process). */
MAPPED,
/**
* Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
* 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
*/
SQUASH,
}
public String source;
public String target;
public AccessMode accessMode;
public boolean readOnly;
public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) { | checkNotNullOrEmpty(source); |
xebialabs/overcast | src/test/java/com/xebialabs/overcast/support/vagrant/VagrantCloudHostTest.java | // Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/host/VagrantCloudHost.java
// public class VagrantCloudHost implements CloudHost {
//
// protected String vagrantIp;
//
// protected String vagrantVm;
//
// protected VagrantDriver vagrantDriver;
//
// private VagrantState initialState;
//
// private Map<String, String> vagrantParameters;
//
// private static final Logger logger = LoggerFactory.getLogger(VagrantCloudHost.class);
//
// public VagrantCloudHost(String vagrantVm, String vagrantIp, VagrantDriver vagrantDriver,
// Map<String, String> vagrantParameters) {
// this.vagrantIp = vagrantIp;
// this.vagrantDriver = vagrantDriver;
// this.vagrantVm = vagrantVm;
// this.vagrantParameters = vagrantParameters;
// }
//
// @Override
// public void setup() {
// initialState = vagrantDriver.state(vagrantVm);
// logger.info("Vagrant host is in state {}.", initialState.toString());
// vagrantDriver.doVagrant(vagrantVm, getTransitionCommand(VagrantState.RUNNING, vagrantParameters));
// }
//
// @Override
// public void teardown() {
// VagrantState nextState;
// if (initialState != null) {
// logger.info("Bringing vagrant back to {} state.", initialState.toString());
// nextState = initialState;
// } else {
// logger.warn("No initial state was captured. Destroying the VM.");
// nextState = NOT_CREATED;
// }
// vagrantDriver.doVagrant(vagrantVm, getTransitionCommand(nextState, vagrantParameters));
// }
//
// @Override
// public String getHostName() {
// return vagrantIp;
// }
//
// @Override
// public int getPort(int port) {
// return port;
// }
//
// }
| import com.xebialabs.overcast.command.CommandResponse;
import com.xebialabs.overcast.host.VagrantCloudHost;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static com.xebialabs.overcast.support.vagrant.VagrantState.NOT_CREATED;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantCloudHostTest {
@Mock
private VagrantDriver vagrantDriver;
@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
}
@Test
public void shouldThrowNoExceptionsWhenAllGoesFine() {
when(vagrantDriver.state("vm")).thenReturn(NOT_CREATED); | // Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/host/VagrantCloudHost.java
// public class VagrantCloudHost implements CloudHost {
//
// protected String vagrantIp;
//
// protected String vagrantVm;
//
// protected VagrantDriver vagrantDriver;
//
// private VagrantState initialState;
//
// private Map<String, String> vagrantParameters;
//
// private static final Logger logger = LoggerFactory.getLogger(VagrantCloudHost.class);
//
// public VagrantCloudHost(String vagrantVm, String vagrantIp, VagrantDriver vagrantDriver,
// Map<String, String> vagrantParameters) {
// this.vagrantIp = vagrantIp;
// this.vagrantDriver = vagrantDriver;
// this.vagrantVm = vagrantVm;
// this.vagrantParameters = vagrantParameters;
// }
//
// @Override
// public void setup() {
// initialState = vagrantDriver.state(vagrantVm);
// logger.info("Vagrant host is in state {}.", initialState.toString());
// vagrantDriver.doVagrant(vagrantVm, getTransitionCommand(VagrantState.RUNNING, vagrantParameters));
// }
//
// @Override
// public void teardown() {
// VagrantState nextState;
// if (initialState != null) {
// logger.info("Bringing vagrant back to {} state.", initialState.toString());
// nextState = initialState;
// } else {
// logger.warn("No initial state was captured. Destroying the VM.");
// nextState = NOT_CREATED;
// }
// vagrantDriver.doVagrant(vagrantVm, getTransitionCommand(nextState, vagrantParameters));
// }
//
// @Override
// public String getHostName() {
// return vagrantIp;
// }
//
// @Override
// public int getPort(int port) {
// return port;
// }
//
// }
// Path: src/test/java/com/xebialabs/overcast/support/vagrant/VagrantCloudHostTest.java
import com.xebialabs.overcast.command.CommandResponse;
import com.xebialabs.overcast.host.VagrantCloudHost;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static com.xebialabs.overcast.support.vagrant.VagrantState.NOT_CREATED;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantCloudHostTest {
@Mock
private VagrantDriver vagrantDriver;
@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
}
@Test
public void shouldThrowNoExceptionsWhenAllGoesFine() {
when(vagrantDriver.state("vm")).thenReturn(NOT_CREATED); | when(vagrantDriver.doVagrant("vm", "up")).thenReturn(new CommandResponse(0, "", "")); |
xebialabs/overcast | src/test/java/com/xebialabs/overcast/support/vagrant/VagrantCloudHostTest.java | // Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/host/VagrantCloudHost.java
// public class VagrantCloudHost implements CloudHost {
//
// protected String vagrantIp;
//
// protected String vagrantVm;
//
// protected VagrantDriver vagrantDriver;
//
// private VagrantState initialState;
//
// private Map<String, String> vagrantParameters;
//
// private static final Logger logger = LoggerFactory.getLogger(VagrantCloudHost.class);
//
// public VagrantCloudHost(String vagrantVm, String vagrantIp, VagrantDriver vagrantDriver,
// Map<String, String> vagrantParameters) {
// this.vagrantIp = vagrantIp;
// this.vagrantDriver = vagrantDriver;
// this.vagrantVm = vagrantVm;
// this.vagrantParameters = vagrantParameters;
// }
//
// @Override
// public void setup() {
// initialState = vagrantDriver.state(vagrantVm);
// logger.info("Vagrant host is in state {}.", initialState.toString());
// vagrantDriver.doVagrant(vagrantVm, getTransitionCommand(VagrantState.RUNNING, vagrantParameters));
// }
//
// @Override
// public void teardown() {
// VagrantState nextState;
// if (initialState != null) {
// logger.info("Bringing vagrant back to {} state.", initialState.toString());
// nextState = initialState;
// } else {
// logger.warn("No initial state was captured. Destroying the VM.");
// nextState = NOT_CREATED;
// }
// vagrantDriver.doVagrant(vagrantVm, getTransitionCommand(nextState, vagrantParameters));
// }
//
// @Override
// public String getHostName() {
// return vagrantIp;
// }
//
// @Override
// public int getPort(int port) {
// return port;
// }
//
// }
| import com.xebialabs.overcast.command.CommandResponse;
import com.xebialabs.overcast.host.VagrantCloudHost;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static com.xebialabs.overcast.support.vagrant.VagrantState.NOT_CREATED;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantCloudHostTest {
@Mock
private VagrantDriver vagrantDriver;
@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
}
@Test
public void shouldThrowNoExceptionsWhenAllGoesFine() {
when(vagrantDriver.state("vm")).thenReturn(NOT_CREATED);
when(vagrantDriver.doVagrant("vm", "up")).thenReturn(new CommandResponse(0, "", ""));
| // Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/host/VagrantCloudHost.java
// public class VagrantCloudHost implements CloudHost {
//
// protected String vagrantIp;
//
// protected String vagrantVm;
//
// protected VagrantDriver vagrantDriver;
//
// private VagrantState initialState;
//
// private Map<String, String> vagrantParameters;
//
// private static final Logger logger = LoggerFactory.getLogger(VagrantCloudHost.class);
//
// public VagrantCloudHost(String vagrantVm, String vagrantIp, VagrantDriver vagrantDriver,
// Map<String, String> vagrantParameters) {
// this.vagrantIp = vagrantIp;
// this.vagrantDriver = vagrantDriver;
// this.vagrantVm = vagrantVm;
// this.vagrantParameters = vagrantParameters;
// }
//
// @Override
// public void setup() {
// initialState = vagrantDriver.state(vagrantVm);
// logger.info("Vagrant host is in state {}.", initialState.toString());
// vagrantDriver.doVagrant(vagrantVm, getTransitionCommand(VagrantState.RUNNING, vagrantParameters));
// }
//
// @Override
// public void teardown() {
// VagrantState nextState;
// if (initialState != null) {
// logger.info("Bringing vagrant back to {} state.", initialState.toString());
// nextState = initialState;
// } else {
// logger.warn("No initial state was captured. Destroying the VM.");
// nextState = NOT_CREATED;
// }
// vagrantDriver.doVagrant(vagrantVm, getTransitionCommand(nextState, vagrantParameters));
// }
//
// @Override
// public String getHostName() {
// return vagrantIp;
// }
//
// @Override
// public int getPort(int port) {
// return port;
// }
//
// }
// Path: src/test/java/com/xebialabs/overcast/support/vagrant/VagrantCloudHostTest.java
import com.xebialabs.overcast.command.CommandResponse;
import com.xebialabs.overcast.host.VagrantCloudHost;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static com.xebialabs.overcast.support.vagrant.VagrantState.NOT_CREATED;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantCloudHostTest {
@Mock
private VagrantDriver vagrantDriver;
@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
}
@Test
public void shouldThrowNoExceptionsWhenAllGoesFine() {
when(vagrantDriver.state("vm")).thenReturn(NOT_CREATED);
when(vagrantDriver.doVagrant("vm", "up")).thenReturn(new CommandResponse(0, "", ""));
| VagrantCloudHost vagrantCloudHost = new VagrantCloudHost("vm", "127.0.0.1", vagrantDriver, null); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/Resources.java | // Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkArgument(
// boolean expression,
// String errorMessageTemplate,
// Object... errorMessageArgs) {
// if (!expression) {
// throw new IllegalArgumentException(String.format(errorMessageTemplate, errorMessageArgs));
// }
// }
| import java.net.URL;
import static com.xebialabs.overcast.Preconditions.checkArgument; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast;
public final class Resources {
private Resources() {}
public static URL getResource(String resourceName) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
loader = Resources.class.getClassLoader();
}
URL url = loader.getResource(resourceName); | // Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkArgument(
// boolean expression,
// String errorMessageTemplate,
// Object... errorMessageArgs) {
// if (!expression) {
// throw new IllegalArgumentException(String.format(errorMessageTemplate, errorMessageArgs));
// }
// }
// Path: src/main/java/com/xebialabs/overcast/Resources.java
import java.net.URL;
import static com.xebialabs.overcast.Preconditions.checkArgument;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast;
public final class Resources {
private Resources() {}
public static URL getResource(String resourceName) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
loader = Resources.class.getClassLoader();
}
URL url = loader.getResource(resourceName); | checkArgument(url != null, "resource %s not found.", resourceName); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/vagrant/VagrantDriver.java | // Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public class CommandProcessor {
//
// public static Logger logger = LoggerFactory.getLogger(CommandProcessor.class);
//
// private String execDir = ".";
//
// private CommandProcessor(final String execDir) {
// this.execDir = execDir;
// }
//
// private CommandProcessor() {}
//
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
//
// public static CommandProcessor atCurrentDir() {
// return new CommandProcessor();
// }
//
// public CommandResponse run(final Command command) {
//
// logger.debug("Executing command {}", command);
//
// try {
// Process p = new ProcessBuilder(command.asList()).directory(new File(execDir)).start();
//
// // We do this small trick to have stdout and stderr of the process on the console and
// // at the same time capture them to strings.
// ByteArrayOutputStream errors = new ByteArrayOutputStream();
// ByteArrayOutputStream messages = new ByteArrayOutputStream();
//
// Thread t1 = showProcessOutput(new TeeInputStream(p.getErrorStream(), errors), System.err);
// Thread t2 = showProcessOutput(new TeeInputStream(p.getInputStream(), messages), System.out);
//
// int code = p.waitFor();
//
// t1.join();
// t2.join();
//
// CommandResponse response = new CommandResponse(code, errors.toString(), messages.toString());
//
// if (!response.isSuccessful()) {
// throw new NonZeroCodeException(command, response);
// }
//
// return response;
//
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// } catch (IOException e) {
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// }
// }
//
// private Thread showProcessOutput(final InputStream from, final PrintStream to) {
// Thread t = new Thread(() -> {
// try {
// for (; ; ) {
// int c = from.read();
// if (c == -1)
// break;
// to.write((char) c);
// }
// } catch (IOException ignore) {
// }
// });
// t.start();
// return t;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
| import com.xebialabs.overcast.command.CommandProcessor;
import com.xebialabs.overcast.command.CommandResponse;
import static com.xebialabs.overcast.command.Command.aCommand; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantDriver {
private final String hostLabel; | // Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public class CommandProcessor {
//
// public static Logger logger = LoggerFactory.getLogger(CommandProcessor.class);
//
// private String execDir = ".";
//
// private CommandProcessor(final String execDir) {
// this.execDir = execDir;
// }
//
// private CommandProcessor() {}
//
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
//
// public static CommandProcessor atCurrentDir() {
// return new CommandProcessor();
// }
//
// public CommandResponse run(final Command command) {
//
// logger.debug("Executing command {}", command);
//
// try {
// Process p = new ProcessBuilder(command.asList()).directory(new File(execDir)).start();
//
// // We do this small trick to have stdout and stderr of the process on the console and
// // at the same time capture them to strings.
// ByteArrayOutputStream errors = new ByteArrayOutputStream();
// ByteArrayOutputStream messages = new ByteArrayOutputStream();
//
// Thread t1 = showProcessOutput(new TeeInputStream(p.getErrorStream(), errors), System.err);
// Thread t2 = showProcessOutput(new TeeInputStream(p.getInputStream(), messages), System.out);
//
// int code = p.waitFor();
//
// t1.join();
// t2.join();
//
// CommandResponse response = new CommandResponse(code, errors.toString(), messages.toString());
//
// if (!response.isSuccessful()) {
// throw new NonZeroCodeException(command, response);
// }
//
// return response;
//
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// } catch (IOException e) {
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// }
// }
//
// private Thread showProcessOutput(final InputStream from, final PrintStream to) {
// Thread t = new Thread(() -> {
// try {
// for (; ; ) {
// int c = from.read();
// if (c == -1)
// break;
// to.write((char) c);
// }
// } catch (IOException ignore) {
// }
// });
// t.start();
// return t;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
// Path: src/main/java/com/xebialabs/overcast/support/vagrant/VagrantDriver.java
import com.xebialabs.overcast.command.CommandProcessor;
import com.xebialabs.overcast.command.CommandResponse;
import static com.xebialabs.overcast.command.Command.aCommand;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantDriver {
private final String hostLabel; | private final CommandProcessor commandProcessor; |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/vagrant/VagrantDriver.java | // Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public class CommandProcessor {
//
// public static Logger logger = LoggerFactory.getLogger(CommandProcessor.class);
//
// private String execDir = ".";
//
// private CommandProcessor(final String execDir) {
// this.execDir = execDir;
// }
//
// private CommandProcessor() {}
//
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
//
// public static CommandProcessor atCurrentDir() {
// return new CommandProcessor();
// }
//
// public CommandResponse run(final Command command) {
//
// logger.debug("Executing command {}", command);
//
// try {
// Process p = new ProcessBuilder(command.asList()).directory(new File(execDir)).start();
//
// // We do this small trick to have stdout and stderr of the process on the console and
// // at the same time capture them to strings.
// ByteArrayOutputStream errors = new ByteArrayOutputStream();
// ByteArrayOutputStream messages = new ByteArrayOutputStream();
//
// Thread t1 = showProcessOutput(new TeeInputStream(p.getErrorStream(), errors), System.err);
// Thread t2 = showProcessOutput(new TeeInputStream(p.getInputStream(), messages), System.out);
//
// int code = p.waitFor();
//
// t1.join();
// t2.join();
//
// CommandResponse response = new CommandResponse(code, errors.toString(), messages.toString());
//
// if (!response.isSuccessful()) {
// throw new NonZeroCodeException(command, response);
// }
//
// return response;
//
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// } catch (IOException e) {
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// }
// }
//
// private Thread showProcessOutput(final InputStream from, final PrintStream to) {
// Thread t = new Thread(() -> {
// try {
// for (; ; ) {
// int c = from.read();
// if (c == -1)
// break;
// to.write((char) c);
// }
// } catch (IOException ignore) {
// }
// });
// t.start();
// return t;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
| import com.xebialabs.overcast.command.CommandProcessor;
import com.xebialabs.overcast.command.CommandResponse;
import static com.xebialabs.overcast.command.Command.aCommand; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantDriver {
private final String hostLabel;
private final CommandProcessor commandProcessor;
public VagrantDriver(String hostLabel, CommandProcessor commandProcessor) {
this.hostLabel = hostLabel;
this.commandProcessor = commandProcessor;
}
/**
* Executes vagrant command which means that arguments passed here will be prepended with "vagrant"
* @param vagrantCommand arguments for <i>vagrant</i> command
* @return vagrant response object
*/ | // Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public class CommandProcessor {
//
// public static Logger logger = LoggerFactory.getLogger(CommandProcessor.class);
//
// private String execDir = ".";
//
// private CommandProcessor(final String execDir) {
// this.execDir = execDir;
// }
//
// private CommandProcessor() {}
//
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
//
// public static CommandProcessor atCurrentDir() {
// return new CommandProcessor();
// }
//
// public CommandResponse run(final Command command) {
//
// logger.debug("Executing command {}", command);
//
// try {
// Process p = new ProcessBuilder(command.asList()).directory(new File(execDir)).start();
//
// // We do this small trick to have stdout and stderr of the process on the console and
// // at the same time capture them to strings.
// ByteArrayOutputStream errors = new ByteArrayOutputStream();
// ByteArrayOutputStream messages = new ByteArrayOutputStream();
//
// Thread t1 = showProcessOutput(new TeeInputStream(p.getErrorStream(), errors), System.err);
// Thread t2 = showProcessOutput(new TeeInputStream(p.getInputStream(), messages), System.out);
//
// int code = p.waitFor();
//
// t1.join();
// t2.join();
//
// CommandResponse response = new CommandResponse(code, errors.toString(), messages.toString());
//
// if (!response.isSuccessful()) {
// throw new NonZeroCodeException(command, response);
// }
//
// return response;
//
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// } catch (IOException e) {
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// }
// }
//
// private Thread showProcessOutput(final InputStream from, final PrintStream to) {
// Thread t = new Thread(() -> {
// try {
// for (; ; ) {
// int c = from.read();
// if (c == -1)
// break;
// to.write((char) c);
// }
// } catch (IOException ignore) {
// }
// });
// t.start();
// return t;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
// Path: src/main/java/com/xebialabs/overcast/support/vagrant/VagrantDriver.java
import com.xebialabs.overcast.command.CommandProcessor;
import com.xebialabs.overcast.command.CommandResponse;
import static com.xebialabs.overcast.command.Command.aCommand;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantDriver {
private final String hostLabel;
private final CommandProcessor commandProcessor;
public VagrantDriver(String hostLabel, CommandProcessor commandProcessor) {
this.hostLabel = hostLabel;
this.commandProcessor = commandProcessor;
}
/**
* Executes vagrant command which means that arguments passed here will be prepended with "vagrant"
* @param vagrantCommand arguments for <i>vagrant</i> command
* @return vagrant response object
*/ | public CommandResponse doVagrant(String vagrantVm, final String... vagrantCommand) { |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/vagrant/VagrantDriver.java | // Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public class CommandProcessor {
//
// public static Logger logger = LoggerFactory.getLogger(CommandProcessor.class);
//
// private String execDir = ".";
//
// private CommandProcessor(final String execDir) {
// this.execDir = execDir;
// }
//
// private CommandProcessor() {}
//
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
//
// public static CommandProcessor atCurrentDir() {
// return new CommandProcessor();
// }
//
// public CommandResponse run(final Command command) {
//
// logger.debug("Executing command {}", command);
//
// try {
// Process p = new ProcessBuilder(command.asList()).directory(new File(execDir)).start();
//
// // We do this small trick to have stdout and stderr of the process on the console and
// // at the same time capture them to strings.
// ByteArrayOutputStream errors = new ByteArrayOutputStream();
// ByteArrayOutputStream messages = new ByteArrayOutputStream();
//
// Thread t1 = showProcessOutput(new TeeInputStream(p.getErrorStream(), errors), System.err);
// Thread t2 = showProcessOutput(new TeeInputStream(p.getInputStream(), messages), System.out);
//
// int code = p.waitFor();
//
// t1.join();
// t2.join();
//
// CommandResponse response = new CommandResponse(code, errors.toString(), messages.toString());
//
// if (!response.isSuccessful()) {
// throw new NonZeroCodeException(command, response);
// }
//
// return response;
//
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// } catch (IOException e) {
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// }
// }
//
// private Thread showProcessOutput(final InputStream from, final PrintStream to) {
// Thread t = new Thread(() -> {
// try {
// for (; ; ) {
// int c = from.read();
// if (c == -1)
// break;
// to.write((char) c);
// }
// } catch (IOException ignore) {
// }
// });
// t.start();
// return t;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
| import com.xebialabs.overcast.command.CommandProcessor;
import com.xebialabs.overcast.command.CommandResponse;
import static com.xebialabs.overcast.command.Command.aCommand; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantDriver {
private final String hostLabel;
private final CommandProcessor commandProcessor;
public VagrantDriver(String hostLabel, CommandProcessor commandProcessor) {
this.hostLabel = hostLabel;
this.commandProcessor = commandProcessor;
}
/**
* Executes vagrant command which means that arguments passed here will be prepended with "vagrant"
* @param vagrantCommand arguments for <i>vagrant</i> command
* @return vagrant response object
*/
public CommandResponse doVagrant(String vagrantVm, final String... vagrantCommand) {
CommandResponse response = commandProcessor.run( | // Path: src/main/java/com/xebialabs/overcast/command/CommandProcessor.java
// public class CommandProcessor {
//
// public static Logger logger = LoggerFactory.getLogger(CommandProcessor.class);
//
// private String execDir = ".";
//
// private CommandProcessor(final String execDir) {
// this.execDir = execDir;
// }
//
// private CommandProcessor() {}
//
// public static CommandProcessor atLocation(String l) {
// return new CommandProcessor(l);
// }
//
// public static CommandProcessor atCurrentDir() {
// return new CommandProcessor();
// }
//
// public CommandResponse run(final Command command) {
//
// logger.debug("Executing command {}", command);
//
// try {
// Process p = new ProcessBuilder(command.asList()).directory(new File(execDir)).start();
//
// // We do this small trick to have stdout and stderr of the process on the console and
// // at the same time capture them to strings.
// ByteArrayOutputStream errors = new ByteArrayOutputStream();
// ByteArrayOutputStream messages = new ByteArrayOutputStream();
//
// Thread t1 = showProcessOutput(new TeeInputStream(p.getErrorStream(), errors), System.err);
// Thread t2 = showProcessOutput(new TeeInputStream(p.getInputStream(), messages), System.out);
//
// int code = p.waitFor();
//
// t1.join();
// t2.join();
//
// CommandResponse response = new CommandResponse(code, errors.toString(), messages.toString());
//
// if (!response.isSuccessful()) {
// throw new NonZeroCodeException(command, response);
// }
//
// return response;
//
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// } catch (IOException e) {
// throw new RuntimeException("Cannot execute " + command.toString(), e);
// }
// }
//
// private Thread showProcessOutput(final InputStream from, final PrintStream to) {
// Thread t = new Thread(() -> {
// try {
// for (; ; ) {
// int c = from.read();
// if (c == -1)
// break;
// to.write((char) c);
// }
// } catch (IOException ignore) {
// }
// });
// t.start();
// return t;
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/CommandResponse.java
// public class CommandResponse {
//
// private final int returnCode;
//
// private final String errors;
//
// private final String output;
//
// public CommandResponse(int returnCode, String errors, String output) {
// this.returnCode = returnCode;
// this.errors = errors;
// this.output = output;
// }
//
// public int getReturnCode() {
// return returnCode;
// }
//
// public String getErrors() {
// return errors;
// }
//
// public String getOutput() {
// return output;
// }
//
// public boolean isSuccessful() {
// return getReturnCode() == 0;
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/command/Command.java
// public static Command aCommand(String executable) {
// if (executable == null) {
// throw new IllegalArgumentException("Executable can not be null");
// }
// Command c = new Command();
// c.withPart(executable);
// return c;
// }
// Path: src/main/java/com/xebialabs/overcast/support/vagrant/VagrantDriver.java
import com.xebialabs.overcast.command.CommandProcessor;
import com.xebialabs.overcast.command.CommandResponse;
import static com.xebialabs.overcast.command.Command.aCommand;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.vagrant;
public class VagrantDriver {
private final String hostLabel;
private final CommandProcessor commandProcessor;
public VagrantDriver(String hostLabel, CommandProcessor commandProcessor) {
this.hostLabel = hostLabel;
this.commandProcessor = commandProcessor;
}
/**
* Executes vagrant command which means that arguments passed here will be prepended with "vagrant"
* @param vagrantCommand arguments for <i>vagrant</i> command
* @return vagrant response object
*/
public CommandResponse doVagrant(String vagrantVm, final String... vagrantCommand) {
CommandResponse response = commandProcessor.run( | aCommand("vagrant").withArguments(vagrantCommand).withOptions(vagrantVm) |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/libvirt/SshIpLookupStrategy.java | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
//
// Path: src/main/java/com/xebialabs/overcast/OverthereUtil.java
// public static OverthereConnection overthereConnectionFromURI(String url) {
// try {
// return overthereConnectionFromURI(new URI(url));
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
| import com.xebialabs.overthere.CmdLine;
import com.xebialabs.overthere.OverthereConnection;
import com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static com.xebialabs.overcast.OverthereUtil.overthereConnectionFromURI;
import static com.xebialabs.overcast.Preconditions.checkNotNull;
import static com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler.capturingHandler; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
/**
* {@link IpLookupStrategy} that uses SSH to execute a command on a remote host to look up the IP based on the MAC.
*/
public class SshIpLookupStrategy implements IpLookupStrategy {
private static final Logger log = LoggerFactory.getLogger(SshIpLookupStrategy.class);
private static final String SSH_TIMEOUT_SUFFIX = ".SSH.timeout";
private static final String SSH_COMMAND_SUFFIX = ".SSH.command";
private static final String SSH_URL_SUFFIX = ".SSH.url";
private final URI url;
private final String command;
private final int timeout;
public SshIpLookupStrategy(URI url, String command, int timeout) {
this.url = url;
this.command = command;
this.timeout = timeout;
}
public static SshIpLookupStrategy create(String prefix) {
try { | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
//
// Path: src/main/java/com/xebialabs/overcast/OverthereUtil.java
// public static OverthereConnection overthereConnectionFromURI(String url) {
// try {
// return overthereConnectionFromURI(new URI(url));
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/SshIpLookupStrategy.java
import com.xebialabs.overthere.CmdLine;
import com.xebialabs.overthere.OverthereConnection;
import com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static com.xebialabs.overcast.OverthereUtil.overthereConnectionFromURI;
import static com.xebialabs.overcast.Preconditions.checkNotNull;
import static com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler.capturingHandler;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
/**
* {@link IpLookupStrategy} that uses SSH to execute a command on a remote host to look up the IP based on the MAC.
*/
public class SshIpLookupStrategy implements IpLookupStrategy {
private static final Logger log = LoggerFactory.getLogger(SshIpLookupStrategy.class);
private static final String SSH_TIMEOUT_SUFFIX = ".SSH.timeout";
private static final String SSH_COMMAND_SUFFIX = ".SSH.command";
private static final String SSH_URL_SUFFIX = ".SSH.url";
private final URI url;
private final String command;
private final int timeout;
public SshIpLookupStrategy(URI url, String command, int timeout) {
this.url = url;
this.command = command;
this.timeout = timeout;
}
public static SshIpLookupStrategy create(String prefix) {
try { | URI uri = new URI(getRequiredOvercastProperty(prefix + SSH_URL_SUFFIX)); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/libvirt/SshIpLookupStrategy.java | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
//
// Path: src/main/java/com/xebialabs/overcast/OverthereUtil.java
// public static OverthereConnection overthereConnectionFromURI(String url) {
// try {
// return overthereConnectionFromURI(new URI(url));
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
| import com.xebialabs.overthere.CmdLine;
import com.xebialabs.overthere.OverthereConnection;
import com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static com.xebialabs.overcast.OverthereUtil.overthereConnectionFromURI;
import static com.xebialabs.overcast.Preconditions.checkNotNull;
import static com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler.capturingHandler; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
/**
* {@link IpLookupStrategy} that uses SSH to execute a command on a remote host to look up the IP based on the MAC.
*/
public class SshIpLookupStrategy implements IpLookupStrategy {
private static final Logger log = LoggerFactory.getLogger(SshIpLookupStrategy.class);
private static final String SSH_TIMEOUT_SUFFIX = ".SSH.timeout";
private static final String SSH_COMMAND_SUFFIX = ".SSH.command";
private static final String SSH_URL_SUFFIX = ".SSH.url";
private final URI url;
private final String command;
private final int timeout;
public SshIpLookupStrategy(URI url, String command, int timeout) {
this.url = url;
this.command = command;
this.timeout = timeout;
}
public static SshIpLookupStrategy create(String prefix) {
try {
URI uri = new URI(getRequiredOvercastProperty(prefix + SSH_URL_SUFFIX));
String command = getRequiredOvercastProperty(prefix + SSH_COMMAND_SUFFIX); | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
//
// Path: src/main/java/com/xebialabs/overcast/OverthereUtil.java
// public static OverthereConnection overthereConnectionFromURI(String url) {
// try {
// return overthereConnectionFromURI(new URI(url));
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/SshIpLookupStrategy.java
import com.xebialabs.overthere.CmdLine;
import com.xebialabs.overthere.OverthereConnection;
import com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static com.xebialabs.overcast.OverthereUtil.overthereConnectionFromURI;
import static com.xebialabs.overcast.Preconditions.checkNotNull;
import static com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler.capturingHandler;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
/**
* {@link IpLookupStrategy} that uses SSH to execute a command on a remote host to look up the IP based on the MAC.
*/
public class SshIpLookupStrategy implements IpLookupStrategy {
private static final Logger log = LoggerFactory.getLogger(SshIpLookupStrategy.class);
private static final String SSH_TIMEOUT_SUFFIX = ".SSH.timeout";
private static final String SSH_COMMAND_SUFFIX = ".SSH.command";
private static final String SSH_URL_SUFFIX = ".SSH.url";
private final URI url;
private final String command;
private final int timeout;
public SshIpLookupStrategy(URI url, String command, int timeout) {
this.url = url;
this.command = command;
this.timeout = timeout;
}
public static SshIpLookupStrategy create(String prefix) {
try {
URI uri = new URI(getRequiredOvercastProperty(prefix + SSH_URL_SUFFIX));
String command = getRequiredOvercastProperty(prefix + SSH_COMMAND_SUFFIX); | int timeout = Integer.parseInt(getOvercastProperty(prefix + SSH_TIMEOUT_SUFFIX, "60")); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/libvirt/SshIpLookupStrategy.java | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
//
// Path: src/main/java/com/xebialabs/overcast/OverthereUtil.java
// public static OverthereConnection overthereConnectionFromURI(String url) {
// try {
// return overthereConnectionFromURI(new URI(url));
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
| import com.xebialabs.overthere.CmdLine;
import com.xebialabs.overthere.OverthereConnection;
import com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static com.xebialabs.overcast.OverthereUtil.overthereConnectionFromURI;
import static com.xebialabs.overcast.Preconditions.checkNotNull;
import static com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler.capturingHandler; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
/**
* {@link IpLookupStrategy} that uses SSH to execute a command on a remote host to look up the IP based on the MAC.
*/
public class SshIpLookupStrategy implements IpLookupStrategy {
private static final Logger log = LoggerFactory.getLogger(SshIpLookupStrategy.class);
private static final String SSH_TIMEOUT_SUFFIX = ".SSH.timeout";
private static final String SSH_COMMAND_SUFFIX = ".SSH.command";
private static final String SSH_URL_SUFFIX = ".SSH.url";
private final URI url;
private final String command;
private final int timeout;
public SshIpLookupStrategy(URI url, String command, int timeout) {
this.url = url;
this.command = command;
this.timeout = timeout;
}
public static SshIpLookupStrategy create(String prefix) {
try {
URI uri = new URI(getRequiredOvercastProperty(prefix + SSH_URL_SUFFIX));
String command = getRequiredOvercastProperty(prefix + SSH_COMMAND_SUFFIX);
int timeout = Integer.parseInt(getOvercastProperty(prefix + SSH_TIMEOUT_SUFFIX, "60"));
SshIpLookupStrategy instance = new SshIpLookupStrategy(uri, command, timeout);
return instance;
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
@Override
public String lookup(String mac) { | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
//
// Path: src/main/java/com/xebialabs/overcast/OverthereUtil.java
// public static OverthereConnection overthereConnectionFromURI(String url) {
// try {
// return overthereConnectionFromURI(new URI(url));
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/SshIpLookupStrategy.java
import com.xebialabs.overthere.CmdLine;
import com.xebialabs.overthere.OverthereConnection;
import com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static com.xebialabs.overcast.OverthereUtil.overthereConnectionFromURI;
import static com.xebialabs.overcast.Preconditions.checkNotNull;
import static com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler.capturingHandler;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
/**
* {@link IpLookupStrategy} that uses SSH to execute a command on a remote host to look up the IP based on the MAC.
*/
public class SshIpLookupStrategy implements IpLookupStrategy {
private static final Logger log = LoggerFactory.getLogger(SshIpLookupStrategy.class);
private static final String SSH_TIMEOUT_SUFFIX = ".SSH.timeout";
private static final String SSH_COMMAND_SUFFIX = ".SSH.command";
private static final String SSH_URL_SUFFIX = ".SSH.url";
private final URI url;
private final String command;
private final int timeout;
public SshIpLookupStrategy(URI url, String command, int timeout) {
this.url = url;
this.command = command;
this.timeout = timeout;
}
public static SshIpLookupStrategy create(String prefix) {
try {
URI uri = new URI(getRequiredOvercastProperty(prefix + SSH_URL_SUFFIX));
String command = getRequiredOvercastProperty(prefix + SSH_COMMAND_SUFFIX);
int timeout = Integer.parseInt(getOvercastProperty(prefix + SSH_TIMEOUT_SUFFIX, "60"));
SshIpLookupStrategy instance = new SshIpLookupStrategy(uri, command, timeout);
return instance;
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
@Override
public String lookup(String mac) { | checkNotNull(mac, "Need a MAC to lookup the IP of a host."); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/libvirt/SshIpLookupStrategy.java | // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
//
// Path: src/main/java/com/xebialabs/overcast/OverthereUtil.java
// public static OverthereConnection overthereConnectionFromURI(String url) {
// try {
// return overthereConnectionFromURI(new URI(url));
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
| import com.xebialabs.overthere.CmdLine;
import com.xebialabs.overthere.OverthereConnection;
import com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static com.xebialabs.overcast.OverthereUtil.overthereConnectionFromURI;
import static com.xebialabs.overcast.Preconditions.checkNotNull;
import static com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler.capturingHandler; | private final String command;
private final int timeout;
public SshIpLookupStrategy(URI url, String command, int timeout) {
this.url = url;
this.command = command;
this.timeout = timeout;
}
public static SshIpLookupStrategy create(String prefix) {
try {
URI uri = new URI(getRequiredOvercastProperty(prefix + SSH_URL_SUFFIX));
String command = getRequiredOvercastProperty(prefix + SSH_COMMAND_SUFFIX);
int timeout = Integer.parseInt(getOvercastProperty(prefix + SSH_TIMEOUT_SUFFIX, "60"));
SshIpLookupStrategy instance = new SshIpLookupStrategy(uri, command, timeout);
return instance;
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
@Override
public String lookup(String mac) {
checkNotNull(mac, "Need a MAC to lookup the IP of a host.");
CmdLine cmdLine = new CmdLine();
String fragment = MessageFormat.format(command, mac);
cmdLine.addRaw(fragment);
log.info("Will use command '{}' to detect IP", cmdLine);
| // Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getOvercastProperty(String key) {
// return getOvercastProperty(key, null);
// }
//
// Path: src/main/java/com/xebialabs/overcast/OvercastProperties.java
// public static String getRequiredOvercastProperty(String key) {
// String value = getOvercastProperty(key);
// checkState(value != null, "Required property %s is not specified as a system property or in " + PropertiesLoader.OVERCAST_CONF_FILE
// + " which can be placed in the current working directory, in ~/.overcast or on the classpath", key);
// return value;
// }
//
// Path: src/main/java/com/xebialabs/overcast/OverthereUtil.java
// public static OverthereConnection overthereConnectionFromURI(String url) {
// try {
// return overthereConnectionFromURI(new URI(url));
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/SshIpLookupStrategy.java
import com.xebialabs.overthere.CmdLine;
import com.xebialabs.overthere.OverthereConnection;
import com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import static com.xebialabs.overcast.OvercastProperties.getOvercastProperty;
import static com.xebialabs.overcast.OvercastProperties.getRequiredOvercastProperty;
import static com.xebialabs.overcast.OverthereUtil.overthereConnectionFromURI;
import static com.xebialabs.overcast.Preconditions.checkNotNull;
import static com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler.capturingHandler;
private final String command;
private final int timeout;
public SshIpLookupStrategy(URI url, String command, int timeout) {
this.url = url;
this.command = command;
this.timeout = timeout;
}
public static SshIpLookupStrategy create(String prefix) {
try {
URI uri = new URI(getRequiredOvercastProperty(prefix + SSH_URL_SUFFIX));
String command = getRequiredOvercastProperty(prefix + SSH_COMMAND_SUFFIX);
int timeout = Integer.parseInt(getOvercastProperty(prefix + SSH_TIMEOUT_SUFFIX, "60"));
SshIpLookupStrategy instance = new SshIpLookupStrategy(uri, command, timeout);
return instance;
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
@Override
public String lookup(String mac) {
checkNotNull(mac, "Need a MAC to lookup the IP of a host.");
CmdLine cmdLine = new CmdLine();
String fragment = MessageFormat.format(command, mac);
cmdLine.addRaw(fragment);
log.info("Will use command '{}' to detect IP", cmdLine);
| try (OverthereConnection connection = overthereConnectionFromURI(url)) { |
xebialabs/overcast | src/test/java/com/xebialabs/overcast/support/libvirt/jdom/DomainXmlTest.java | // Path: src/main/java/com/xebialabs/overcast/Resources.java
// public final class Resources {
// private Resources() {}
//
// public static URL getResource(String resourceName) {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) {
// loader = Resources.class.getClassLoader();
// }
// URL url = loader.getResource(resourceName);
// checkArgument(url != null, "resource %s not found.", resourceName);
// return url;
// }
//
// }
| import com.xebialabs.overcast.Resources;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt.jdom;
public class DomainXmlTest {
public Document getXml(String file) throws Exception {
SAXBuilder saxBuilder = new SAXBuilder(); | // Path: src/main/java/com/xebialabs/overcast/Resources.java
// public final class Resources {
// private Resources() {}
//
// public static URL getResource(String resourceName) {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) {
// loader = Resources.class.getClassLoader();
// }
// URL url = loader.getResource(resourceName);
// checkArgument(url != null, "resource %s not found.", resourceName);
// return url;
// }
//
// }
// Path: src/test/java/com/xebialabs/overcast/support/libvirt/jdom/DomainXmlTest.java
import com.xebialabs.overcast.Resources;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt.jdom;
public class DomainXmlTest {
public Document getXml(String file) throws Exception {
SAXBuilder saxBuilder = new SAXBuilder(); | return saxBuilder.build(Resources.getResource(file)); |
xebialabs/overcast | src/main/java/com/xebialabs/overcast/support/libvirt/Metadata.java | // Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public final class Preconditions {
// private Preconditions() {}
//
// public static void checkState(
// boolean expression,
// String errorMessageTemplate,
// Object... errorMessageArgs) {
// if (!expression) {
// throw new IllegalStateException(String.format(errorMessageTemplate, errorMessageArgs));
// }
// }
//
// public static void checkArgument(
// boolean expression,
// String errorMessageTemplate,
// Object... errorMessageArgs) {
// if (!expression) {
// throw new IllegalArgumentException(String.format(errorMessageTemplate, errorMessageArgs));
// }
// }
//
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
//
// public static void checkNotNull(
// Object reference, String errorMessageTemplate, Object... errorMessageArgs) {
// if (reference == null) {
// throw new NullPointerException(String.format(errorMessageTemplate, errorMessageArgs));
// }
// }
//
// public static void checkNotNullOrEmpty(String s) {
// if (isNullOrEmpty(s)) {
// throw new NullPointerException();
// }
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static String getElementText(Element parent, String localName, Namespace ns) {
// if (parent == null) {
// throw new IllegalArgumentException("parent element not found");
// }
// Element child = parent.getChild(localName, ns);
// if (child == null) {
// throw new IllegalArgumentException(String.format("child element '%s' not found", localName));
// }
// return child.getText();
// }
| import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import com.xebialabs.overcast.Preconditions;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.Namespace;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.getElementText; | /**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
/**
* Utility to deal with the metadata we set on Libvirt Domains. Metadata can be for a provisioned domain or for just a clone.
* <p>For a provisioned domain it looks like:
* <pre>
* <metadata>
* <overcast_metdata xmlns="http://www.xebialabs.com/overcast/metadata/v1">
* <parent_domain>centos6</parent_domain>
* <provisioned_with>/mnt/puppet/Vagrantfile</provisioned_with>
* <provisioned_checksum>2008-10-31T15:07:38.6875000-05:00</provisioned_checksum>
* <creation_time>2008-10-31T15:07:38.6875000-05:00</provisioned_at>
* </overcast_metdata>
* </metadata>
* </pre>
* <p>For a cloned domain it looks like:
* <pre>
* <metadata>
* <overcast_metdata xmlns="http://www.xebialabs.com/overcast/metadata/v1">
* <parent_domain>centos6</parent_domain>
* <creation_time>2008-10-31T15:07:38.6875000-05:00</provisioned_at>
* </overcast_metdata>
* </metadata>
* </pre>
*/
public class Metadata {
private static final String XML_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
public static final String METADATA_NS_V1 = "http://www.xebialabs.com/overcast/metadata/v1";
public static final String METADATA = "metadata";
public static final String OVERCAST_METADATA = "overcast_metadata";
public static final String CREATION_TIME = "creation_time";
public static final String PROVISIONED_CHECKSUM = "provisioned_checksum";
public static final String PROVISIONED_WITH = "provisioned_with";
public static final String PARENT_DOMAIN = "parent_domain";
private static final TimeZone METADATA_TIMEZONE = TimeZone.getTimeZone("UTC");
private final String parentDomain;
private final String provisionedWith;
private final String provisionedChecksum;
private final Date creationTime;
public Metadata(String parentDomain, String provisionedWith, String provisionedChecksum, Date creationTime) { | // Path: src/main/java/com/xebialabs/overcast/Preconditions.java
// public final class Preconditions {
// private Preconditions() {}
//
// public static void checkState(
// boolean expression,
// String errorMessageTemplate,
// Object... errorMessageArgs) {
// if (!expression) {
// throw new IllegalStateException(String.format(errorMessageTemplate, errorMessageArgs));
// }
// }
//
// public static void checkArgument(
// boolean expression,
// String errorMessageTemplate,
// Object... errorMessageArgs) {
// if (!expression) {
// throw new IllegalArgumentException(String.format(errorMessageTemplate, errorMessageArgs));
// }
// }
//
// public static void checkNotNull(Object reference) {
// if (reference == null) {
// throw new NullPointerException();
// }
// }
//
// public static void checkNotNull(
// Object reference, String errorMessageTemplate, Object... errorMessageArgs) {
// if (reference == null) {
// throw new NullPointerException(String.format(errorMessageTemplate, errorMessageArgs));
// }
// }
//
// public static void checkNotNullOrEmpty(String s) {
// if (isNullOrEmpty(s)) {
// throw new NullPointerException();
// }
// }
//
// }
//
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/JDomUtil.java
// public static String getElementText(Element parent, String localName, Namespace ns) {
// if (parent == null) {
// throw new IllegalArgumentException("parent element not found");
// }
// Element child = parent.getChild(localName, ns);
// if (child == null) {
// throw new IllegalArgumentException(String.format("child element '%s' not found", localName));
// }
// return child.getText();
// }
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Metadata.java
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import com.xebialabs.overcast.Preconditions;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.Namespace;
import static com.xebialabs.overcast.support.libvirt.JDomUtil.getElementText;
/**
* Copyright 2012-2021 Digital.ai
*
* 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 com.xebialabs.overcast.support.libvirt;
/**
* Utility to deal with the metadata we set on Libvirt Domains. Metadata can be for a provisioned domain or for just a clone.
* <p>For a provisioned domain it looks like:
* <pre>
* <metadata>
* <overcast_metdata xmlns="http://www.xebialabs.com/overcast/metadata/v1">
* <parent_domain>centos6</parent_domain>
* <provisioned_with>/mnt/puppet/Vagrantfile</provisioned_with>
* <provisioned_checksum>2008-10-31T15:07:38.6875000-05:00</provisioned_checksum>
* <creation_time>2008-10-31T15:07:38.6875000-05:00</provisioned_at>
* </overcast_metdata>
* </metadata>
* </pre>
* <p>For a cloned domain it looks like:
* <pre>
* <metadata>
* <overcast_metdata xmlns="http://www.xebialabs.com/overcast/metadata/v1">
* <parent_domain>centos6</parent_domain>
* <creation_time>2008-10-31T15:07:38.6875000-05:00</provisioned_at>
* </overcast_metdata>
* </metadata>
* </pre>
*/
public class Metadata {
private static final String XML_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
public static final String METADATA_NS_V1 = "http://www.xebialabs.com/overcast/metadata/v1";
public static final String METADATA = "metadata";
public static final String OVERCAST_METADATA = "overcast_metadata";
public static final String CREATION_TIME = "creation_time";
public static final String PROVISIONED_CHECKSUM = "provisioned_checksum";
public static final String PROVISIONED_WITH = "provisioned_with";
public static final String PARENT_DOMAIN = "parent_domain";
private static final TimeZone METADATA_TIMEZONE = TimeZone.getTimeZone("UTC");
private final String parentDomain;
private final String provisionedWith;
private final String provisionedChecksum;
private final Date creationTime;
public Metadata(String parentDomain, String provisionedWith, String provisionedChecksum, Date creationTime) { | Preconditions.checkNotNull(creationTime, "creationTime cannot be null"); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.