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 |
|---|---|---|---|---|---|---|
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/firstname/FirstnameComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.firstname;
@Component
public class FirstnameComponent implements FxmlComponent {
public static final String FIRST_NAME_FIELD_NAME = "First name";
@Override
public FxmlFile getFile() {
return () -> "Firstname.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/firstname/FirstnameComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.firstname;
@Component
public class FirstnameComponent implements FxmlComponent {
public static final String FIRST_NAME_FIELD_NAME = "First name";
@Override
public FxmlFile getFile() {
return () -> "Firstname.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/samples/button/ButtonComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass; | /*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.button;
@Component
public class ButtonComponent implements FxmlComponent {
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/button/ButtonComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass;
/*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.button;
@Component
public class ButtonComponent implements FxmlComponent {
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/samples/button/ButtonComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass; | /*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.button;
@Component
public class ButtonComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "Button.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/button/ButtonComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass;
/*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.button;
@Component
public class ButtonComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "Button.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/samples/button/ButtonComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass; | /*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.button;
@Component
public class ButtonComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "Button.fxml";
}
@Override
public Class<? extends FxmlController> getControllerClass() { | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/button/ButtonComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass;
/*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.button;
@Component
public class ButtonComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "Button.fxml";
}
@Override
public Class<? extends FxmlController> getControllerClass() { | return NoControllerClass.class; |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/util/PropertiesTest.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/util/Properties.java
// public static <T, P extends ObservableValue<T>> void whenPropertyIsSet(P property, Consumer<T> doWhenSet) {
// whenPropertyIsSet(property, () -> doWhenSet.accept(property.getValue()));
// }
| import static moe.tristan.easyfxml.util.Properties.whenPropertyIsSet;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.stream.IntStream;
import org.junit.jupiter.api.Test;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.util;
public class PropertiesTest {
@Test
public void shouldCallDirectlyIfSetWithValue() {
final Object element = new Object();
final Property<Object> called = new SimpleObjectProperty<>(null);
Properties.newPropertyWithCallback(() -> new SimpleObjectProperty<>(element), called::setValue);
assertThat(called.getValue()).isSameAs(element);
}
@Test
public void shouldCallConsumerOnEverySetCall() {
final Property<Integer> called = new SimpleObjectProperty<>();
final Property<Integer> property = Properties.newPropertyWithCallback(SimpleObjectProperty::new, called::setValue);
assertThat(called.getValue()).isNull();
IntStream.range(0, 1000).forEach(value -> {
property.setValue(value);
assertThat(called.getValue()).isEqualTo(value);
});
}
@Test
public void awaitCallsDirectlyIfSet() {
final Property<Object> valuedProp = new SimpleObjectProperty<>(new Object());
final Property<Object> listener = new SimpleObjectProperty<>();
| // Path: easyfxml/src/main/java/moe/tristan/easyfxml/util/Properties.java
// public static <T, P extends ObservableValue<T>> void whenPropertyIsSet(P property, Consumer<T> doWhenSet) {
// whenPropertyIsSet(property, () -> doWhenSet.accept(property.getValue()));
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/util/PropertiesTest.java
import static moe.tristan.easyfxml.util.Properties.whenPropertyIsSet;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.stream.IntStream;
import org.junit.jupiter.api.Test;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.util;
public class PropertiesTest {
@Test
public void shouldCallDirectlyIfSetWithValue() {
final Object element = new Object();
final Property<Object> called = new SimpleObjectProperty<>(null);
Properties.newPropertyWithCallback(() -> new SimpleObjectProperty<>(element), called::setValue);
assertThat(called.getValue()).isSameAs(element);
}
@Test
public void shouldCallConsumerOnEverySetCall() {
final Property<Integer> called = new SimpleObjectProperty<>();
final Property<Integer> property = Properties.newPropertyWithCallback(SimpleObjectProperty::new, called::setValue);
assertThat(called.getValue()).isNull();
IntStream.range(0, 1000).forEach(value -> {
property.setValue(value);
assertThat(called.getValue()).isEqualTo(value);
});
}
@Test
public void awaitCallsDirectlyIfSet() {
final Property<Object> valuedProp = new SimpleObjectProperty<>(new Object());
final Property<Object> listener = new SimpleObjectProperty<>();
| whenPropertyIsSet(valuedProp, listener::setValue); |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/FxmlLoadResult.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/exception/ExceptionHandler.java
// public final class ExceptionHandler {
//
// private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class);
// private static final double ERROR_FIELD_MARGIN_SIZE = 20.0;
//
// private final Throwable exception;
//
// /**
// * Creates an instance with the given exception.
// *
// * @param exception The exception to base this instance on
// */
// public ExceptionHandler(final Throwable exception) {
// LOG.debug("Generating ExceptionPane for exception of type {}", exception.getClass());
// this.exception = exception;
// }
//
// /**
// * @return The exception in a pane with {@link Throwable#getMessage()} as a label over the stacktrace.
// */
// public Pane asPane() {
// return this.asPane(this.exception.getMessage());
// }
//
// /**
// * Same as {@link #asPane()} but with a custom error label on top of the stack trace.
// *
// * @param userReadableError The custom error message.
// *
// * @return The exception in a pane with the custom error message as a label over the stacktrace.
// */
// public Pane asPane(final String userReadableError) {
// LOG.debug("Generating node corresponding to ExceptionPane...");
// final Label messageLabel = new Label(userReadableError);
// final TextArea throwableDataLabel = new TextArea(formatErrorMessage(this.exception));
//
// AnchorPane.setLeftAnchor(messageLabel, ERROR_FIELD_MARGIN_SIZE);
// Nodes.centerNode(throwableDataLabel, ERROR_FIELD_MARGIN_SIZE);
// return new AnchorPane(messageLabel, throwableDataLabel);
// }
//
// public static Pane fromThrowable(final Throwable throwable) {
// return new ExceptionHandler(throwable).asPane();
// }
//
// /**
// * Creates a pop-up and displays it based on a given exception, pop-up title and custom error message.
// *
// * @param title The title of the error pop-up
// * @param readable The custom label to display on top of the stack trace
// * @param exception The exception to use
// *
// * @return a {@link CompletionStage} to know when the pop-up displayed and have a handle on it.
// */
// public static CompletionStage<Stage> displayExceptionPane(
// final String title,
// final String readable,
// final Throwable exception
// ) {
// final Pane exceptionPane = new ExceptionHandler(exception).asPane(readable);
// final CompletionStage<Stage> exceptionStage = Stages.stageOf(title, exceptionPane);
// return exceptionStage.thenCompose(Stages::scheduleDisplaying);
// }
//
// private static String formatErrorMessage(final Throwable throwable) {
// return "Message : \n" +
// throwable.getMessage() +
// "\nStackTrace:\n" +
// Arrays.stream(throwable.getStackTrace())
// .map(StackTraceElement::toString)
// .collect(Collectors.joining("\n"));
// }
//
// }
| import java.util.Objects;
import java.util.function.Consumer;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.layout.Pane;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.model.exception.ExceptionHandler;
import io.vavr.Tuple;
import io.vavr.collection.List;
import io.vavr.collection.Seq;
import io.vavr.control.Try; | * successes (in the sense of {@link Try#isSuccess()} and be non-null values.
*/
private void ensureCorrectlyLoaded() {
if (node.isFailure()) {
throw new IllegalStateException("Node did not properly load!", node.getCause());
}
if (controller.isFailure()) {
throw new IllegalStateException("Controller did not properly load!", controller.getCause());
}
Objects.requireNonNull(node.get(), "The node did not load properly and was null.");
Objects.requireNonNull(controller.get(), "The controller did not load properly and was null.");
}
/**
* @return The result of the attempt to load the {@link Node} as a {@link Try} instance.
*/
public Try<NODE> getNode() {
return node;
}
/**
* @return The result of the attempt to build the controller associated to the node as a {@link Try} instance.
*/
public Try<CONTROLLER> getController() {
return controller;
}
public Try<Pane> orExceptionPane() {
//noinspection unchecked | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/exception/ExceptionHandler.java
// public final class ExceptionHandler {
//
// private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class);
// private static final double ERROR_FIELD_MARGIN_SIZE = 20.0;
//
// private final Throwable exception;
//
// /**
// * Creates an instance with the given exception.
// *
// * @param exception The exception to base this instance on
// */
// public ExceptionHandler(final Throwable exception) {
// LOG.debug("Generating ExceptionPane for exception of type {}", exception.getClass());
// this.exception = exception;
// }
//
// /**
// * @return The exception in a pane with {@link Throwable#getMessage()} as a label over the stacktrace.
// */
// public Pane asPane() {
// return this.asPane(this.exception.getMessage());
// }
//
// /**
// * Same as {@link #asPane()} but with a custom error label on top of the stack trace.
// *
// * @param userReadableError The custom error message.
// *
// * @return The exception in a pane with the custom error message as a label over the stacktrace.
// */
// public Pane asPane(final String userReadableError) {
// LOG.debug("Generating node corresponding to ExceptionPane...");
// final Label messageLabel = new Label(userReadableError);
// final TextArea throwableDataLabel = new TextArea(formatErrorMessage(this.exception));
//
// AnchorPane.setLeftAnchor(messageLabel, ERROR_FIELD_MARGIN_SIZE);
// Nodes.centerNode(throwableDataLabel, ERROR_FIELD_MARGIN_SIZE);
// return new AnchorPane(messageLabel, throwableDataLabel);
// }
//
// public static Pane fromThrowable(final Throwable throwable) {
// return new ExceptionHandler(throwable).asPane();
// }
//
// /**
// * Creates a pop-up and displays it based on a given exception, pop-up title and custom error message.
// *
// * @param title The title of the error pop-up
// * @param readable The custom label to display on top of the stack trace
// * @param exception The exception to use
// *
// * @return a {@link CompletionStage} to know when the pop-up displayed and have a handle on it.
// */
// public static CompletionStage<Stage> displayExceptionPane(
// final String title,
// final String readable,
// final Throwable exception
// ) {
// final Pane exceptionPane = new ExceptionHandler(exception).asPane(readable);
// final CompletionStage<Stage> exceptionStage = Stages.stageOf(title, exceptionPane);
// return exceptionStage.thenCompose(Stages::scheduleDisplaying);
// }
//
// private static String formatErrorMessage(final Throwable throwable) {
// return "Message : \n" +
// throwable.getMessage() +
// "\nStackTrace:\n" +
// Arrays.stream(throwable.getStackTrace())
// .map(StackTraceElement::toString)
// .collect(Collectors.joining("\n"));
// }
//
// }
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/FxmlLoadResult.java
import java.util.Objects;
import java.util.function.Consumer;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.layout.Pane;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.model.exception.ExceptionHandler;
import io.vavr.Tuple;
import io.vavr.collection.List;
import io.vavr.collection.Seq;
import io.vavr.control.Try;
* successes (in the sense of {@link Try#isSuccess()} and be non-null values.
*/
private void ensureCorrectlyLoaded() {
if (node.isFailure()) {
throw new IllegalStateException("Node did not properly load!", node.getCause());
}
if (controller.isFailure()) {
throw new IllegalStateException("Controller did not properly load!", controller.getCause());
}
Objects.requireNonNull(node.get(), "The node did not load properly and was null.");
Objects.requireNonNull(controller.get(), "The controller did not load properly and was null.");
}
/**
* @return The result of the attempt to load the {@link Node} as a {@link Try} instance.
*/
public Try<NODE> getNode() {
return node;
}
/**
* @return The result of the attempt to build the controller associated to the node as a {@link Try} instance.
*/
public Try<CONTROLLER> getController() {
return controller;
}
public Try<Pane> orExceptionPane() {
//noinspection unchecked | return ((Try<Pane>) getNode()).recover(ExceptionHandler::fromThrowable); |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/TestFxUiManager.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java
// @Component
// public class PaneWithButtonComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "PaneWithButton.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return PaneWithButtonController.class;
// }
//
// }
| import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.samples.panewithbutton.PaneWithButtonComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@Component
public class TestFxUiManager extends FxUiManager {
@Autowired | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java
// @Component
// public class PaneWithButtonComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "PaneWithButton.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return PaneWithButtonController.class;
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/TestFxUiManager.java
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.samples.panewithbutton.PaneWithButtonComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@Component
public class TestFxUiManager extends FxUiManager {
@Autowired | private PaneWithButtonComponent paneWithButtonComponent; |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/TestFxUiManager.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java
// @Component
// public class PaneWithButtonComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "PaneWithButton.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return PaneWithButtonController.class;
// }
//
// }
| import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.samples.panewithbutton.PaneWithButtonComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@Component
public class TestFxUiManager extends FxUiManager {
@Autowired
private PaneWithButtonComponent paneWithButtonComponent;
@Override
protected String title() {
return "A pane with a button";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java
// @Component
// public class PaneWithButtonComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "PaneWithButton.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return PaneWithButtonController.class;
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/TestFxUiManager.java
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.samples.panewithbutton.PaneWithButtonComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@Component
public class TestFxUiManager extends FxUiManager {
@Autowired
private PaneWithButtonComponent paneWithButtonComponent;
@Override
protected String title() {
return "A pane with a button";
}
@Override | protected FxmlComponent mainComponent() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/TestFxUiManager.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java
// @Component
// public class PaneWithButtonComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "PaneWithButton.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return PaneWithButtonController.class;
// }
//
// }
| import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.samples.panewithbutton.PaneWithButtonComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@Component
public class TestFxUiManager extends FxUiManager {
@Autowired
private PaneWithButtonComponent paneWithButtonComponent;
@Override
protected String title() {
return "A pane with a button";
}
@Override
protected FxmlComponent mainComponent() {
return paneWithButtonComponent;
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java
// @Component
// public class PaneWithButtonComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "PaneWithButton.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return PaneWithButtonController.class;
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/TestFxUiManager.java
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.samples.panewithbutton.PaneWithButtonComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@Component
public class TestFxUiManager extends FxUiManager {
@Autowired
private PaneWithButtonComponent paneWithButtonComponent;
@Override
protected String title() {
return "A pane with a button";
}
@Override
protected FxmlComponent mainComponent() {
return paneWithButtonComponent;
}
@Override | protected Optional<FxmlStylesheet> getStylesheet() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/model/beanmanagement/StageManagerTest.java | // Path: easyfxml/src/test/java/moe/tristan/easyfxml/TestUtils.java
// public static boolean isSpringSingleton(final ApplicationContext context, final Class<?> beanClazz) {
// final Object bean1 = context.getBean(beanClazz);
// final Object bean2 = context.getBean(beanClazz);
//
// return bean1.equals(bean2);
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxmlAutoConfiguration.java
// @ComponentScan("moe.tristan.easyfxml")
// @EnableAutoConfiguration
// @EnableConfigurationProperties(EasyFxmlProperties.class)
// public class EasyFxmlAutoConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(EasyFxmlAutoConfiguration.class);
//
// private final ApplicationContext context;
//
// @Autowired
// public EasyFxmlAutoConfiguration(ApplicationContext context) {
// this.context = context;
// }
//
// @PostConstruct
// public void logFoundControllers() {
// final String fxmlControllersFound = String.join("\n->\t", context.getBeanNamesForType(FxmlController.class));
// LOGGER.debug("\nFound the following FxmlControllers : \n->\t{}", fxmlControllersFound);
// LOGGER.info("EasyFXML is now configured for: {}", context.getApplicationName());
// }
//
// @Bean
// @ConditionalOnBean(Application.class)
// public HostServices hostServices(final Application application) {
// return application.getHostServices();
// }
//
// }
| import static moe.tristan.easyfxml.TestUtils.isSpringSingleton;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import moe.tristan.easyfxml.EasyFxmlAutoConfiguration; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.beanmanagement;
@ContextConfiguration(classes = EasyFxmlAutoConfiguration.class)
@ExtendWith(SpringExtension.class)
public class StageManagerTest {
@Autowired
private ApplicationContext context;
@Test
public void testLinkage() {
final StageManager manager = this.context.getBean(StageManager.class);
assertThat(manager).isNotNull();
}
@Test
public void testSingleton() { | // Path: easyfxml/src/test/java/moe/tristan/easyfxml/TestUtils.java
// public static boolean isSpringSingleton(final ApplicationContext context, final Class<?> beanClazz) {
// final Object bean1 = context.getBean(beanClazz);
// final Object bean2 = context.getBean(beanClazz);
//
// return bean1.equals(bean2);
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxmlAutoConfiguration.java
// @ComponentScan("moe.tristan.easyfxml")
// @EnableAutoConfiguration
// @EnableConfigurationProperties(EasyFxmlProperties.class)
// public class EasyFxmlAutoConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(EasyFxmlAutoConfiguration.class);
//
// private final ApplicationContext context;
//
// @Autowired
// public EasyFxmlAutoConfiguration(ApplicationContext context) {
// this.context = context;
// }
//
// @PostConstruct
// public void logFoundControllers() {
// final String fxmlControllersFound = String.join("\n->\t", context.getBeanNamesForType(FxmlController.class));
// LOGGER.debug("\nFound the following FxmlControllers : \n->\t{}", fxmlControllersFound);
// LOGGER.info("EasyFXML is now configured for: {}", context.getApplicationName());
// }
//
// @Bean
// @ConditionalOnBean(Application.class)
// public HostServices hostServices(final Application application) {
// return application.getHostServices();
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/model/beanmanagement/StageManagerTest.java
import static moe.tristan.easyfxml.TestUtils.isSpringSingleton;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import moe.tristan.easyfxml.EasyFxmlAutoConfiguration;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.beanmanagement;
@ContextConfiguration(classes = EasyFxmlAutoConfiguration.class)
@ExtendWith(SpringExtension.class)
public class StageManagerTest {
@Autowired
private ApplicationContext context;
@Test
public void testLinkage() {
final StageManager manager = this.context.getBean(StageManager.class);
assertThat(manager).isNotNull();
}
@Test
public void testSingleton() { | assertThat(isSpringSingleton(this.context, StageManager.class)).isTrue(); |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/FxmlStylesheets.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
| import moe.tristan.easyfxml.api.FxmlStylesheet; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.fxml;
/**
* This class contains a few constants for default {@link FxmlStylesheet} implementations.
*/
public final class FxmlStylesheets {
private FxmlStylesheets() {
}
| // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/FxmlStylesheets.java
import moe.tristan.easyfxml.api.FxmlStylesheet;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.fxml;
/**
* This class contains a few constants for default {@link FxmlStylesheet} implementations.
*/
public final class FxmlStylesheets {
private FxmlStylesheets() {
}
| public static final FxmlStylesheet DEFAULT_JAVAFX_STYLE = () -> null; |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/FxmlComponentLoadException.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import java.io.Serializable;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.fxml;
class FxmlComponentLoadException extends RuntimeException implements Serializable {
private static final long serialVersionUID = -5375149649340364076L;
| // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/FxmlComponentLoadException.java
import java.io.Serializable;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.fxml;
class FxmlComponentLoadException extends RuntimeException implements Serializable {
private static final long serialVersionUID = -5375149649340364076L;
| FxmlComponentLoadException(FxmlComponent component, Throwable cause) { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/hello/HelloController.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/util/Buttons.java
// public static void setOnClick(final Button button, final Runnable action) {
// button.setOnAction(e -> Platform.runLater(action));
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
| import static java.util.function.Predicate.not;
import static moe.tristan.easyfxml.util.Buttons.setOnClick;
import java.util.Optional;
import org.springframework.stereotype.Component;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import moe.tristan.easyfxml.api.FxmlController; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.helloworld.view.hello;
@Component
public class HelloController implements FxmlController {
@FXML
private TextField userNameTextField;
@FXML
private Button helloButton;
@FXML
public HBox greetingBox;
@FXML
private Label greetingName;
@Override
public void initialize() {
greetingBox.setVisible(false); | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/util/Buttons.java
// public static void setOnClick(final Button button, final Runnable action) {
// button.setOnAction(e -> Platform.runLater(action));
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
// Path: easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/hello/HelloController.java
import static java.util.function.Predicate.not;
import static moe.tristan.easyfxml.util.Buttons.setOnClick;
import java.util.Optional;
import org.springframework.stereotype.Component;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import moe.tristan.easyfxml.api.FxmlController;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.helloworld.view.hello;
@Component
public class HelloController implements FxmlController {
@FXML
private TextField userNameTextField;
@FXML
private Button helloButton;
@FXML
public HBox greetingBox;
@FXML
private Label greetingName;
@Override
public void initialize() {
greetingBox.setVisible(false); | setOnClick(helloButton, this::greet); |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/model/system/BrowserSupportTest.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxmlAutoConfiguration.java
// @ComponentScan("moe.tristan.easyfxml")
// @EnableAutoConfiguration
// @EnableConfigurationProperties(EasyFxmlProperties.class)
// public class EasyFxmlAutoConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(EasyFxmlAutoConfiguration.class);
//
// private final ApplicationContext context;
//
// @Autowired
// public EasyFxmlAutoConfiguration(ApplicationContext context) {
// this.context = context;
// }
//
// @PostConstruct
// public void logFoundControllers() {
// final String fxmlControllersFound = String.join("\n->\t", context.getBeanNamesForType(FxmlController.class));
// LOGGER.debug("\nFound the following FxmlControllers : \n->\t{}", fxmlControllersFound);
// LOGGER.info("EasyFXML is now configured for: {}", context.getApplicationName());
// }
//
// @Bean
// @ConditionalOnBean(Application.class)
// public HostServices hostServices(final Application application) {
// return application.getHostServices();
// }
//
// }
//
// Path: easyfxml-junit/src/main/java/moe/tristan/easyfxml/junit/SpringBootComponentTest.java
// @SpringBootTest
// @ExtendWith(ApplicationExtension.class)
// public abstract class SpringBootComponentTest extends ApplicationTest {
//
// protected final FxNodeAsyncQuery withNodes(Node... nodes) {
// return FxNodeAsyncQuery.withNodes(nodes);
// }
//
// protected Supplier<Boolean> showing(Node node) {
// return () -> {
// final PointQuery pointQuery = point(node);
// return pointQuery.query() != null;
// };
// }
//
// public static final class FxNodeAsyncQuery {
//
// private final List<Node> nodes;
//
// private List<Supplier<Boolean>> nodesReady = emptyList();
//
// private List<Runnable> actions = emptyList();
//
// private List<Supplier<Boolean>> witnesses = emptyList();
//
// FxNodeAsyncQuery(Node[] nodes) {
// this.nodes = List.of(nodes);
// }
//
// public static FxNodeAsyncQuery withNodes(Node... nodes) {
// return new FxNodeAsyncQuery(nodes);
// }
//
// @SafeVarargs
// public final FxNodeAsyncQuery startWhen(Supplier<Boolean>... readyCheck) {
// this.nodesReady = List.of(readyCheck);
// return this;
// }
//
// public final FxNodeAsyncQuery willDo(Runnable... actionsWhenReady) {
// this.actions = List.of(actionsWhenReady);
// return this;
// }
//
// @SafeVarargs
// public final void andAwaitFor(Supplier<Boolean>... awaited) {
// this.witnesses = List.of(awaited);
// run();
// }
//
// public void run() {
// runTestQuery(nodes, nodesReady, actions, witnesses);
// }
//
// private void runTestQuery(List<Node> nodes, List<Supplier<Boolean>> nodesReady, List<Runnable> actions, List<Supplier<Boolean>> witnesses) {
// CompletableFuture
// .runAsync(() -> buildStageWithNodes(nodes), Platform::runLater)
// .thenRunAsync(() -> await().until(() -> allEvaluateToTrue(nodesReady)))
// .thenRunAsync(() -> actions.forEach(Runnable::run)).join();
//
// for (Supplier<Boolean> witness : witnesses) {
// await().until(witness::get);
// }
// }
//
// private static void buildStageWithNodes(List<Node> nodes) {
// Stage testStage = new Stage();
// testStage.setScene(new Scene(new VBox(nodes.toArray(new Node[0]))));
// testStage.show();
// testStage.toFront();
// }
//
// private static Boolean allEvaluateToTrue(List<Supplier<Boolean>> nodesReady) {
// return nodesReady.stream().map(Supplier::get).reduce((prev, cur) -> prev && cur).orElse(true);
// }
//
// }
//
// }
| import static org.assertj.core.api.Assertions.assertThat;
import java.net.URL;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import moe.tristan.easyfxml.EasyFxmlAutoConfiguration;
import moe.tristan.easyfxml.junit.SpringBootComponentTest;
import io.vavr.control.Try; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.system;
@ContextConfiguration(classes = EasyFxmlAutoConfiguration.class)
@ExtendWith(SpringExtension.class) | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxmlAutoConfiguration.java
// @ComponentScan("moe.tristan.easyfxml")
// @EnableAutoConfiguration
// @EnableConfigurationProperties(EasyFxmlProperties.class)
// public class EasyFxmlAutoConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(EasyFxmlAutoConfiguration.class);
//
// private final ApplicationContext context;
//
// @Autowired
// public EasyFxmlAutoConfiguration(ApplicationContext context) {
// this.context = context;
// }
//
// @PostConstruct
// public void logFoundControllers() {
// final String fxmlControllersFound = String.join("\n->\t", context.getBeanNamesForType(FxmlController.class));
// LOGGER.debug("\nFound the following FxmlControllers : \n->\t{}", fxmlControllersFound);
// LOGGER.info("EasyFXML is now configured for: {}", context.getApplicationName());
// }
//
// @Bean
// @ConditionalOnBean(Application.class)
// public HostServices hostServices(final Application application) {
// return application.getHostServices();
// }
//
// }
//
// Path: easyfxml-junit/src/main/java/moe/tristan/easyfxml/junit/SpringBootComponentTest.java
// @SpringBootTest
// @ExtendWith(ApplicationExtension.class)
// public abstract class SpringBootComponentTest extends ApplicationTest {
//
// protected final FxNodeAsyncQuery withNodes(Node... nodes) {
// return FxNodeAsyncQuery.withNodes(nodes);
// }
//
// protected Supplier<Boolean> showing(Node node) {
// return () -> {
// final PointQuery pointQuery = point(node);
// return pointQuery.query() != null;
// };
// }
//
// public static final class FxNodeAsyncQuery {
//
// private final List<Node> nodes;
//
// private List<Supplier<Boolean>> nodesReady = emptyList();
//
// private List<Runnable> actions = emptyList();
//
// private List<Supplier<Boolean>> witnesses = emptyList();
//
// FxNodeAsyncQuery(Node[] nodes) {
// this.nodes = List.of(nodes);
// }
//
// public static FxNodeAsyncQuery withNodes(Node... nodes) {
// return new FxNodeAsyncQuery(nodes);
// }
//
// @SafeVarargs
// public final FxNodeAsyncQuery startWhen(Supplier<Boolean>... readyCheck) {
// this.nodesReady = List.of(readyCheck);
// return this;
// }
//
// public final FxNodeAsyncQuery willDo(Runnable... actionsWhenReady) {
// this.actions = List.of(actionsWhenReady);
// return this;
// }
//
// @SafeVarargs
// public final void andAwaitFor(Supplier<Boolean>... awaited) {
// this.witnesses = List.of(awaited);
// run();
// }
//
// public void run() {
// runTestQuery(nodes, nodesReady, actions, witnesses);
// }
//
// private void runTestQuery(List<Node> nodes, List<Supplier<Boolean>> nodesReady, List<Runnable> actions, List<Supplier<Boolean>> witnesses) {
// CompletableFuture
// .runAsync(() -> buildStageWithNodes(nodes), Platform::runLater)
// .thenRunAsync(() -> await().until(() -> allEvaluateToTrue(nodesReady)))
// .thenRunAsync(() -> actions.forEach(Runnable::run)).join();
//
// for (Supplier<Boolean> witness : witnesses) {
// await().until(witness::get);
// }
// }
//
// private static void buildStageWithNodes(List<Node> nodes) {
// Stage testStage = new Stage();
// testStage.setScene(new Scene(new VBox(nodes.toArray(new Node[0]))));
// testStage.show();
// testStage.toFront();
// }
//
// private static Boolean allEvaluateToTrue(List<Supplier<Boolean>> nodesReady) {
// return nodesReady.stream().map(Supplier::get).reduce((prev, cur) -> prev && cur).orElse(true);
// }
//
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/model/system/BrowserSupportTest.java
import static org.assertj.core.api.Assertions.assertThat;
import java.net.URL;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import moe.tristan.easyfxml.EasyFxmlAutoConfiguration;
import moe.tristan.easyfxml.junit.SpringBootComponentTest;
import io.vavr.control.Try;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.system;
@ContextConfiguration(classes = EasyFxmlAutoConfiguration.class)
@ExtendWith(SpringExtension.class) | public class BrowserSupportTest extends SpringBootComponentTest { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/util/StagesTest.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/util/Resources.java
// public static Try<Path> getResourcePath(final String resourceRelativePath) {
// return Try.of(() -> new ClassPathResource(resourceRelativePath))
// .filter(ClassPathResource::exists)
// .map(ClassPathResource::getPath)
// .map(Paths::get);
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml-junit/src/main/java/moe/tristan/easyfxml/junit/SpringBootComponentTest.java
// @SpringBootTest
// @ExtendWith(ApplicationExtension.class)
// public abstract class SpringBootComponentTest extends ApplicationTest {
//
// protected final FxNodeAsyncQuery withNodes(Node... nodes) {
// return FxNodeAsyncQuery.withNodes(nodes);
// }
//
// protected Supplier<Boolean> showing(Node node) {
// return () -> {
// final PointQuery pointQuery = point(node);
// return pointQuery.query() != null;
// };
// }
//
// public static final class FxNodeAsyncQuery {
//
// private final List<Node> nodes;
//
// private List<Supplier<Boolean>> nodesReady = emptyList();
//
// private List<Runnable> actions = emptyList();
//
// private List<Supplier<Boolean>> witnesses = emptyList();
//
// FxNodeAsyncQuery(Node[] nodes) {
// this.nodes = List.of(nodes);
// }
//
// public static FxNodeAsyncQuery withNodes(Node... nodes) {
// return new FxNodeAsyncQuery(nodes);
// }
//
// @SafeVarargs
// public final FxNodeAsyncQuery startWhen(Supplier<Boolean>... readyCheck) {
// this.nodesReady = List.of(readyCheck);
// return this;
// }
//
// public final FxNodeAsyncQuery willDo(Runnable... actionsWhenReady) {
// this.actions = List.of(actionsWhenReady);
// return this;
// }
//
// @SafeVarargs
// public final void andAwaitFor(Supplier<Boolean>... awaited) {
// this.witnesses = List.of(awaited);
// run();
// }
//
// public void run() {
// runTestQuery(nodes, nodesReady, actions, witnesses);
// }
//
// private void runTestQuery(List<Node> nodes, List<Supplier<Boolean>> nodesReady, List<Runnable> actions, List<Supplier<Boolean>> witnesses) {
// CompletableFuture
// .runAsync(() -> buildStageWithNodes(nodes), Platform::runLater)
// .thenRunAsync(() -> await().until(() -> allEvaluateToTrue(nodesReady)))
// .thenRunAsync(() -> actions.forEach(Runnable::run)).join();
//
// for (Supplier<Boolean> witness : witnesses) {
// await().until(witness::get);
// }
// }
//
// private static void buildStageWithNodes(List<Node> nodes) {
// Stage testStage = new Stage();
// testStage.setScene(new Scene(new VBox(nodes.toArray(new Node[0]))));
// testStage.show();
// testStage.toFront();
// }
//
// private static Boolean allEvaluateToTrue(List<Supplier<Boolean>> nodesReady) {
// return nodesReady.stream().map(Supplier::get).reduce((prev, cur) -> prev && cur).orElse(true);
// }
//
// }
//
// }
| import javafx.stage.Stage;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.junit.SpringBootComponentTest;
import io.vavr.control.Try;
import static moe.tristan.easyfxml.util.Resources.getResourcePath;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.Start;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.layout.Pane; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.util;
public class StagesTest extends SpringBootComponentTest {
private static final String RES_REL_PATH_TEST_STYLE = "css/test_style.css"; | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/util/Resources.java
// public static Try<Path> getResourcePath(final String resourceRelativePath) {
// return Try.of(() -> new ClassPathResource(resourceRelativePath))
// .filter(ClassPathResource::exists)
// .map(ClassPathResource::getPath)
// .map(Paths::get);
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml-junit/src/main/java/moe/tristan/easyfxml/junit/SpringBootComponentTest.java
// @SpringBootTest
// @ExtendWith(ApplicationExtension.class)
// public abstract class SpringBootComponentTest extends ApplicationTest {
//
// protected final FxNodeAsyncQuery withNodes(Node... nodes) {
// return FxNodeAsyncQuery.withNodes(nodes);
// }
//
// protected Supplier<Boolean> showing(Node node) {
// return () -> {
// final PointQuery pointQuery = point(node);
// return pointQuery.query() != null;
// };
// }
//
// public static final class FxNodeAsyncQuery {
//
// private final List<Node> nodes;
//
// private List<Supplier<Boolean>> nodesReady = emptyList();
//
// private List<Runnable> actions = emptyList();
//
// private List<Supplier<Boolean>> witnesses = emptyList();
//
// FxNodeAsyncQuery(Node[] nodes) {
// this.nodes = List.of(nodes);
// }
//
// public static FxNodeAsyncQuery withNodes(Node... nodes) {
// return new FxNodeAsyncQuery(nodes);
// }
//
// @SafeVarargs
// public final FxNodeAsyncQuery startWhen(Supplier<Boolean>... readyCheck) {
// this.nodesReady = List.of(readyCheck);
// return this;
// }
//
// public final FxNodeAsyncQuery willDo(Runnable... actionsWhenReady) {
// this.actions = List.of(actionsWhenReady);
// return this;
// }
//
// @SafeVarargs
// public final void andAwaitFor(Supplier<Boolean>... awaited) {
// this.witnesses = List.of(awaited);
// run();
// }
//
// public void run() {
// runTestQuery(nodes, nodesReady, actions, witnesses);
// }
//
// private void runTestQuery(List<Node> nodes, List<Supplier<Boolean>> nodesReady, List<Runnable> actions, List<Supplier<Boolean>> witnesses) {
// CompletableFuture
// .runAsync(() -> buildStageWithNodes(nodes), Platform::runLater)
// .thenRunAsync(() -> await().until(() -> allEvaluateToTrue(nodesReady)))
// .thenRunAsync(() -> actions.forEach(Runnable::run)).join();
//
// for (Supplier<Boolean> witness : witnesses) {
// await().until(witness::get);
// }
// }
//
// private static void buildStageWithNodes(List<Node> nodes) {
// Stage testStage = new Stage();
// testStage.setScene(new Scene(new VBox(nodes.toArray(new Node[0]))));
// testStage.show();
// testStage.toFront();
// }
//
// private static Boolean allEvaluateToTrue(List<Supplier<Boolean>> nodesReady) {
// return nodesReady.stream().map(Supplier::get).reduce((prev, cur) -> prev && cur).orElse(true);
// }
//
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/util/StagesTest.java
import javafx.stage.Stage;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.junit.SpringBootComponentTest;
import io.vavr.control.Try;
import static moe.tristan.easyfxml.util.Resources.getResourcePath;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.Start;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.util;
public class StagesTest extends SpringBootComponentTest {
private static final String RES_REL_PATH_TEST_STYLE = "css/test_style.css"; | private static final FxmlStylesheet TEST_STYLE = () -> getResourcePath(RES_REL_PATH_TEST_STYLE).get(); |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/util/StagesTest.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/util/Resources.java
// public static Try<Path> getResourcePath(final String resourceRelativePath) {
// return Try.of(() -> new ClassPathResource(resourceRelativePath))
// .filter(ClassPathResource::exists)
// .map(ClassPathResource::getPath)
// .map(Paths::get);
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml-junit/src/main/java/moe/tristan/easyfxml/junit/SpringBootComponentTest.java
// @SpringBootTest
// @ExtendWith(ApplicationExtension.class)
// public abstract class SpringBootComponentTest extends ApplicationTest {
//
// protected final FxNodeAsyncQuery withNodes(Node... nodes) {
// return FxNodeAsyncQuery.withNodes(nodes);
// }
//
// protected Supplier<Boolean> showing(Node node) {
// return () -> {
// final PointQuery pointQuery = point(node);
// return pointQuery.query() != null;
// };
// }
//
// public static final class FxNodeAsyncQuery {
//
// private final List<Node> nodes;
//
// private List<Supplier<Boolean>> nodesReady = emptyList();
//
// private List<Runnable> actions = emptyList();
//
// private List<Supplier<Boolean>> witnesses = emptyList();
//
// FxNodeAsyncQuery(Node[] nodes) {
// this.nodes = List.of(nodes);
// }
//
// public static FxNodeAsyncQuery withNodes(Node... nodes) {
// return new FxNodeAsyncQuery(nodes);
// }
//
// @SafeVarargs
// public final FxNodeAsyncQuery startWhen(Supplier<Boolean>... readyCheck) {
// this.nodesReady = List.of(readyCheck);
// return this;
// }
//
// public final FxNodeAsyncQuery willDo(Runnable... actionsWhenReady) {
// this.actions = List.of(actionsWhenReady);
// return this;
// }
//
// @SafeVarargs
// public final void andAwaitFor(Supplier<Boolean>... awaited) {
// this.witnesses = List.of(awaited);
// run();
// }
//
// public void run() {
// runTestQuery(nodes, nodesReady, actions, witnesses);
// }
//
// private void runTestQuery(List<Node> nodes, List<Supplier<Boolean>> nodesReady, List<Runnable> actions, List<Supplier<Boolean>> witnesses) {
// CompletableFuture
// .runAsync(() -> buildStageWithNodes(nodes), Platform::runLater)
// .thenRunAsync(() -> await().until(() -> allEvaluateToTrue(nodesReady)))
// .thenRunAsync(() -> actions.forEach(Runnable::run)).join();
//
// for (Supplier<Boolean> witness : witnesses) {
// await().until(witness::get);
// }
// }
//
// private static void buildStageWithNodes(List<Node> nodes) {
// Stage testStage = new Stage();
// testStage.setScene(new Scene(new VBox(nodes.toArray(new Node[0]))));
// testStage.show();
// testStage.toFront();
// }
//
// private static Boolean allEvaluateToTrue(List<Supplier<Boolean>> nodesReady) {
// return nodesReady.stream().map(Supplier::get).reduce((prev, cur) -> prev && cur).orElse(true);
// }
//
// }
//
// }
| import javafx.stage.Stage;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.junit.SpringBootComponentTest;
import io.vavr.control.Try;
import static moe.tristan.easyfxml.util.Resources.getResourcePath;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.Start;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.layout.Pane; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.util;
public class StagesTest extends SpringBootComponentTest {
private static final String RES_REL_PATH_TEST_STYLE = "css/test_style.css"; | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/util/Resources.java
// public static Try<Path> getResourcePath(final String resourceRelativePath) {
// return Try.of(() -> new ClassPathResource(resourceRelativePath))
// .filter(ClassPathResource::exists)
// .map(ClassPathResource::getPath)
// .map(Paths::get);
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
//
// Path: easyfxml-junit/src/main/java/moe/tristan/easyfxml/junit/SpringBootComponentTest.java
// @SpringBootTest
// @ExtendWith(ApplicationExtension.class)
// public abstract class SpringBootComponentTest extends ApplicationTest {
//
// protected final FxNodeAsyncQuery withNodes(Node... nodes) {
// return FxNodeAsyncQuery.withNodes(nodes);
// }
//
// protected Supplier<Boolean> showing(Node node) {
// return () -> {
// final PointQuery pointQuery = point(node);
// return pointQuery.query() != null;
// };
// }
//
// public static final class FxNodeAsyncQuery {
//
// private final List<Node> nodes;
//
// private List<Supplier<Boolean>> nodesReady = emptyList();
//
// private List<Runnable> actions = emptyList();
//
// private List<Supplier<Boolean>> witnesses = emptyList();
//
// FxNodeAsyncQuery(Node[] nodes) {
// this.nodes = List.of(nodes);
// }
//
// public static FxNodeAsyncQuery withNodes(Node... nodes) {
// return new FxNodeAsyncQuery(nodes);
// }
//
// @SafeVarargs
// public final FxNodeAsyncQuery startWhen(Supplier<Boolean>... readyCheck) {
// this.nodesReady = List.of(readyCheck);
// return this;
// }
//
// public final FxNodeAsyncQuery willDo(Runnable... actionsWhenReady) {
// this.actions = List.of(actionsWhenReady);
// return this;
// }
//
// @SafeVarargs
// public final void andAwaitFor(Supplier<Boolean>... awaited) {
// this.witnesses = List.of(awaited);
// run();
// }
//
// public void run() {
// runTestQuery(nodes, nodesReady, actions, witnesses);
// }
//
// private void runTestQuery(List<Node> nodes, List<Supplier<Boolean>> nodesReady, List<Runnable> actions, List<Supplier<Boolean>> witnesses) {
// CompletableFuture
// .runAsync(() -> buildStageWithNodes(nodes), Platform::runLater)
// .thenRunAsync(() -> await().until(() -> allEvaluateToTrue(nodesReady)))
// .thenRunAsync(() -> actions.forEach(Runnable::run)).join();
//
// for (Supplier<Boolean> witness : witnesses) {
// await().until(witness::get);
// }
// }
//
// private static void buildStageWithNodes(List<Node> nodes) {
// Stage testStage = new Stage();
// testStage.setScene(new Scene(new VBox(nodes.toArray(new Node[0]))));
// testStage.show();
// testStage.toFront();
// }
//
// private static Boolean allEvaluateToTrue(List<Supplier<Boolean>> nodesReady) {
// return nodesReady.stream().map(Supplier::get).reduce((prev, cur) -> prev && cur).orElse(true);
// }
//
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/util/StagesTest.java
import javafx.stage.Stage;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import moe.tristan.easyfxml.junit.SpringBootComponentTest;
import io.vavr.control.Try;
import static moe.tristan.easyfxml.util.Resources.getResourcePath;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.Start;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.util;
public class StagesTest extends SpringBootComponentTest {
private static final String RES_REL_PATH_TEST_STYLE = "css/test_style.css"; | private static final FxmlStylesheet TEST_STYLE = () -> getResourcePath(RES_REL_PATH_TEST_STYLE).get(); |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile; | /*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.panewithbutton;
@Component
public class PaneWithButtonComponent implements FxmlComponent {
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
/*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.panewithbutton;
@Component
public class PaneWithButtonComponent implements FxmlComponent {
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile; | /*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.panewithbutton;
@Component
public class PaneWithButtonComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "PaneWithButton.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
/*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.panewithbutton;
@Component
public class PaneWithButtonComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "PaneWithButton.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonController.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
| import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import moe.tristan.easyfxml.api.FxmlController; | /*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.panewithbutton;
@Scope(SCOPE_PROTOTYPE)
@Component | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/panewithbutton/PaneWithButtonController.java
import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import moe.tristan.easyfxml.api.FxmlController;
/*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.panewithbutton;
@Scope(SCOPE_PROTOTYPE)
@Component | public class PaneWithButtonController implements FxmlController { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/model/fxml/FxmlLoadResultTest.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml-junit/src/main/java/moe/tristan/easyfxml/junit/SpringBootComponentTest.java
// @SpringBootTest
// @ExtendWith(ApplicationExtension.class)
// public abstract class SpringBootComponentTest extends ApplicationTest {
//
// protected final FxNodeAsyncQuery withNodes(Node... nodes) {
// return FxNodeAsyncQuery.withNodes(nodes);
// }
//
// protected Supplier<Boolean> showing(Node node) {
// return () -> {
// final PointQuery pointQuery = point(node);
// return pointQuery.query() != null;
// };
// }
//
// public static final class FxNodeAsyncQuery {
//
// private final List<Node> nodes;
//
// private List<Supplier<Boolean>> nodesReady = emptyList();
//
// private List<Runnable> actions = emptyList();
//
// private List<Supplier<Boolean>> witnesses = emptyList();
//
// FxNodeAsyncQuery(Node[] nodes) {
// this.nodes = List.of(nodes);
// }
//
// public static FxNodeAsyncQuery withNodes(Node... nodes) {
// return new FxNodeAsyncQuery(nodes);
// }
//
// @SafeVarargs
// public final FxNodeAsyncQuery startWhen(Supplier<Boolean>... readyCheck) {
// this.nodesReady = List.of(readyCheck);
// return this;
// }
//
// public final FxNodeAsyncQuery willDo(Runnable... actionsWhenReady) {
// this.actions = List.of(actionsWhenReady);
// return this;
// }
//
// @SafeVarargs
// public final void andAwaitFor(Supplier<Boolean>... awaited) {
// this.witnesses = List.of(awaited);
// run();
// }
//
// public void run() {
// runTestQuery(nodes, nodesReady, actions, witnesses);
// }
//
// private void runTestQuery(List<Node> nodes, List<Supplier<Boolean>> nodesReady, List<Runnable> actions, List<Supplier<Boolean>> witnesses) {
// CompletableFuture
// .runAsync(() -> buildStageWithNodes(nodes), Platform::runLater)
// .thenRunAsync(() -> await().until(() -> allEvaluateToTrue(nodesReady)))
// .thenRunAsync(() -> actions.forEach(Runnable::run)).join();
//
// for (Supplier<Boolean> witness : witnesses) {
// await().until(witness::get);
// }
// }
//
// private static void buildStageWithNodes(List<Node> nodes) {
// Stage testStage = new Stage();
// testStage.setScene(new Scene(new VBox(nodes.toArray(new Node[0]))));
// testStage.show();
// testStage.toFront();
// }
//
// private static Boolean allEvaluateToTrue(List<Supplier<Boolean>> nodesReady) {
// return nodesReady.stream().map(Supplier::get).reduce((prev, cur) -> prev && cur).orElse(true);
// }
//
// }
//
// }
| import io.vavr.control.Try;
import static org.testfx.assertions.api.Assertions.assertThat;
import java.util.concurrent.atomic.AtomicBoolean;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javafx.scene.Node;
import javafx.scene.layout.Pane;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.junit.SpringBootComponentTest; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.fxml;
public class FxmlLoadResultTest extends SpringBootComponentTest {
private static final Node TEST_NODE = new Pane(); | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml-junit/src/main/java/moe/tristan/easyfxml/junit/SpringBootComponentTest.java
// @SpringBootTest
// @ExtendWith(ApplicationExtension.class)
// public abstract class SpringBootComponentTest extends ApplicationTest {
//
// protected final FxNodeAsyncQuery withNodes(Node... nodes) {
// return FxNodeAsyncQuery.withNodes(nodes);
// }
//
// protected Supplier<Boolean> showing(Node node) {
// return () -> {
// final PointQuery pointQuery = point(node);
// return pointQuery.query() != null;
// };
// }
//
// public static final class FxNodeAsyncQuery {
//
// private final List<Node> nodes;
//
// private List<Supplier<Boolean>> nodesReady = emptyList();
//
// private List<Runnable> actions = emptyList();
//
// private List<Supplier<Boolean>> witnesses = emptyList();
//
// FxNodeAsyncQuery(Node[] nodes) {
// this.nodes = List.of(nodes);
// }
//
// public static FxNodeAsyncQuery withNodes(Node... nodes) {
// return new FxNodeAsyncQuery(nodes);
// }
//
// @SafeVarargs
// public final FxNodeAsyncQuery startWhen(Supplier<Boolean>... readyCheck) {
// this.nodesReady = List.of(readyCheck);
// return this;
// }
//
// public final FxNodeAsyncQuery willDo(Runnable... actionsWhenReady) {
// this.actions = List.of(actionsWhenReady);
// return this;
// }
//
// @SafeVarargs
// public final void andAwaitFor(Supplier<Boolean>... awaited) {
// this.witnesses = List.of(awaited);
// run();
// }
//
// public void run() {
// runTestQuery(nodes, nodesReady, actions, witnesses);
// }
//
// private void runTestQuery(List<Node> nodes, List<Supplier<Boolean>> nodesReady, List<Runnable> actions, List<Supplier<Boolean>> witnesses) {
// CompletableFuture
// .runAsync(() -> buildStageWithNodes(nodes), Platform::runLater)
// .thenRunAsync(() -> await().until(() -> allEvaluateToTrue(nodesReady)))
// .thenRunAsync(() -> actions.forEach(Runnable::run)).join();
//
// for (Supplier<Boolean> witness : witnesses) {
// await().until(witness::get);
// }
// }
//
// private static void buildStageWithNodes(List<Node> nodes) {
// Stage testStage = new Stage();
// testStage.setScene(new Scene(new VBox(nodes.toArray(new Node[0]))));
// testStage.show();
// testStage.toFront();
// }
//
// private static Boolean allEvaluateToTrue(List<Supplier<Boolean>> nodesReady) {
// return nodesReady.stream().map(Supplier::get).reduce((prev, cur) -> prev && cur).orElse(true);
// }
//
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/model/fxml/FxmlLoadResultTest.java
import io.vavr.control.Try;
import static org.testfx.assertions.api.Assertions.assertThat;
import java.util.concurrent.atomic.AtomicBoolean;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javafx.scene.Node;
import javafx.scene.layout.Pane;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.junit.SpringBootComponentTest;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.fxml;
public class FxmlLoadResultTest extends SpringBootComponentTest {
private static final Node TEST_NODE = new Pane(); | private static final FxmlController TEST_CONTROLLER = () -> { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/email/EmailComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.email;
@Component
public class EmailComponent implements FxmlComponent {
public static final String EMAIL_FIELD_NAME = "Email address";
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/email/EmailComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.email;
@Component
public class EmailComponent implements FxmlComponent {
public static final String EMAIL_FIELD_NAME = "Email address";
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/email/EmailComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.email;
@Component
public class EmailComponent implements FxmlComponent {
public static final String EMAIL_FIELD_NAME = "Email address";
@Override
public FxmlFile getFile() {
return () -> "Email.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/email/EmailComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.email;
@Component
public class EmailComponent implements FxmlComponent {
public static final String EMAIL_FIELD_NAME = "Email address";
@Override
public FxmlFile getFile() {
return () -> "Email.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/cell/ComponentListCellComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.cell;
@Component
public class ComponentListCellComponent implements FxmlComponent {
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/cell/ComponentListCellComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.cell;
@Component
public class ComponentListCellComponent implements FxmlComponent {
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/cell/ComponentListCellComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.cell;
@Component
public class ComponentListCellComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "ComponentCell.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/cell/ComponentListCellComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.cell;
@Component
public class ComponentListCellComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "ComponentCell.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/HelloWorldUiManager.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/FxUiManager.java
// public abstract class FxUiManager {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FxUiManager.class);
//
// private EasyFxml easyFxml;
//
// /**
// * Called by {@link FxApplication} after Spring and JavaFX are started. This is the equivalent of {@link javafx.application.Application#start(Stage)} in
// * traditional JavaFX apps.
// *
// * @param mainStage A reference to the main stage of the application, received from JavaFX via {@link javafx.application.Application#start(Stage)}.
// */
// public void startGui(final Stage mainStage) {
// try {
// onStageCreated(mainStage);
// final Scene mainScene = getScene(mainComponent());
// onSceneCreated(mainScene);
// mainStage.setScene(mainScene);
// mainStage.setTitle(title());
//
// Option.ofOptional(getStylesheet())
// .filter(style -> !FxmlStylesheets.DEFAULT_JAVAFX_STYLE.equals(style))
// .peek(stylesheet -> this.setTheme(stylesheet, mainStage));
//
// mainStage.show();
// } catch (Throwable t) {
// throw new RuntimeException("There was a failure during start-up of the application.", t);
// }
// }
//
// /**
// * @return The title to give the main stage
// */
// protected abstract String title();
//
// /**
// * @return The component to load in the main stage upon startup
// */
// protected abstract FxmlComponent mainComponent();
//
// /**
// * Called right after the main {@link Scene} was created if you want to edit it.
// *
// * @param mainScene The main scene of the application
// */
// @SuppressWarnings("unused")
// protected void onSceneCreated(final Scene mainScene) {
// //do nothing by default
// }
//
// /**
// * Called as we enter the {@link #startGui(Stage)} method.
// *
// * @param mainStage The main stage, supplied by JavaFX's {@link javafx.application.Application#start(Stage)} method.
// */
// @SuppressWarnings("unused")
// protected void onStageCreated(final Stage mainStage) {
// //do nothing by default
// }
//
// /**
// * @return If overriden, this function returns the {@link FxmlStylesheet} to apply to the main window.
// */
// protected Optional<FxmlStylesheet> getStylesheet() {
// return Optional.empty();
// }
//
// /**
// * Simple utility class to load an {@link FxmlComponent} as a {@link Scene} for use with {@link #mainComponent()}
// *
// * @param component the component to load in the {@link Scene}
// *
// * @return The ready-to-use {@link Scene}
// *
// * @throws RuntimeException if the scene could not be loaded properly
// */
// protected Scene getScene(final FxmlComponent component) {
// return easyFxml
// .load(component)
// .getNode()
// .map(Scene::new)
// .getOrElseThrow((Function<? super Throwable, RuntimeException>) RuntimeException::new);
// }
//
// private void setTheme(final FxmlStylesheet stylesheet, Stage mainStage) {
// Try.of(() -> stylesheet)
// .mapTry(FxmlStylesheet::getExternalForm)
// .mapTry(stylesheetUri -> Stages.setStylesheet(mainStage, stylesheetUri))
// .orElseRun(err -> ExceptionHandler.displayExceptionPane(
// "Could not load theme!",
// "Could not load theme file with description : " + stylesheet,
// err
// ));
// }
//
// @Autowired
// public void setEasyFxml(EasyFxml easyFxml) {
// this.easyFxml = easyFxml;
// }
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/hello/HelloComponent.java
// @Component
// public class HelloComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "HelloView.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return HelloController.class;
// }
//
// }
| import javafx.stage.Stage;
import moe.tristan.easyfxml.FxUiManager;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.samples.helloworld.view.hello.HelloComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.helloworld.view;
public class HelloWorldUiManager extends FxUiManager {
private final HelloComponent helloComponent;
protected HelloWorldUiManager(HelloComponent helloComponent) {
this.helloComponent = helloComponent;
}
/**
* @return the main {@link Stage}'s title you want
*/
@Override
protected String title() {
return "Hello, World!";
}
/**
* @return the component to load as the root view in your main {@link Stage}.
*/
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/FxUiManager.java
// public abstract class FxUiManager {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FxUiManager.class);
//
// private EasyFxml easyFxml;
//
// /**
// * Called by {@link FxApplication} after Spring and JavaFX are started. This is the equivalent of {@link javafx.application.Application#start(Stage)} in
// * traditional JavaFX apps.
// *
// * @param mainStage A reference to the main stage of the application, received from JavaFX via {@link javafx.application.Application#start(Stage)}.
// */
// public void startGui(final Stage mainStage) {
// try {
// onStageCreated(mainStage);
// final Scene mainScene = getScene(mainComponent());
// onSceneCreated(mainScene);
// mainStage.setScene(mainScene);
// mainStage.setTitle(title());
//
// Option.ofOptional(getStylesheet())
// .filter(style -> !FxmlStylesheets.DEFAULT_JAVAFX_STYLE.equals(style))
// .peek(stylesheet -> this.setTheme(stylesheet, mainStage));
//
// mainStage.show();
// } catch (Throwable t) {
// throw new RuntimeException("There was a failure during start-up of the application.", t);
// }
// }
//
// /**
// * @return The title to give the main stage
// */
// protected abstract String title();
//
// /**
// * @return The component to load in the main stage upon startup
// */
// protected abstract FxmlComponent mainComponent();
//
// /**
// * Called right after the main {@link Scene} was created if you want to edit it.
// *
// * @param mainScene The main scene of the application
// */
// @SuppressWarnings("unused")
// protected void onSceneCreated(final Scene mainScene) {
// //do nothing by default
// }
//
// /**
// * Called as we enter the {@link #startGui(Stage)} method.
// *
// * @param mainStage The main stage, supplied by JavaFX's {@link javafx.application.Application#start(Stage)} method.
// */
// @SuppressWarnings("unused")
// protected void onStageCreated(final Stage mainStage) {
// //do nothing by default
// }
//
// /**
// * @return If overriden, this function returns the {@link FxmlStylesheet} to apply to the main window.
// */
// protected Optional<FxmlStylesheet> getStylesheet() {
// return Optional.empty();
// }
//
// /**
// * Simple utility class to load an {@link FxmlComponent} as a {@link Scene} for use with {@link #mainComponent()}
// *
// * @param component the component to load in the {@link Scene}
// *
// * @return The ready-to-use {@link Scene}
// *
// * @throws RuntimeException if the scene could not be loaded properly
// */
// protected Scene getScene(final FxmlComponent component) {
// return easyFxml
// .load(component)
// .getNode()
// .map(Scene::new)
// .getOrElseThrow((Function<? super Throwable, RuntimeException>) RuntimeException::new);
// }
//
// private void setTheme(final FxmlStylesheet stylesheet, Stage mainStage) {
// Try.of(() -> stylesheet)
// .mapTry(FxmlStylesheet::getExternalForm)
// .mapTry(stylesheetUri -> Stages.setStylesheet(mainStage, stylesheetUri))
// .orElseRun(err -> ExceptionHandler.displayExceptionPane(
// "Could not load theme!",
// "Could not load theme file with description : " + stylesheet,
// err
// ));
// }
//
// @Autowired
// public void setEasyFxml(EasyFxml easyFxml) {
// this.easyFxml = easyFxml;
// }
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/hello/HelloComponent.java
// @Component
// public class HelloComponent implements FxmlComponent {
//
// @Override
// public FxmlFile getFile() {
// return () -> "HelloView.fxml";
// }
//
// @Override
// public Class<? extends FxmlController> getControllerClass() {
// return HelloController.class;
// }
//
// }
// Path: easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/HelloWorldUiManager.java
import javafx.stage.Stage;
import moe.tristan.easyfxml.FxUiManager;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.samples.helloworld.view.hello.HelloComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.helloworld.view;
public class HelloWorldUiManager extends FxUiManager {
private final HelloComponent helloComponent;
protected HelloWorldUiManager(HelloComponent helloComponent) {
this.helloComponent = helloComponent;
}
/**
* @return the main {@link Stage}'s title you want
*/
@Override
protected String title() {
return "Hello, World!";
}
/**
* @return the component to load as the root view in your main {@link Stage}.
*/
@Override | protected FxmlComponent mainComponent() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/cell/ComponentCellFxmlSampleController.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/components/listview/ComponentCellFxmlController.java
// public interface ComponentCellFxmlController<T> extends FxmlController {
//
// void updateWithValue(final T newValue);
//
// /**
// * @param selected a property watching whether this list view cell is currently selected. You can listen on it and react accordingly.
// */
// default void selectedProperty(final BooleanExpression selected) {
// }
//
// }
| import java.util.concurrent.atomic.AtomicReference;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javafx.application.Platform;
import javafx.beans.binding.BooleanExpression;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import moe.tristan.easyfxml.model.components.listview.ComponentCellFxmlController; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.cell;
@Component
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/components/listview/ComponentCellFxmlController.java
// public interface ComponentCellFxmlController<T> extends FxmlController {
//
// void updateWithValue(final T newValue);
//
// /**
// * @param selected a property watching whether this list view cell is currently selected. You can listen on it and react accordingly.
// */
// default void selectedProperty(final BooleanExpression selected) {
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/cell/ComponentCellFxmlSampleController.java
import java.util.concurrent.atomic.AtomicReference;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javafx.application.Platform;
import javafx.beans.binding.BooleanExpression;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import moe.tristan.easyfxml.model.components.listview.ComponentCellFxmlController;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.cell;
@Component
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) | public class ComponentCellFxmlSampleController implements ComponentCellFxmlController<String> { |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxmlAutoConfiguration.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
| import moe.tristan.easyfxml.api.FxmlController;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import javafx.application.Application;
import javafx.application.HostServices; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@ComponentScan("moe.tristan.easyfxml")
@EnableAutoConfiguration
@EnableConfigurationProperties(EasyFxmlProperties.class)
public class EasyFxmlAutoConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(EasyFxmlAutoConfiguration.class);
private final ApplicationContext context;
@Autowired
public EasyFxmlAutoConfiguration(ApplicationContext context) {
this.context = context;
}
@PostConstruct
public void logFoundControllers() { | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxmlAutoConfiguration.java
import moe.tristan.easyfxml.api.FxmlController;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import javafx.application.Application;
import javafx.application.HostServices;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@ComponentScan("moe.tristan.easyfxml")
@EnableAutoConfiguration
@EnableConfigurationProperties(EasyFxmlProperties.class)
public class EasyFxmlAutoConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(EasyFxmlAutoConfiguration.class);
private final ApplicationContext context;
@Autowired
public EasyFxmlAutoConfiguration(ApplicationContext context) {
this.context = context;
}
@PostConstruct
public void logFoundControllers() { | final String fxmlControllersFound = String.join("\n->\t", context.getBeanNamesForType(FxmlController.class)); |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxmlProperties.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/FxmlFileResolutionStrategy.java
// public enum FxmlFileResolutionStrategy {
// RELATIVE,
// ABSOLUTE
// }
| import moe.tristan.easyfxml.model.fxml.FxmlFileResolutionStrategy;
import static moe.tristan.easyfxml.model.fxml.FxmlFileResolutionStrategy.RELATIVE;
import java.util.Objects;
import org.springframework.boot.context.properties.ConfigurationProperties; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@ConfigurationProperties(prefix = "moe.tristan.easyfxml")
public class EasyFxmlProperties {
/**
* Base classpath location in which to look for fxml files
*/ | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/FxmlFileResolutionStrategy.java
// public enum FxmlFileResolutionStrategy {
// RELATIVE,
// ABSOLUTE
// }
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxmlProperties.java
import moe.tristan.easyfxml.model.fxml.FxmlFileResolutionStrategy;
import static moe.tristan.easyfxml.model.fxml.FxmlFileResolutionStrategy.RELATIVE;
import java.util.Objects;
import org.springframework.boot.context.properties.ConfigurationProperties;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml;
@ConfigurationProperties(prefix = "moe.tristan.easyfxml")
public class EasyFxmlProperties {
/**
* Base classpath location in which to look for fxml files
*/ | private FxmlFileResolutionStrategy fxmlFileResolutionStrategy = RELATIVE; |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
| import java.util.concurrent.CompletionStage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import io.vavr.Tuple; | */
public static CompletionStage<Stage> setStylesheet(final Stage stage, final String stylesheet) {
LOG.info(
"Setting stylesheet {} for stage {}({})",
stylesheet,
stage.toString(),
stage.getTitle()
);
return FxAsync.doOnFxThread(
stage,
theStage -> {
final Scene stageScene = theStage.getScene();
stageScene.getStylesheets().clear();
stageScene.getStylesheets().add(stylesheet);
}
);
}
public static CompletionStage<Stage> setStylesheet(final CompletionStage<Stage> stageCreationResult, final String stylesheet) {
return stageCreationResult.whenCompleteAsync((res, err) -> setStylesheet(res, stylesheet));
}
/**
* See {@link #setStylesheet(Stage, String)}
*
* @param stage The stage to apply the style to
* @param stylesheet The {@link FxmlStylesheet} pointing to the stylesheet to apply
*
* @return A {@link CompletionStage} to have monitoring over the state of the asynchronous operation
*/ | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlStylesheet.java
// public interface FxmlStylesheet {
//
// /**
// * @return the CSS file that composes the stylesheet as a {@link Path}. See {@link
// * Resources#getResourcePath(String)}
// */
// Path getPath();
//
// /**
// * This method is a sample implementation that should work in almost all general cases.
// * <p>
// * An {@link java.io.IOException} can be thrown in very rare cases.
// * <p>
// * If you encounter them, post an issue with system details.
// *
// * @return the CSS file in external form (i.e. with the file:/, http:/...) protocol info before it.
// *
// * @see Resources#getResourceURL(String)
// * @see URL#toExternalForm()
// */
// default String getExternalForm() {
// return Try.of(this::getPath)
// .map(Path::toUri)
// .mapTry(URI::toURL)
// .map(URL::toExternalForm)
// .get();
// }
//
// }
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java
import java.util.concurrent.CompletionStage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import moe.tristan.easyfxml.api.FxmlStylesheet;
import io.vavr.Tuple;
*/
public static CompletionStage<Stage> setStylesheet(final Stage stage, final String stylesheet) {
LOG.info(
"Setting stylesheet {} for stage {}({})",
stylesheet,
stage.toString(),
stage.getTitle()
);
return FxAsync.doOnFxThread(
stage,
theStage -> {
final Scene stageScene = theStage.getScene();
stageScene.getStylesheets().clear();
stageScene.getStylesheets().add(stylesheet);
}
);
}
public static CompletionStage<Stage> setStylesheet(final CompletionStage<Stage> stageCreationResult, final String stylesheet) {
return stageCreationResult.whenCompleteAsync((res, err) -> setStylesheet(res, stylesheet));
}
/**
* See {@link #setStylesheet(Stage, String)}
*
* @param stage The stage to apply the style to
* @param stylesheet The {@link FxmlStylesheet} pointing to the stylesheet to apply
*
* @return A {@link CompletionStage} to have monitoring over the state of the asynchronous operation
*/ | public static CompletionStage<Stage> setStylesheet(final Stage stage, final FxmlStylesheet stylesheet) { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/samples/invalid/InvalidComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass; | /*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.invalid;
@Component
public class InvalidComponent implements FxmlComponent {
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/invalid/InvalidComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass;
/*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.invalid;
@Component
public class InvalidComponent implements FxmlComponent {
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/samples/invalid/InvalidComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass; | /*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.invalid;
@Component
public class InvalidComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "Invalid.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/invalid/InvalidComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass;
/*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.invalid;
@Component
public class InvalidComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "Invalid.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/samples/invalid/InvalidComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass; | /*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.invalid;
@Component
public class InvalidComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "Invalid.fxml";
}
@Override
public Class<? extends FxmlController> getControllerClass() { | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/NoControllerClass.java
// @Component
// public class NoControllerClass implements FxmlController {
//
// /**
// * Empty voluntarily as no logic is to be included in this class.
// */
// @SuppressWarnings("EmptyMethod")
// @Override
// public void initialize() {
// //see doc
// }
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/samples/invalid/InvalidComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.model.fxml.NoControllerClass;
/*
* Copyright 2017 - 2020 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.invalid;
@Component
public class InvalidComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "Invalid.fxml";
}
@Override
public Class<? extends FxmlController> getControllerClass() { | return NoControllerClass.class; |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/hello/HelloComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.helloworld.view.hello;
@Component
public class HelloComponent implements FxmlComponent {
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/hello/HelloComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.helloworld.view.hello;
@Component
public class HelloComponent implements FxmlComponent {
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/hello/HelloComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.helloworld.view.hello;
@Component
public class HelloComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "HelloView.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-hello-world/src/main/java/moe/tristan/easyfxml/samples/helloworld/view/hello/HelloComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.helloworld.view.hello;
@Component
public class HelloComponent implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "HelloView.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/test/java/moe/tristan/easyfxml/samples/form/user/UserFormContextTest.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxml.java
// public interface EasyFxml {
//
// /**
// * Loads a {@link FxmlComponent} as a Pane (this is the safest base class for all sorts of hierarchies) since most of the base containers are subclasses of
// * it.
// * <p>
// * It also registers its controller in the {@link ControllerManager} for later usage.
// * <p>
// * It returns a {@link Try} which is a monadic structure which allows us to do clean exception-handling.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// *
// * @return A {@link Try} containing either the JavaFX {@link Pane} inside a {@link Try.Success} or the exception that was raised during the chain of calls
// * needed to load it, inside a {@link Try.Failure}. See {@link Try#getOrElse(Object)}, {@link Try#onFailure(Consumer)}, {@link Try#recover(Function)} and
// * related methods for how to handle {@link Try.Failure}.
// */
// FxmlLoadResult<Pane, FxmlController> load(final FxmlComponent component);
//
// /**
// * Same as {@link #load(FxmlComponent)} but offers a selector parameter for multistage usage of {@link ControllerManager}.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param selector The selector for deduplication of Panes sharing the same {@link FxmlComponent}.
// *
// * @return A Try of the {@link Pane} to be loaded. See {@link #load(FxmlComponent)} for more information on {@link Try}.
// */
// FxmlLoadResult<Pane, FxmlController> load(final FxmlComponent component, final Selector selector);
//
// /**
// * Same as {@link #load(FxmlComponent)} except you can choose the return type wished for instead of just {@link Pane}.
// * <p>
// * It's a bad idea but it can sometimes be actually useful on the rare case where the element is really nothing like a Pane. Be it a very complex button or
// * a custom textfield with non-rectangular shape.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param nodeClass The class of the JavaFX {@link Node} represented by this {@link FxmlComponent}.
// * @param controllerClass The class of the {@link FxmlController} managing this {@link FxmlComponent}.
// * @param <NODE> The type of the node. Mostly for type safety.
// * @param <CONTROLLER> The type of the controller. Mostly for type safety.
// *
// * @return A {@link FxmlLoadResult} containing two {@link Try} instances. One for the node itself and one for its controller. This allows for granular load
// * error management.
// */
// <NODE extends Node, CONTROLLER extends FxmlController>
// FxmlLoadResult<NODE, CONTROLLER>
// load(
// final FxmlComponent component,
// final Class<? extends NODE> nodeClass,
// final Class<? extends CONTROLLER> controllerClass
// );
//
// /**
// * This is to {@link #load(FxmlComponent, Class, Class)} just what {@link #load(FxmlComponent, Selector)} is to {@link #load(FxmlComponent)}.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param nodeClass The class of the JavaFX {@link Node} represented by this {@link FxmlComponent}.
// * @param controllerClass The class of the {@link FxmlController} managing this {@link FxmlComponent}.
// * @param selector The selector for deduplication of Panes sharing the same {@link FxmlComponent}.
// * @param <NODE> The type of the node. Mostly for type safety.
// * @param <CONTROLLER> The type of the controller. Mostly for type safety.
// *
// * @return A {@link FxmlLoadResult} containing two {@link Try} instances.
// *
// * One for the node itself and one for its controller. This allows for granular load error management.
// */
// <NODE extends Node, CONTROLLER extends FxmlController>
// FxmlLoadResult<NODE, CONTROLLER>
// load(
// final FxmlComponent component,
// final Class<? extends NODE> nodeClass,
// final Class<? extends CONTROLLER> controllerClass,
// final Selector selector
// );
//
// }
| import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import moe.tristan.easyfxml.EasyFxml; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user;
@SpringBootTest
public class UserFormContextTest {
@Autowired | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/EasyFxml.java
// public interface EasyFxml {
//
// /**
// * Loads a {@link FxmlComponent} as a Pane (this is the safest base class for all sorts of hierarchies) since most of the base containers are subclasses of
// * it.
// * <p>
// * It also registers its controller in the {@link ControllerManager} for later usage.
// * <p>
// * It returns a {@link Try} which is a monadic structure which allows us to do clean exception-handling.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// *
// * @return A {@link Try} containing either the JavaFX {@link Pane} inside a {@link Try.Success} or the exception that was raised during the chain of calls
// * needed to load it, inside a {@link Try.Failure}. See {@link Try#getOrElse(Object)}, {@link Try#onFailure(Consumer)}, {@link Try#recover(Function)} and
// * related methods for how to handle {@link Try.Failure}.
// */
// FxmlLoadResult<Pane, FxmlController> load(final FxmlComponent component);
//
// /**
// * Same as {@link #load(FxmlComponent)} but offers a selector parameter for multistage usage of {@link ControllerManager}.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param selector The selector for deduplication of Panes sharing the same {@link FxmlComponent}.
// *
// * @return A Try of the {@link Pane} to be loaded. See {@link #load(FxmlComponent)} for more information on {@link Try}.
// */
// FxmlLoadResult<Pane, FxmlController> load(final FxmlComponent component, final Selector selector);
//
// /**
// * Same as {@link #load(FxmlComponent)} except you can choose the return type wished for instead of just {@link Pane}.
// * <p>
// * It's a bad idea but it can sometimes be actually useful on the rare case where the element is really nothing like a Pane. Be it a very complex button or
// * a custom textfield with non-rectangular shape.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param nodeClass The class of the JavaFX {@link Node} represented by this {@link FxmlComponent}.
// * @param controllerClass The class of the {@link FxmlController} managing this {@link FxmlComponent}.
// * @param <NODE> The type of the node. Mostly for type safety.
// * @param <CONTROLLER> The type of the controller. Mostly for type safety.
// *
// * @return A {@link FxmlLoadResult} containing two {@link Try} instances. One for the node itself and one for its controller. This allows for granular load
// * error management.
// */
// <NODE extends Node, CONTROLLER extends FxmlController>
// FxmlLoadResult<NODE, CONTROLLER>
// load(
// final FxmlComponent component,
// final Class<? extends NODE> nodeClass,
// final Class<? extends CONTROLLER> controllerClass
// );
//
// /**
// * This is to {@link #load(FxmlComponent, Class, Class)} just what {@link #load(FxmlComponent, Selector)} is to {@link #load(FxmlComponent)}.
// *
// * @param component The element's {@link FxmlComponent} counterpart.
// * @param nodeClass The class of the JavaFX {@link Node} represented by this {@link FxmlComponent}.
// * @param controllerClass The class of the {@link FxmlController} managing this {@link FxmlComponent}.
// * @param selector The selector for deduplication of Panes sharing the same {@link FxmlComponent}.
// * @param <NODE> The type of the node. Mostly for type safety.
// * @param <CONTROLLER> The type of the controller. Mostly for type safety.
// *
// * @return A {@link FxmlLoadResult} containing two {@link Try} instances.
// *
// * One for the node itself and one for its controller. This allows for granular load error management.
// */
// <NODE extends Node, CONTROLLER extends FxmlController>
// FxmlLoadResult<NODE, CONTROLLER>
// load(
// final FxmlComponent component,
// final Class<? extends NODE> nodeClass,
// final Class<? extends CONTROLLER> controllerClass,
// final Selector selector
// );
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/test/java/moe/tristan/easyfxml/samples/form/user/UserFormContextTest.java
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import moe.tristan.easyfxml.EasyFxml;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user;
@SpringBootTest
public class UserFormContextTest {
@Autowired | private EasyFxml easyFxml; |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/model/system/BrowserSupport.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/exception/ExceptionHandler.java
// public final class ExceptionHandler {
//
// private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class);
// private static final double ERROR_FIELD_MARGIN_SIZE = 20.0;
//
// private final Throwable exception;
//
// /**
// * Creates an instance with the given exception.
// *
// * @param exception The exception to base this instance on
// */
// public ExceptionHandler(final Throwable exception) {
// LOG.debug("Generating ExceptionPane for exception of type {}", exception.getClass());
// this.exception = exception;
// }
//
// /**
// * @return The exception in a pane with {@link Throwable#getMessage()} as a label over the stacktrace.
// */
// public Pane asPane() {
// return this.asPane(this.exception.getMessage());
// }
//
// /**
// * Same as {@link #asPane()} but with a custom error label on top of the stack trace.
// *
// * @param userReadableError The custom error message.
// *
// * @return The exception in a pane with the custom error message as a label over the stacktrace.
// */
// public Pane asPane(final String userReadableError) {
// LOG.debug("Generating node corresponding to ExceptionPane...");
// final Label messageLabel = new Label(userReadableError);
// final TextArea throwableDataLabel = new TextArea(formatErrorMessage(this.exception));
//
// AnchorPane.setLeftAnchor(messageLabel, ERROR_FIELD_MARGIN_SIZE);
// Nodes.centerNode(throwableDataLabel, ERROR_FIELD_MARGIN_SIZE);
// return new AnchorPane(messageLabel, throwableDataLabel);
// }
//
// public static Pane fromThrowable(final Throwable throwable) {
// return new ExceptionHandler(throwable).asPane();
// }
//
// /**
// * Creates a pop-up and displays it based on a given exception, pop-up title and custom error message.
// *
// * @param title The title of the error pop-up
// * @param readable The custom label to display on top of the stack trace
// * @param exception The exception to use
// *
// * @return a {@link CompletionStage} to know when the pop-up displayed and have a handle on it.
// */
// public static CompletionStage<Stage> displayExceptionPane(
// final String title,
// final String readable,
// final Throwable exception
// ) {
// final Pane exceptionPane = new ExceptionHandler(exception).asPane(readable);
// final CompletionStage<Stage> exceptionStage = Stages.stageOf(title, exceptionPane);
// return exceptionStage.thenCompose(Stages::scheduleDisplaying);
// }
//
// private static String formatErrorMessage(final Throwable throwable) {
// return "Message : \n" +
// throwable.getMessage() +
// "\nStackTrace:\n" +
// Arrays.stream(throwable.getStackTrace())
// .map(StackTraceElement::toString)
// .collect(Collectors.joining("\n"));
// }
//
// }
| import java.net.URI;
import java.net.URL;
import java.util.function.Consumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javafx.application.HostServices;
import moe.tristan.easyfxml.model.exception.ExceptionHandler;
import io.vavr.control.Try; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.system;
/**
* This class contains some utility methods to open URLs with the default web browser of the user.
*/
@Component
public class BrowserSupport {
private final HostServices hostServices;
@Autowired
public BrowserSupport(HostServices hostServices) {
this.hostServices = hostServices;
}
/**
* Opens a given URL or a pop-up with the error if it could not do so.
*
* @param url The URL as a String. Does not have to conform to {@link URL#URL(String)}.
*
* @return a {@link Try} that can be either {@link Try.Success} (and empty) or {@link Try.Failure} and contain an
* exception.
*
* @see Try#onFailure(Consumer)
*/
public Try<Void> openUrl(final String url) {
return Try.run(() -> hostServices.showDocument(url))
.onFailure(cause -> onException(cause, url));
}
/**
* Opens a given URL or a pop-up with the error if it could not do so.
*
* @param url The URL as an {@link URL}.
*
* @return a {@link Try} that can be either {@link Try.Success} (and empty) or {@link Try.Failure} and contain an
* exception.
*
* @see Try#onFailure(Consumer)
*/
public Try<Void> openUrl(final URL url) {
return Try.of(() -> url)
.mapTry(URL::toURI)
.map(URI::toString)
.flatMap(this::openUrl);
}
private void onException(final Throwable cause, final String url) { | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/exception/ExceptionHandler.java
// public final class ExceptionHandler {
//
// private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class);
// private static final double ERROR_FIELD_MARGIN_SIZE = 20.0;
//
// private final Throwable exception;
//
// /**
// * Creates an instance with the given exception.
// *
// * @param exception The exception to base this instance on
// */
// public ExceptionHandler(final Throwable exception) {
// LOG.debug("Generating ExceptionPane for exception of type {}", exception.getClass());
// this.exception = exception;
// }
//
// /**
// * @return The exception in a pane with {@link Throwable#getMessage()} as a label over the stacktrace.
// */
// public Pane asPane() {
// return this.asPane(this.exception.getMessage());
// }
//
// /**
// * Same as {@link #asPane()} but with a custom error label on top of the stack trace.
// *
// * @param userReadableError The custom error message.
// *
// * @return The exception in a pane with the custom error message as a label over the stacktrace.
// */
// public Pane asPane(final String userReadableError) {
// LOG.debug("Generating node corresponding to ExceptionPane...");
// final Label messageLabel = new Label(userReadableError);
// final TextArea throwableDataLabel = new TextArea(formatErrorMessage(this.exception));
//
// AnchorPane.setLeftAnchor(messageLabel, ERROR_FIELD_MARGIN_SIZE);
// Nodes.centerNode(throwableDataLabel, ERROR_FIELD_MARGIN_SIZE);
// return new AnchorPane(messageLabel, throwableDataLabel);
// }
//
// public static Pane fromThrowable(final Throwable throwable) {
// return new ExceptionHandler(throwable).asPane();
// }
//
// /**
// * Creates a pop-up and displays it based on a given exception, pop-up title and custom error message.
// *
// * @param title The title of the error pop-up
// * @param readable The custom label to display on top of the stack trace
// * @param exception The exception to use
// *
// * @return a {@link CompletionStage} to know when the pop-up displayed and have a handle on it.
// */
// public static CompletionStage<Stage> displayExceptionPane(
// final String title,
// final String readable,
// final Throwable exception
// ) {
// final Pane exceptionPane = new ExceptionHandler(exception).asPane(readable);
// final CompletionStage<Stage> exceptionStage = Stages.stageOf(title, exceptionPane);
// return exceptionStage.thenCompose(Stages::scheduleDisplaying);
// }
//
// private static String formatErrorMessage(final Throwable throwable) {
// return "Message : \n" +
// throwable.getMessage() +
// "\nStackTrace:\n" +
// Arrays.stream(throwable.getStackTrace())
// .map(StackTraceElement::toString)
// .collect(Collectors.joining("\n"));
// }
//
// }
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/system/BrowserSupport.java
import java.net.URI;
import java.net.URL;
import java.util.function.Consumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javafx.application.HostServices;
import moe.tristan.easyfxml.model.exception.ExceptionHandler;
import io.vavr.control.Try;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.system;
/**
* This class contains some utility methods to open URLs with the default web browser of the user.
*/
@Component
public class BrowserSupport {
private final HostServices hostServices;
@Autowired
public BrowserSupport(HostServices hostServices) {
this.hostServices = hostServices;
}
/**
* Opens a given URL or a pop-up with the error if it could not do so.
*
* @param url The URL as a String. Does not have to conform to {@link URL#URL(String)}.
*
* @return a {@link Try} that can be either {@link Try.Success} (and empty) or {@link Try.Failure} and contain an
* exception.
*
* @see Try#onFailure(Consumer)
*/
public Try<Void> openUrl(final String url) {
return Try.run(() -> hostServices.showDocument(url))
.onFailure(cause -> onException(cause, url));
}
/**
* Opens a given URL or a pop-up with the error if it could not do so.
*
* @param url The URL as an {@link URL}.
*
* @return a {@link Try} that can be either {@link Try.Success} (and empty) or {@link Try.Failure} and contain an
* exception.
*
* @see Try#onFailure(Consumer)
*/
public Try<Void> openUrl(final URL url) {
return Try.of(() -> url)
.mapTry(URL::toURI)
.map(URI::toString)
.flatMap(this::openUrl);
}
private void onException(final Throwable cause, final String url) { | ExceptionHandler.displayExceptionPane( |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/model/beanmanagement/ControllerManagerTest.java | // Path: easyfxml/src/test/java/moe/tristan/easyfxml/TestUtils.java
// public static boolean isSpringSingleton(final ApplicationContext context, final Class<?> beanClazz) {
// final Object bean1 = context.getBean(beanClazz);
// final Object bean2 = context.getBean(beanClazz);
//
// return bean1.equals(bean2);
// }
| import static moe.tristan.easyfxml.TestUtils.isSpringSingleton;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.beanmanagement;
@SpringBootTest
public class ControllerManagerTest {
@Autowired
private ApplicationContext context;
@Test
public void testLinkage() {
final ControllerManager manager = this.context.getBean(ControllerManager.class);
assertThat(manager).isNotNull();
}
@Test
public void testSingleton() { | // Path: easyfxml/src/test/java/moe/tristan/easyfxml/TestUtils.java
// public static boolean isSpringSingleton(final ApplicationContext context, final Class<?> beanClazz) {
// final Object bean1 = context.getBean(beanClazz);
// final Object bean2 = context.getBean(beanClazz);
//
// return bean1.equals(bean2);
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/model/beanmanagement/ControllerManagerTest.java
import static moe.tristan.easyfxml.TestUtils.isSpringSingleton;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.beanmanagement;
@SpringBootTest
public class ControllerManagerTest {
@Autowired
private ApplicationContext context;
@Test
public void testLinkage() {
final ControllerManager manager = this.context.getBean(ControllerManager.class);
assertThat(manager).isNotNull();
}
@Test
public void testSingleton() { | assertThat(isSpringSingleton(this.context, ControllerManager.class)).isTrue(); |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/birthday/BirthdayComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.birthday;
@Component
public class BirthdayComponent implements FxmlComponent {
public static final String BIRTHDATE_FIELD_NAME = "Birthdate";
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/birthday/BirthdayComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.birthday;
@Component
public class BirthdayComponent implements FxmlComponent {
public static final String BIRTHDATE_FIELD_NAME = "Birthdate";
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/birthday/BirthdayComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.birthday;
@Component
public class BirthdayComponent implements FxmlComponent {
public static final String BIRTHDATE_FIELD_NAME = "Birthdate";
@Override
public FxmlFile getFile() {
return () -> "Birthday.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/birthday/BirthdayComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.birthday;
@Component
public class BirthdayComponent implements FxmlComponent {
public static final String BIRTHDATE_FIELD_NAME = "Birthdate";
@Override
public FxmlFile getFile() {
return () -> "Birthday.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/lastname/LastnameComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.lastname;
@Component
public class LastnameComponent implements FxmlComponent {
public static final String LAST_NAME_FIELD_NAME = "Last name";
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/lastname/LastnameComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.lastname;
@Component
public class LastnameComponent implements FxmlComponent {
public static final String LAST_NAME_FIELD_NAME = "Last name";
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/lastname/LastnameComponent.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.lastname;
@Component
public class LastnameComponent implements FxmlComponent {
public static final String LAST_NAME_FIELD_NAME = "Last name";
@Override
public FxmlFile getFile() {
return () -> "Lastname.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
// Path: easyfxml-samples/easyfxml-sample-form-user/src/main/java/moe/tristan/easyfxml/samples/form/user/view/userform/fields/lastname/LastnameComponent.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlComponent;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.samples.form.user.view.userform.fields.lastname;
@Component
public class LastnameComponent implements FxmlComponent {
public static final String LAST_NAME_FIELD_NAME = "Last name";
@Override
public FxmlFile getFile() {
return () -> "Lastname.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/view/ComponentListView.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.view;
@Component
public class ComponentListView implements FxmlComponent {
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/view/ComponentListView.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.view;
@Component
public class ComponentListView implements FxmlComponent {
@Override | public FxmlFile getFile() { |
Tristan971/EasyFXML | easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/view/ComponentListView.java | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
| import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile; | /*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.view;
@Component
public class ComponentListView implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "ComponentListViewSample.fxml";
}
@Override | // Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java
// public interface FxmlComponent {
//
// FxmlFile getFile();
//
// Class<? extends FxmlController> getControllerClass();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
//
// /**
// * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
// * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
// * <p>
// * Calling it from the constructor is a hazard and will generally cause failures.
// */
// @SuppressWarnings("unused")
// void initialize();
//
// }
//
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlFile.java
// public interface FxmlFile {
//
// /**
// * @return the path relative to the classpath root (/target/classes in Maven's default model) as a {@link String}.
// */
// String getPath();
//
// }
// Path: easyfxml/src/test/java/moe/tristan/easyfxml/model/components/listview/view/ComponentListView.java
import org.springframework.stereotype.Component;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
/*
* Copyright 2017 - 2019 EasyFXML project and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package moe.tristan.easyfxml.model.components.listview.view;
@Component
public class ComponentListView implements FxmlComponent {
@Override
public FxmlFile getFile() {
return () -> "ComponentListViewSample.fxml";
}
@Override | public Class<? extends FxmlController> getControllerClass() { |
alibaba/ARouter | module-java/src/main/java/com/alibaba/android/arouter/demo/module1/BlankFragment.java | // Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestObj.java
// public class TestObj {
// public String name;
// public int id;
//
// public TestObj() {
// }
//
// public TestObj(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestParcelable.java
// public class TestParcelable implements Parcelable {
// public String name;
// public int id;
//
// public TestParcelable() {
// }
//
// public TestParcelable(String name, int id) {
// this.name = name;
// this.id = id;
// }
//
// protected TestParcelable(Parcel in) {
// name = in.readString();
// id = in.readInt();
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(name);
// dest.writeInt(id);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// public static final Creator<TestParcelable> CREATOR = new Creator<TestParcelable>() {
// @Override
// public TestParcelable createFromParcel(Parcel in) {
// return new TestParcelable(in);
// }
//
// @Override
// public TestParcelable[] newArray(int size) {
// return new TestParcelable[size];
// }
// };
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestSerializable.java
// public class TestSerializable implements Serializable {
// public String name;
// public int id;
//
// public TestSerializable() {
// }
//
// public TestSerializable(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.alibaba.android.arouter.demo.service.model.TestObj;
import com.alibaba.android.arouter.demo.service.model.TestParcelable;
import com.alibaba.android.arouter.demo.service.model.TestSerializable;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import java.util.List;
import java.util.Map; | package com.alibaba.android.arouter.demo.module1;
/**
* A simple {@link Fragment} subclass.
*/
@Route(path = "/test/fragment")
public class BlankFragment extends Fragment {
@Autowired
String name;
@Autowired(required = true) | // Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestObj.java
// public class TestObj {
// public String name;
// public int id;
//
// public TestObj() {
// }
//
// public TestObj(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestParcelable.java
// public class TestParcelable implements Parcelable {
// public String name;
// public int id;
//
// public TestParcelable() {
// }
//
// public TestParcelable(String name, int id) {
// this.name = name;
// this.id = id;
// }
//
// protected TestParcelable(Parcel in) {
// name = in.readString();
// id = in.readInt();
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(name);
// dest.writeInt(id);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// public static final Creator<TestParcelable> CREATOR = new Creator<TestParcelable>() {
// @Override
// public TestParcelable createFromParcel(Parcel in) {
// return new TestParcelable(in);
// }
//
// @Override
// public TestParcelable[] newArray(int size) {
// return new TestParcelable[size];
// }
// };
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestSerializable.java
// public class TestSerializable implements Serializable {
// public String name;
// public int id;
//
// public TestSerializable() {
// }
//
// public TestSerializable(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
// Path: module-java/src/main/java/com/alibaba/android/arouter/demo/module1/BlankFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.alibaba.android.arouter.demo.service.model.TestObj;
import com.alibaba.android.arouter.demo.service.model.TestParcelable;
import com.alibaba.android.arouter.demo.service.model.TestSerializable;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import java.util.List;
import java.util.Map;
package com.alibaba.android.arouter.demo.module1;
/**
* A simple {@link Fragment} subclass.
*/
@Route(path = "/test/fragment")
public class BlankFragment extends Fragment {
@Autowired
String name;
@Autowired(required = true) | TestObj obj; |
alibaba/ARouter | module-java/src/main/java/com/alibaba/android/arouter/demo/module1/BlankFragment.java | // Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestObj.java
// public class TestObj {
// public String name;
// public int id;
//
// public TestObj() {
// }
//
// public TestObj(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestParcelable.java
// public class TestParcelable implements Parcelable {
// public String name;
// public int id;
//
// public TestParcelable() {
// }
//
// public TestParcelable(String name, int id) {
// this.name = name;
// this.id = id;
// }
//
// protected TestParcelable(Parcel in) {
// name = in.readString();
// id = in.readInt();
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(name);
// dest.writeInt(id);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// public static final Creator<TestParcelable> CREATOR = new Creator<TestParcelable>() {
// @Override
// public TestParcelable createFromParcel(Parcel in) {
// return new TestParcelable(in);
// }
//
// @Override
// public TestParcelable[] newArray(int size) {
// return new TestParcelable[size];
// }
// };
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestSerializable.java
// public class TestSerializable implements Serializable {
// public String name;
// public int id;
//
// public TestSerializable() {
// }
//
// public TestSerializable(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.alibaba.android.arouter.demo.service.model.TestObj;
import com.alibaba.android.arouter.demo.service.model.TestParcelable;
import com.alibaba.android.arouter.demo.service.model.TestSerializable;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import java.util.List;
import java.util.Map; | package com.alibaba.android.arouter.demo.module1;
/**
* A simple {@link Fragment} subclass.
*/
@Route(path = "/test/fragment")
public class BlankFragment extends Fragment {
@Autowired
String name;
@Autowired(required = true)
TestObj obj;
@Autowired
int age = 10;
@Autowired
int height = 175;
@Autowired(name = "boy", required = true)
boolean girl;
@Autowired
char ch = 'A';
@Autowired
float fl = 12.00f;
@Autowired
double dou = 12.01d;
@Autowired | // Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestObj.java
// public class TestObj {
// public String name;
// public int id;
//
// public TestObj() {
// }
//
// public TestObj(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestParcelable.java
// public class TestParcelable implements Parcelable {
// public String name;
// public int id;
//
// public TestParcelable() {
// }
//
// public TestParcelable(String name, int id) {
// this.name = name;
// this.id = id;
// }
//
// protected TestParcelable(Parcel in) {
// name = in.readString();
// id = in.readInt();
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(name);
// dest.writeInt(id);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// public static final Creator<TestParcelable> CREATOR = new Creator<TestParcelable>() {
// @Override
// public TestParcelable createFromParcel(Parcel in) {
// return new TestParcelable(in);
// }
//
// @Override
// public TestParcelable[] newArray(int size) {
// return new TestParcelable[size];
// }
// };
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestSerializable.java
// public class TestSerializable implements Serializable {
// public String name;
// public int id;
//
// public TestSerializable() {
// }
//
// public TestSerializable(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
// Path: module-java/src/main/java/com/alibaba/android/arouter/demo/module1/BlankFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.alibaba.android.arouter.demo.service.model.TestObj;
import com.alibaba.android.arouter.demo.service.model.TestParcelable;
import com.alibaba.android.arouter.demo.service.model.TestSerializable;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import java.util.List;
import java.util.Map;
package com.alibaba.android.arouter.demo.module1;
/**
* A simple {@link Fragment} subclass.
*/
@Route(path = "/test/fragment")
public class BlankFragment extends Fragment {
@Autowired
String name;
@Autowired(required = true)
TestObj obj;
@Autowired
int age = 10;
@Autowired
int height = 175;
@Autowired(name = "boy", required = true)
boolean girl;
@Autowired
char ch = 'A';
@Autowired
float fl = 12.00f;
@Autowired
double dou = 12.01d;
@Autowired | TestSerializable ser; |
alibaba/ARouter | module-java/src/main/java/com/alibaba/android/arouter/demo/module1/BlankFragment.java | // Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestObj.java
// public class TestObj {
// public String name;
// public int id;
//
// public TestObj() {
// }
//
// public TestObj(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestParcelable.java
// public class TestParcelable implements Parcelable {
// public String name;
// public int id;
//
// public TestParcelable() {
// }
//
// public TestParcelable(String name, int id) {
// this.name = name;
// this.id = id;
// }
//
// protected TestParcelable(Parcel in) {
// name = in.readString();
// id = in.readInt();
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(name);
// dest.writeInt(id);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// public static final Creator<TestParcelable> CREATOR = new Creator<TestParcelable>() {
// @Override
// public TestParcelable createFromParcel(Parcel in) {
// return new TestParcelable(in);
// }
//
// @Override
// public TestParcelable[] newArray(int size) {
// return new TestParcelable[size];
// }
// };
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestSerializable.java
// public class TestSerializable implements Serializable {
// public String name;
// public int id;
//
// public TestSerializable() {
// }
//
// public TestSerializable(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.alibaba.android.arouter.demo.service.model.TestObj;
import com.alibaba.android.arouter.demo.service.model.TestParcelable;
import com.alibaba.android.arouter.demo.service.model.TestSerializable;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import java.util.List;
import java.util.Map; | package com.alibaba.android.arouter.demo.module1;
/**
* A simple {@link Fragment} subclass.
*/
@Route(path = "/test/fragment")
public class BlankFragment extends Fragment {
@Autowired
String name;
@Autowired(required = true)
TestObj obj;
@Autowired
int age = 10;
@Autowired
int height = 175;
@Autowired(name = "boy", required = true)
boolean girl;
@Autowired
char ch = 'A';
@Autowired
float fl = 12.00f;
@Autowired
double dou = 12.01d;
@Autowired
TestSerializable ser;
@Autowired | // Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestObj.java
// public class TestObj {
// public String name;
// public int id;
//
// public TestObj() {
// }
//
// public TestObj(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestParcelable.java
// public class TestParcelable implements Parcelable {
// public String name;
// public int id;
//
// public TestParcelable() {
// }
//
// public TestParcelable(String name, int id) {
// this.name = name;
// this.id = id;
// }
//
// protected TestParcelable(Parcel in) {
// name = in.readString();
// id = in.readInt();
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(name);
// dest.writeInt(id);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// public static final Creator<TestParcelable> CREATOR = new Creator<TestParcelable>() {
// @Override
// public TestParcelable createFromParcel(Parcel in) {
// return new TestParcelable(in);
// }
//
// @Override
// public TestParcelable[] newArray(int size) {
// return new TestParcelable[size];
// }
// };
// }
//
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/model/TestSerializable.java
// public class TestSerializable implements Serializable {
// public String name;
// public int id;
//
// public TestSerializable() {
// }
//
// public TestSerializable(String name, int id) {
// this.name = name;
// this.id = id;
// }
// }
// Path: module-java/src/main/java/com/alibaba/android/arouter/demo/module1/BlankFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.alibaba.android.arouter.demo.service.model.TestObj;
import com.alibaba.android.arouter.demo.service.model.TestParcelable;
import com.alibaba.android.arouter.demo.service.model.TestSerializable;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import java.util.List;
import java.util.Map;
package com.alibaba.android.arouter.demo.module1;
/**
* A simple {@link Fragment} subclass.
*/
@Route(path = "/test/fragment")
public class BlankFragment extends Fragment {
@Autowired
String name;
@Autowired(required = true)
TestObj obj;
@Autowired
int age = 10;
@Autowired
int height = 175;
@Autowired(name = "boy", required = true)
boolean girl;
@Autowired
char ch = 'A';
@Autowired
float fl = 12.00f;
@Autowired
double dou = 12.01d;
@Autowired
TestSerializable ser;
@Autowired | TestParcelable pac; |
alibaba/ARouter | arouter-api/src/main/java/com/alibaba/android/arouter/utils/PackageUtils.java | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public static ILogger logger;
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
| import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import static com.alibaba.android.arouter.launcher.ARouter.logger;
import static com.alibaba.android.arouter.utils.Consts.AROUTER_SP_CACHE_KEY;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_CODE;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_NAME; | package com.alibaba.android.arouter.utils;
/**
* Android package utils
*
* @author zhilong <a href="mailto:zhilong.liu@aliyun.com">Contact me.</a>
* @version 1.0
* @since 2017/8/8 下午8:19
*/
public class PackageUtils {
private static String NEW_VERSION_NAME;
private static int NEW_VERSION_CODE;
public static boolean isNewVersion(Context context) {
PackageInfo packageInfo = getPackageInfo(context);
if (null != packageInfo) {
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
| // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public static ILogger logger;
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/PackageUtils.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import static com.alibaba.android.arouter.launcher.ARouter.logger;
import static com.alibaba.android.arouter.utils.Consts.AROUTER_SP_CACHE_KEY;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_CODE;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_NAME;
package com.alibaba.android.arouter.utils;
/**
* Android package utils
*
* @author zhilong <a href="mailto:zhilong.liu@aliyun.com">Contact me.</a>
* @version 1.0
* @since 2017/8/8 下午8:19
*/
public class PackageUtils {
private static String NEW_VERSION_NAME;
private static int NEW_VERSION_CODE;
public static boolean isNewVersion(Context context) {
PackageInfo packageInfo = getPackageInfo(context);
if (null != packageInfo) {
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
| SharedPreferences sp = context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE); |
alibaba/ARouter | arouter-api/src/main/java/com/alibaba/android/arouter/utils/PackageUtils.java | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public static ILogger logger;
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
| import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import static com.alibaba.android.arouter.launcher.ARouter.logger;
import static com.alibaba.android.arouter.utils.Consts.AROUTER_SP_CACHE_KEY;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_CODE;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_NAME; | package com.alibaba.android.arouter.utils;
/**
* Android package utils
*
* @author zhilong <a href="mailto:zhilong.liu@aliyun.com">Contact me.</a>
* @version 1.0
* @since 2017/8/8 下午8:19
*/
public class PackageUtils {
private static String NEW_VERSION_NAME;
private static int NEW_VERSION_CODE;
public static boolean isNewVersion(Context context) {
PackageInfo packageInfo = getPackageInfo(context);
if (null != packageInfo) {
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
SharedPreferences sp = context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE); | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public static ILogger logger;
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/PackageUtils.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import static com.alibaba.android.arouter.launcher.ARouter.logger;
import static com.alibaba.android.arouter.utils.Consts.AROUTER_SP_CACHE_KEY;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_CODE;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_NAME;
package com.alibaba.android.arouter.utils;
/**
* Android package utils
*
* @author zhilong <a href="mailto:zhilong.liu@aliyun.com">Contact me.</a>
* @version 1.0
* @since 2017/8/8 下午8:19
*/
public class PackageUtils {
private static String NEW_VERSION_NAME;
private static int NEW_VERSION_CODE;
public static boolean isNewVersion(Context context) {
PackageInfo packageInfo = getPackageInfo(context);
if (null != packageInfo) {
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
SharedPreferences sp = context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE); | if (!versionName.equals(sp.getString(LAST_VERSION_NAME, null)) || versionCode != sp.getInt(LAST_VERSION_CODE, -1)) { |
alibaba/ARouter | arouter-api/src/main/java/com/alibaba/android/arouter/utils/PackageUtils.java | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public static ILogger logger;
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
| import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import static com.alibaba.android.arouter.launcher.ARouter.logger;
import static com.alibaba.android.arouter.utils.Consts.AROUTER_SP_CACHE_KEY;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_CODE;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_NAME; | package com.alibaba.android.arouter.utils;
/**
* Android package utils
*
* @author zhilong <a href="mailto:zhilong.liu@aliyun.com">Contact me.</a>
* @version 1.0
* @since 2017/8/8 下午8:19
*/
public class PackageUtils {
private static String NEW_VERSION_NAME;
private static int NEW_VERSION_CODE;
public static boolean isNewVersion(Context context) {
PackageInfo packageInfo = getPackageInfo(context);
if (null != packageInfo) {
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
SharedPreferences sp = context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE); | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public static ILogger logger;
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/PackageUtils.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import static com.alibaba.android.arouter.launcher.ARouter.logger;
import static com.alibaba.android.arouter.utils.Consts.AROUTER_SP_CACHE_KEY;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_CODE;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_NAME;
package com.alibaba.android.arouter.utils;
/**
* Android package utils
*
* @author zhilong <a href="mailto:zhilong.liu@aliyun.com">Contact me.</a>
* @version 1.0
* @since 2017/8/8 下午8:19
*/
public class PackageUtils {
private static String NEW_VERSION_NAME;
private static int NEW_VERSION_CODE;
public static boolean isNewVersion(Context context) {
PackageInfo packageInfo = getPackageInfo(context);
if (null != packageInfo) {
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
SharedPreferences sp = context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE); | if (!versionName.equals(sp.getString(LAST_VERSION_NAME, null)) || versionCode != sp.getInt(LAST_VERSION_CODE, -1)) { |
alibaba/ARouter | arouter-api/src/main/java/com/alibaba/android/arouter/utils/PackageUtils.java | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public static ILogger logger;
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
| import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import static com.alibaba.android.arouter.launcher.ARouter.logger;
import static com.alibaba.android.arouter.utils.Consts.AROUTER_SP_CACHE_KEY;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_CODE;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_NAME; | String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
SharedPreferences sp = context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE);
if (!versionName.equals(sp.getString(LAST_VERSION_NAME, null)) || versionCode != sp.getInt(LAST_VERSION_CODE, -1)) {
// new version
NEW_VERSION_NAME = versionName;
NEW_VERSION_CODE = versionCode;
return true;
} else {
return false;
}
} else {
return true;
}
}
public static void updateVersion(Context context) {
if (!android.text.TextUtils.isEmpty(NEW_VERSION_NAME) && NEW_VERSION_CODE != 0) {
SharedPreferences sp = context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE);
sp.edit().putString(LAST_VERSION_NAME, NEW_VERSION_NAME).putInt(LAST_VERSION_CODE, NEW_VERSION_CODE).apply();
}
}
private static PackageInfo getPackageInfo(Context context) {
PackageInfo packageInfo = null;
try {
packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_CONFIGURATIONS);
} catch (Exception ex) { | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public static ILogger logger;
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
//
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/PackageUtils.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import static com.alibaba.android.arouter.launcher.ARouter.logger;
import static com.alibaba.android.arouter.utils.Consts.AROUTER_SP_CACHE_KEY;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_CODE;
import static com.alibaba.android.arouter.utils.Consts.LAST_VERSION_NAME;
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
SharedPreferences sp = context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE);
if (!versionName.equals(sp.getString(LAST_VERSION_NAME, null)) || versionCode != sp.getInt(LAST_VERSION_CODE, -1)) {
// new version
NEW_VERSION_NAME = versionName;
NEW_VERSION_CODE = versionCode;
return true;
} else {
return false;
}
} else {
return true;
}
}
public static void updateVersion(Context context) {
if (!android.text.TextUtils.isEmpty(NEW_VERSION_NAME) && NEW_VERSION_CODE != 0) {
SharedPreferences sp = context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE);
sp.edit().putString(LAST_VERSION_NAME, NEW_VERSION_NAME).putInt(LAST_VERSION_CODE, NEW_VERSION_CODE).apply();
}
}
private static PackageInfo getPackageInfo(Context context) {
PackageInfo packageInfo = null;
try {
packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_CONFIGURATIONS);
} catch (Exception ex) { | logger.error(Consts.TAG, "Get package info error."); |
alibaba/ARouter | arouter-api/src/main/java/com/alibaba/android/arouter/facade/template/ILogger.java | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public final class Consts {
// public static final String SDK_NAME = "ARouter";
// public static final String TAG = SDK_NAME + "::";
// public static final String SEPARATOR = "$$";
// public static final String SUFFIX_ROOT = "Root";
// public static final String SUFFIX_INTERCEPTORS = "Interceptors";
// public static final String SUFFIX_PROVIDERS = "Providers";
// public static final String SUFFIX_AUTOWIRED = SEPARATOR + SDK_NAME + SEPARATOR + "Autowired";
// public static final String DOT = ".";
// public static final String ROUTE_ROOT_PAKCAGE = "com.alibaba.android.arouter.routes";
//
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
// public static final String AROUTER_SP_KEY_MAP = "ROUTER_MAP";
//
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
// }
| import com.alibaba.android.arouter.utils.Consts; | package com.alibaba.android.arouter.facade.template;
/**
* Logger
*
* @author 正纬 <a href="mailto:zhilong.liu@aliyun.com">Contact me.</a>
* @version 1.0
* @since 16/5/16 下午5:39
*/
public interface ILogger {
boolean isShowLog = false;
boolean isShowStackTrace = false; | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public final class Consts {
// public static final String SDK_NAME = "ARouter";
// public static final String TAG = SDK_NAME + "::";
// public static final String SEPARATOR = "$$";
// public static final String SUFFIX_ROOT = "Root";
// public static final String SUFFIX_INTERCEPTORS = "Interceptors";
// public static final String SUFFIX_PROVIDERS = "Providers";
// public static final String SUFFIX_AUTOWIRED = SEPARATOR + SDK_NAME + SEPARATOR + "Autowired";
// public static final String DOT = ".";
// public static final String ROUTE_ROOT_PAKCAGE = "com.alibaba.android.arouter.routes";
//
// public static final String AROUTER_SP_CACHE_KEY = "SP_AROUTER_CACHE";
// public static final String AROUTER_SP_KEY_MAP = "ROUTER_MAP";
//
// public static final String LAST_VERSION_NAME = "LAST_VERSION_NAME";
// public static final String LAST_VERSION_CODE = "LAST_VERSION_CODE";
// }
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/facade/template/ILogger.java
import com.alibaba.android.arouter.utils.Consts;
package com.alibaba.android.arouter.facade.template;
/**
* Logger
*
* @author 正纬 <a href="mailto:zhilong.liu@aliyun.com">Contact me.</a>
* @version 1.0
* @since 16/5/16 下午5:39
*/
public interface ILogger {
boolean isShowLog = false;
boolean isShowStackTrace = false; | String defaultTag = Consts.TAG; |
alibaba/ARouter | module-java/src/main/java/com/alibaba/android/arouter/demo/module1/testactivity/Test3Activity.java | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public final class ARouter {
// // Key of raw uri
// public static final String RAW_URI = "NTeRQWvye18AkPd6G";
// public static final String AUTO_INJECT = "wmHzgD4lOj5o4241";
//
// private volatile static ARouter instance = null;
// private volatile static boolean hasInit = false;
// public static ILogger logger;
//
// private ARouter() {
// }
//
// /**
// * Init, it must be call before used router.
// */
// public static void init(Application application) {
// if (!hasInit) {
// logger = _ARouter.logger;
// _ARouter.logger.info(Consts.TAG, "ARouter init start.");
// hasInit = _ARouter.init(application);
//
// if (hasInit) {
// _ARouter.afterInit();
// }
//
// _ARouter.logger.info(Consts.TAG, "ARouter init over.");
// }
// }
//
// /**
// * Get instance of router. A
// * All feature U use, will be starts here.
// */
// public static ARouter getInstance() {
// if (!hasInit) {
// throw new InitException("ARouter::Init::Invoke init(context) first!");
// } else {
// if (instance == null) {
// synchronized (ARouter.class) {
// if (instance == null) {
// instance = new ARouter();
// }
// }
// }
// return instance;
// }
// }
//
// public static synchronized void openDebug() {
// _ARouter.openDebug();
// }
//
// public static boolean debuggable() {
// return _ARouter.debuggable();
// }
//
// public static synchronized void openLog() {
// _ARouter.openLog();
// }
//
// public static synchronized void printStackTrace() {
// _ARouter.printStackTrace();
// }
//
// public static synchronized void setExecutor(ThreadPoolExecutor tpe) {
// _ARouter.setExecutor(tpe);
// }
//
// public synchronized void destroy() {
// _ARouter.destroy();
// hasInit = false;
// }
//
// /**
// * The interface is not stable enough, use 'ARouter.inject();';
// */
// @Deprecated
// public static synchronized void enableAutoInject() {
// _ARouter.enableAutoInject();
// }
//
// @Deprecated
// public static boolean canAutoInject() {
// return _ARouter.canAutoInject();
// }
//
// /**
// * The interface is not stable enough, use 'ARouter.inject();';
// */
// @Deprecated
// public static void attachBaseContext() {
// _ARouter.attachBaseContext();
// }
//
// public static synchronized void monitorMode() {
// _ARouter.monitorMode();
// }
//
// public static boolean isMonitorMode() {
// return _ARouter.isMonitorMode();
// }
//
// public static void setLogger(ILogger userLogger) {
// _ARouter.setLogger(userLogger);
// }
//
// /**
// * Inject params and services.
// */
// public void inject(Object thiz) {
// _ARouter.inject(thiz);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param path Where you go.
// */
// public Postcard build(String path) {
// return _ARouter.getInstance().build(path);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param path Where you go.
// * @param group The group of path.
// */
// @Deprecated
// public Postcard build(String path, String group) {
// return _ARouter.getInstance().build(path, group, false);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param url the path
// */
// public Postcard build(Uri url) {
// return _ARouter.getInstance().build(url);
// }
//
// /**
// * Launch the navigation by type
// *
// * @param service interface of service
// * @param <T> return type
// * @return instance of service
// */
// public <T> T navigation(Class<? extends T> service) {
// return _ARouter.getInstance().navigation(service);
// }
//
// /**
// * Launch the navigation.
// *
// * @param mContext .
// * @param postcard .
// * @param requestCode Set for startActivityForResult
// * @param callback cb
// */
// public Object navigation(Context mContext, Postcard postcard, int requestCode, NavigationCallback callback) {
// return _ARouter.getInstance().navigation(mContext, postcard, requestCode, callback);
// }
//
// /**
// * Add route group dynamic.
// * @param group route group.
// * @return add result.
// */
// public boolean addRouteGroup(IRouteGroup group) {
// return _ARouter.getInstance().addRouteGroup(group);
// }
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import com.alibaba.android.arouter.demo.module1.R;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter; | package com.alibaba.android.arouter.demo.module1.testactivity;
/**
* 自动注入的测试用例
*/
@Route(path = "/test/activity3")
public class Test3Activity extends AppCompatActivity {
@Autowired
String name;
@Autowired
int age;
@Autowired(name = "boy")
boolean girl;
// 这个字段没有注解,是不会自动注入的
private long high;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test1);
| // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public final class ARouter {
// // Key of raw uri
// public static final String RAW_URI = "NTeRQWvye18AkPd6G";
// public static final String AUTO_INJECT = "wmHzgD4lOj5o4241";
//
// private volatile static ARouter instance = null;
// private volatile static boolean hasInit = false;
// public static ILogger logger;
//
// private ARouter() {
// }
//
// /**
// * Init, it must be call before used router.
// */
// public static void init(Application application) {
// if (!hasInit) {
// logger = _ARouter.logger;
// _ARouter.logger.info(Consts.TAG, "ARouter init start.");
// hasInit = _ARouter.init(application);
//
// if (hasInit) {
// _ARouter.afterInit();
// }
//
// _ARouter.logger.info(Consts.TAG, "ARouter init over.");
// }
// }
//
// /**
// * Get instance of router. A
// * All feature U use, will be starts here.
// */
// public static ARouter getInstance() {
// if (!hasInit) {
// throw new InitException("ARouter::Init::Invoke init(context) first!");
// } else {
// if (instance == null) {
// synchronized (ARouter.class) {
// if (instance == null) {
// instance = new ARouter();
// }
// }
// }
// return instance;
// }
// }
//
// public static synchronized void openDebug() {
// _ARouter.openDebug();
// }
//
// public static boolean debuggable() {
// return _ARouter.debuggable();
// }
//
// public static synchronized void openLog() {
// _ARouter.openLog();
// }
//
// public static synchronized void printStackTrace() {
// _ARouter.printStackTrace();
// }
//
// public static synchronized void setExecutor(ThreadPoolExecutor tpe) {
// _ARouter.setExecutor(tpe);
// }
//
// public synchronized void destroy() {
// _ARouter.destroy();
// hasInit = false;
// }
//
// /**
// * The interface is not stable enough, use 'ARouter.inject();';
// */
// @Deprecated
// public static synchronized void enableAutoInject() {
// _ARouter.enableAutoInject();
// }
//
// @Deprecated
// public static boolean canAutoInject() {
// return _ARouter.canAutoInject();
// }
//
// /**
// * The interface is not stable enough, use 'ARouter.inject();';
// */
// @Deprecated
// public static void attachBaseContext() {
// _ARouter.attachBaseContext();
// }
//
// public static synchronized void monitorMode() {
// _ARouter.monitorMode();
// }
//
// public static boolean isMonitorMode() {
// return _ARouter.isMonitorMode();
// }
//
// public static void setLogger(ILogger userLogger) {
// _ARouter.setLogger(userLogger);
// }
//
// /**
// * Inject params and services.
// */
// public void inject(Object thiz) {
// _ARouter.inject(thiz);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param path Where you go.
// */
// public Postcard build(String path) {
// return _ARouter.getInstance().build(path);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param path Where you go.
// * @param group The group of path.
// */
// @Deprecated
// public Postcard build(String path, String group) {
// return _ARouter.getInstance().build(path, group, false);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param url the path
// */
// public Postcard build(Uri url) {
// return _ARouter.getInstance().build(url);
// }
//
// /**
// * Launch the navigation by type
// *
// * @param service interface of service
// * @param <T> return type
// * @return instance of service
// */
// public <T> T navigation(Class<? extends T> service) {
// return _ARouter.getInstance().navigation(service);
// }
//
// /**
// * Launch the navigation.
// *
// * @param mContext .
// * @param postcard .
// * @param requestCode Set for startActivityForResult
// * @param callback cb
// */
// public Object navigation(Context mContext, Postcard postcard, int requestCode, NavigationCallback callback) {
// return _ARouter.getInstance().navigation(mContext, postcard, requestCode, callback);
// }
//
// /**
// * Add route group dynamic.
// * @param group route group.
// * @return add result.
// */
// public boolean addRouteGroup(IRouteGroup group) {
// return _ARouter.getInstance().addRouteGroup(group);
// }
// }
// Path: module-java/src/main/java/com/alibaba/android/arouter/demo/module1/testactivity/Test3Activity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import com.alibaba.android.arouter.demo.module1.R;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
package com.alibaba.android.arouter.demo.module1.testactivity;
/**
* 自动注入的测试用例
*/
@Route(path = "/test/activity3")
public class Test3Activity extends AppCompatActivity {
@Autowired
String name;
@Autowired
int age;
@Autowired(name = "boy")
boolean girl;
// 这个字段没有注解,是不会自动注入的
private long high;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test1);
| ARouter.getInstance().inject(this); |
alibaba/ARouter | module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/Entrance.java | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public final class ARouter {
// // Key of raw uri
// public static final String RAW_URI = "NTeRQWvye18AkPd6G";
// public static final String AUTO_INJECT = "wmHzgD4lOj5o4241";
//
// private volatile static ARouter instance = null;
// private volatile static boolean hasInit = false;
// public static ILogger logger;
//
// private ARouter() {
// }
//
// /**
// * Init, it must be call before used router.
// */
// public static void init(Application application) {
// if (!hasInit) {
// logger = _ARouter.logger;
// _ARouter.logger.info(Consts.TAG, "ARouter init start.");
// hasInit = _ARouter.init(application);
//
// if (hasInit) {
// _ARouter.afterInit();
// }
//
// _ARouter.logger.info(Consts.TAG, "ARouter init over.");
// }
// }
//
// /**
// * Get instance of router. A
// * All feature U use, will be starts here.
// */
// public static ARouter getInstance() {
// if (!hasInit) {
// throw new InitException("ARouter::Init::Invoke init(context) first!");
// } else {
// if (instance == null) {
// synchronized (ARouter.class) {
// if (instance == null) {
// instance = new ARouter();
// }
// }
// }
// return instance;
// }
// }
//
// public static synchronized void openDebug() {
// _ARouter.openDebug();
// }
//
// public static boolean debuggable() {
// return _ARouter.debuggable();
// }
//
// public static synchronized void openLog() {
// _ARouter.openLog();
// }
//
// public static synchronized void printStackTrace() {
// _ARouter.printStackTrace();
// }
//
// public static synchronized void setExecutor(ThreadPoolExecutor tpe) {
// _ARouter.setExecutor(tpe);
// }
//
// public synchronized void destroy() {
// _ARouter.destroy();
// hasInit = false;
// }
//
// /**
// * The interface is not stable enough, use 'ARouter.inject();';
// */
// @Deprecated
// public static synchronized void enableAutoInject() {
// _ARouter.enableAutoInject();
// }
//
// @Deprecated
// public static boolean canAutoInject() {
// return _ARouter.canAutoInject();
// }
//
// /**
// * The interface is not stable enough, use 'ARouter.inject();';
// */
// @Deprecated
// public static void attachBaseContext() {
// _ARouter.attachBaseContext();
// }
//
// public static synchronized void monitorMode() {
// _ARouter.monitorMode();
// }
//
// public static boolean isMonitorMode() {
// return _ARouter.isMonitorMode();
// }
//
// public static void setLogger(ILogger userLogger) {
// _ARouter.setLogger(userLogger);
// }
//
// /**
// * Inject params and services.
// */
// public void inject(Object thiz) {
// _ARouter.inject(thiz);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param path Where you go.
// */
// public Postcard build(String path) {
// return _ARouter.getInstance().build(path);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param path Where you go.
// * @param group The group of path.
// */
// @Deprecated
// public Postcard build(String path, String group) {
// return _ARouter.getInstance().build(path, group, false);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param url the path
// */
// public Postcard build(Uri url) {
// return _ARouter.getInstance().build(url);
// }
//
// /**
// * Launch the navigation by type
// *
// * @param service interface of service
// * @param <T> return type
// * @return instance of service
// */
// public <T> T navigation(Class<? extends T> service) {
// return _ARouter.getInstance().navigation(service);
// }
//
// /**
// * Launch the navigation.
// *
// * @param mContext .
// * @param postcard .
// * @param requestCode Set for startActivityForResult
// * @param callback cb
// */
// public Object navigation(Context mContext, Postcard postcard, int requestCode, NavigationCallback callback) {
// return _ARouter.getInstance().navigation(mContext, postcard, requestCode, callback);
// }
//
// /**
// * Add route group dynamic.
// * @param group route group.
// * @return add result.
// */
// public boolean addRouteGroup(IRouteGroup group) {
// return _ARouter.getInstance().addRouteGroup(group);
// }
// }
| import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter; | package com.alibaba.android.arouter.demo.service;
public class Entrance {
/**
* 跳转到 Test1 Activity,
*
* @param name 姓名
* @param age 年龄
* @param context ctx
*/
public static void redirect2Test1Activity(String name, int age, Context context) { | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/launcher/ARouter.java
// public final class ARouter {
// // Key of raw uri
// public static final String RAW_URI = "NTeRQWvye18AkPd6G";
// public static final String AUTO_INJECT = "wmHzgD4lOj5o4241";
//
// private volatile static ARouter instance = null;
// private volatile static boolean hasInit = false;
// public static ILogger logger;
//
// private ARouter() {
// }
//
// /**
// * Init, it must be call before used router.
// */
// public static void init(Application application) {
// if (!hasInit) {
// logger = _ARouter.logger;
// _ARouter.logger.info(Consts.TAG, "ARouter init start.");
// hasInit = _ARouter.init(application);
//
// if (hasInit) {
// _ARouter.afterInit();
// }
//
// _ARouter.logger.info(Consts.TAG, "ARouter init over.");
// }
// }
//
// /**
// * Get instance of router. A
// * All feature U use, will be starts here.
// */
// public static ARouter getInstance() {
// if (!hasInit) {
// throw new InitException("ARouter::Init::Invoke init(context) first!");
// } else {
// if (instance == null) {
// synchronized (ARouter.class) {
// if (instance == null) {
// instance = new ARouter();
// }
// }
// }
// return instance;
// }
// }
//
// public static synchronized void openDebug() {
// _ARouter.openDebug();
// }
//
// public static boolean debuggable() {
// return _ARouter.debuggable();
// }
//
// public static synchronized void openLog() {
// _ARouter.openLog();
// }
//
// public static synchronized void printStackTrace() {
// _ARouter.printStackTrace();
// }
//
// public static synchronized void setExecutor(ThreadPoolExecutor tpe) {
// _ARouter.setExecutor(tpe);
// }
//
// public synchronized void destroy() {
// _ARouter.destroy();
// hasInit = false;
// }
//
// /**
// * The interface is not stable enough, use 'ARouter.inject();';
// */
// @Deprecated
// public static synchronized void enableAutoInject() {
// _ARouter.enableAutoInject();
// }
//
// @Deprecated
// public static boolean canAutoInject() {
// return _ARouter.canAutoInject();
// }
//
// /**
// * The interface is not stable enough, use 'ARouter.inject();';
// */
// @Deprecated
// public static void attachBaseContext() {
// _ARouter.attachBaseContext();
// }
//
// public static synchronized void monitorMode() {
// _ARouter.monitorMode();
// }
//
// public static boolean isMonitorMode() {
// return _ARouter.isMonitorMode();
// }
//
// public static void setLogger(ILogger userLogger) {
// _ARouter.setLogger(userLogger);
// }
//
// /**
// * Inject params and services.
// */
// public void inject(Object thiz) {
// _ARouter.inject(thiz);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param path Where you go.
// */
// public Postcard build(String path) {
// return _ARouter.getInstance().build(path);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param path Where you go.
// * @param group The group of path.
// */
// @Deprecated
// public Postcard build(String path, String group) {
// return _ARouter.getInstance().build(path, group, false);
// }
//
// /**
// * Build the roadmap, draw a postcard.
// *
// * @param url the path
// */
// public Postcard build(Uri url) {
// return _ARouter.getInstance().build(url);
// }
//
// /**
// * Launch the navigation by type
// *
// * @param service interface of service
// * @param <T> return type
// * @return instance of service
// */
// public <T> T navigation(Class<? extends T> service) {
// return _ARouter.getInstance().navigation(service);
// }
//
// /**
// * Launch the navigation.
// *
// * @param mContext .
// * @param postcard .
// * @param requestCode Set for startActivityForResult
// * @param callback cb
// */
// public Object navigation(Context mContext, Postcard postcard, int requestCode, NavigationCallback callback) {
// return _ARouter.getInstance().navigation(mContext, postcard, requestCode, callback);
// }
//
// /**
// * Add route group dynamic.
// * @param group route group.
// * @return add result.
// */
// public boolean addRouteGroup(IRouteGroup group) {
// return _ARouter.getInstance().addRouteGroup(group);
// }
// }
// Path: module-java-export/src/main/java/com/alibaba/android/arouter/demo/service/Entrance.java
import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter;
package com.alibaba.android.arouter.demo.service;
public class Entrance {
/**
* 跳转到 Test1 Activity,
*
* @param name 姓名
* @param age 年龄
* @param context ctx
*/
public static void redirect2Test1Activity(String name, int age, Context context) { | ARouter.getInstance().build("/test/activity1") |
alibaba/ARouter | arouter-api/src/main/java/com/alibaba/android/arouter/core/AutowiredServiceImpl.java | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String SUFFIX_AUTOWIRED = SEPARATOR + SDK_NAME + SEPARATOR + "Autowired";
| import android.content.Context;
import android.util.LruCache;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.facade.service.AutowiredService;
import com.alibaba.android.arouter.facade.template.ISyringe;
import java.util.ArrayList;
import java.util.List;
import static com.alibaba.android.arouter.utils.Consts.SUFFIX_AUTOWIRED; | }
/**
* Recursive injection
*
* @param instance who call me.
* @param parent parent of me.
*/
private void doInject(Object instance, Class<?> parent) {
Class<?> clazz = null == parent ? instance.getClass() : parent;
ISyringe syringe = getSyringe(clazz);
if (null != syringe) {
syringe.inject(instance);
}
Class<?> superClazz = clazz.getSuperclass();
// has parent and its not the class of framework.
if (null != superClazz && !superClazz.getName().startsWith("android")) {
doInject(instance, superClazz);
}
}
private ISyringe getSyringe(Class<?> clazz) {
String className = clazz.getName();
try {
if (!blackList.contains(className)) {
ISyringe syringeHelper = classCache.get(className);
if (null == syringeHelper) { // No cache. | // Path: arouter-api/src/main/java/com/alibaba/android/arouter/utils/Consts.java
// public static final String SUFFIX_AUTOWIRED = SEPARATOR + SDK_NAME + SEPARATOR + "Autowired";
// Path: arouter-api/src/main/java/com/alibaba/android/arouter/core/AutowiredServiceImpl.java
import android.content.Context;
import android.util.LruCache;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.facade.service.AutowiredService;
import com.alibaba.android.arouter.facade.template.ISyringe;
import java.util.ArrayList;
import java.util.List;
import static com.alibaba.android.arouter.utils.Consts.SUFFIX_AUTOWIRED;
}
/**
* Recursive injection
*
* @param instance who call me.
* @param parent parent of me.
*/
private void doInject(Object instance, Class<?> parent) {
Class<?> clazz = null == parent ? instance.getClass() : parent;
ISyringe syringe = getSyringe(clazz);
if (null != syringe) {
syringe.inject(instance);
}
Class<?> superClazz = clazz.getSuperclass();
// has parent and its not the class of framework.
if (null != superClazz && !superClazz.getName().startsWith("android")) {
doInject(instance, superClazz);
}
}
private ISyringe getSyringe(Class<?> clazz) {
String className = clazz.getName();
try {
if (!blackList.contains(className)) {
ISyringe syringeHelper = classCache.get(className);
if (null == syringeHelper) { // No cache. | syringeHelper = (ISyringe) Class.forName(clazz.getName() + SUFFIX_AUTOWIRED).getConstructor().newInstance(); |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
| // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
| parcelableType = elements.getTypeElement(PARCELABLE).asType(); |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType(); | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType(); | serializableType = elements.getTypeElement(SERIALIZABLE).asType(); |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) { | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) { | case BYTE: |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE: | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE: | return TypeKind.BYTE.ordinal(); |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal(); | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal(); | case SHORT: |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal(); | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal(); | case INTEGER: |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal(); | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal(); | case LONG: |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal(); | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal(); | case FLOAT: |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal();
case FLOAT:
return TypeKind.FLOAT.ordinal(); | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal();
case FLOAT:
return TypeKind.FLOAT.ordinal(); | case DOUBEL: |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal();
case FLOAT:
return TypeKind.FLOAT.ordinal();
case DOUBEL:
return TypeKind.DOUBLE.ordinal(); | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal();
case FLOAT:
return TypeKind.FLOAT.ordinal();
case DOUBEL:
return TypeKind.DOUBLE.ordinal(); | case BOOLEAN: |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal();
case FLOAT:
return TypeKind.FLOAT.ordinal();
case DOUBEL:
return TypeKind.DOUBLE.ordinal();
case BOOLEAN:
return TypeKind.BOOLEAN.ordinal(); | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
package com.alibaba.android.arouter.compiler.utils;
/**
* Utils for type exchange
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/21 下午1:06
*/
public class TypeUtils {
private Types types;
private TypeMirror parcelableType;
private TypeMirror serializableType;
public TypeUtils(Types types, Elements elements) {
this.types = types;
parcelableType = elements.getTypeElement(PARCELABLE).asType();
serializableType = elements.getTypeElement(SERIALIZABLE).asType();
}
/**
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal();
case FLOAT:
return TypeKind.FLOAT.ordinal();
case DOUBEL:
return TypeKind.DOUBLE.ordinal();
case BOOLEAN:
return TypeKind.BOOLEAN.ordinal(); | case CHAR: |
alibaba/ARouter | arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
| import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR; | * Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal();
case FLOAT:
return TypeKind.FLOAT.ordinal();
case DOUBEL:
return TypeKind.DOUBLE.ordinal();
case BOOLEAN:
return TypeKind.BOOLEAN.ordinal();
case CHAR:
return TypeKind.CHAR.ordinal(); | // Path: arouter-annotation/src/main/java/com/alibaba/android/arouter/facade/enums/TypeKind.java
// public enum TypeKind {
// // Base type
// BOOLEAN,
// BYTE,
// SHORT,
// INT,
// LONG,
// CHAR,
// FLOAT,
// DOUBLE,
//
// // Other type
// STRING,
// SERIALIZABLE,
// PARCELABLE,
// OBJECT;
// }
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BOOLEAN = LANG + ".Boolean";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String BYTE = LANG + ".Byte";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String DOUBEL = LANG + ".Double";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String FLOAT = LANG + ".Float";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String INTEGER = LANG + ".Integer";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String LONG = LANG + ".Long";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String PARCELABLE = "android.os.Parcelable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SERIALIZABLE = "java.io.Serializable";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String SHORT = LANG + ".Short";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String STRING = LANG + ".String";
//
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/Consts.java
// public static final String CHAR = LANG + ".Character";
// Path: arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/utils/TypeUtils.java
import com.alibaba.android.arouter.facade.enums.TypeKind;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import static com.alibaba.android.arouter.compiler.utils.Consts.BOOLEAN;
import static com.alibaba.android.arouter.compiler.utils.Consts.BYTE;
import static com.alibaba.android.arouter.compiler.utils.Consts.DOUBEL;
import static com.alibaba.android.arouter.compiler.utils.Consts.FLOAT;
import static com.alibaba.android.arouter.compiler.utils.Consts.INTEGER;
import static com.alibaba.android.arouter.compiler.utils.Consts.LONG;
import static com.alibaba.android.arouter.compiler.utils.Consts.PARCELABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SERIALIZABLE;
import static com.alibaba.android.arouter.compiler.utils.Consts.SHORT;
import static com.alibaba.android.arouter.compiler.utils.Consts.STRING;
import static com.alibaba.android.arouter.compiler.utils.Consts.CHAR;
* Diagnostics out the true java type
*
* @param element Raw type
* @return Type class of java
*/
public int typeExchange(Element element) {
TypeMirror typeMirror = element.asType();
// Primitive
if (typeMirror.getKind().isPrimitive()) {
return element.asType().getKind().ordinal();
}
switch (typeMirror.toString()) {
case BYTE:
return TypeKind.BYTE.ordinal();
case SHORT:
return TypeKind.SHORT.ordinal();
case INTEGER:
return TypeKind.INT.ordinal();
case LONG:
return TypeKind.LONG.ordinal();
case FLOAT:
return TypeKind.FLOAT.ordinal();
case DOUBEL:
return TypeKind.DOUBLE.ordinal();
case BOOLEAN:
return TypeKind.BOOLEAN.ordinal();
case CHAR:
return TypeKind.CHAR.ordinal(); | case STRING: |
jasonwyatt/SRML | app/src/main/java/co/jasonwyatt/srmldemoapp/TargetActivity.java | // Path: library/src/main/java/co/jasonwyatt/srml/SRML.java
// public final class SRML {
// private static Transformer sTransformer;
//
// static {
// configure(new DefaultTransformer(), null);
// }
//
// private SRML() {
// // no outside instantiation needed plz
// }
//
// /**
// * Supply a {@link Transformer} for SRML.
// * @param transformer The new transformer.
// * @param imageLoader An {@link SRMLImageLoader} for SRML.
// */
// public static void configure(Transformer transformer, SRMLImageLoader imageLoader) {
// sTransformer = transformer;
// setImageLoader(imageLoader);
// }
//
// /**
// * Set an image loader for SRML.
// * @param imageLoader The new image loader.
// */
// public static void setImageLoader(SRMLImageLoader imageLoader) {
// Utils.setImageLoader(imageLoader);
// }
//
// /**
// * Register a new {@link Tag} type with SRML.
// * @param name The tag's name, aka: the first part in a tag after the <code>{{</code> or <code>{{/</code>
// * @param tagClass The class for an implementation of {@link Tag}
// */
// public static void registerTag(String name, Class<? extends Tag> tagClass) {
// sTransformer.getTagFactory().registerTag(name, tagClass);
// }
//
// /**
// * Analog of {@link Context#getString(int)} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId) {
// return getString(context, sTransformer, resId);
// }
//
// /**
// * Analog of {@link Context#getString(int, Object[])} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @param formatArgs Format arguments for the string, passed along to {@link Context#getString(int, Object[]}
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId, Object... formatArgs) {
// return getString(context, sTransformer, resId, formatArgs);
// }
//
// public static CharSequence[] getStringArray(Context context, @ArrayRes int resId) {
// return getStringArray(context, sTransformer, resId);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity) {
// return getQuantityString(context, sTransformer, resId, quantity);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return getQuantityString(context, sTransformer, resId, quantity, formatArgs);
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId) {
// return transformer.transform(context, context.getString(resId));
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId, Object... formatArgs) {
// return transformer.transform(context, context.getString(resId, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// public static CharSequence[] getStringArray(Context context, Transformer transformer, @ArrayRes int resId) {
// String[] strings = context.getResources().getStringArray(resId);
// CharSequence[] result = new CharSequence[strings.length];
// for (int i = 0, len = result.length; i < len; i++) {
// result[i] = transformer.transform(context, strings[i]);
// }
// return result;
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity));
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// /**
// * Mark up a string with SRML.
// * @param context Current context
// * @param str String to mark up.
// * @return Marked-up CharSequence.
// */
// public static CharSequence markup(Context context, String str) {
// return sTransformer.transform(context, str);
// }
// }
| import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import co.jasonwyatt.srml.SRML; | package co.jasonwyatt.srmldemoapp;
public class TargetActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_target);
setTitle(R.string.another_activity_title);
Intent i = getIntent();
TextView textView = (TextView) findViewById(R.id.text);
if (i.hasExtra("text")) { | // Path: library/src/main/java/co/jasonwyatt/srml/SRML.java
// public final class SRML {
// private static Transformer sTransformer;
//
// static {
// configure(new DefaultTransformer(), null);
// }
//
// private SRML() {
// // no outside instantiation needed plz
// }
//
// /**
// * Supply a {@link Transformer} for SRML.
// * @param transformer The new transformer.
// * @param imageLoader An {@link SRMLImageLoader} for SRML.
// */
// public static void configure(Transformer transformer, SRMLImageLoader imageLoader) {
// sTransformer = transformer;
// setImageLoader(imageLoader);
// }
//
// /**
// * Set an image loader for SRML.
// * @param imageLoader The new image loader.
// */
// public static void setImageLoader(SRMLImageLoader imageLoader) {
// Utils.setImageLoader(imageLoader);
// }
//
// /**
// * Register a new {@link Tag} type with SRML.
// * @param name The tag's name, aka: the first part in a tag after the <code>{{</code> or <code>{{/</code>
// * @param tagClass The class for an implementation of {@link Tag}
// */
// public static void registerTag(String name, Class<? extends Tag> tagClass) {
// sTransformer.getTagFactory().registerTag(name, tagClass);
// }
//
// /**
// * Analog of {@link Context#getString(int)} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId) {
// return getString(context, sTransformer, resId);
// }
//
// /**
// * Analog of {@link Context#getString(int, Object[])} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @param formatArgs Format arguments for the string, passed along to {@link Context#getString(int, Object[]}
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId, Object... formatArgs) {
// return getString(context, sTransformer, resId, formatArgs);
// }
//
// public static CharSequence[] getStringArray(Context context, @ArrayRes int resId) {
// return getStringArray(context, sTransformer, resId);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity) {
// return getQuantityString(context, sTransformer, resId, quantity);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return getQuantityString(context, sTransformer, resId, quantity, formatArgs);
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId) {
// return transformer.transform(context, context.getString(resId));
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId, Object... formatArgs) {
// return transformer.transform(context, context.getString(resId, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// public static CharSequence[] getStringArray(Context context, Transformer transformer, @ArrayRes int resId) {
// String[] strings = context.getResources().getStringArray(resId);
// CharSequence[] result = new CharSequence[strings.length];
// for (int i = 0, len = result.length; i < len; i++) {
// result[i] = transformer.transform(context, strings[i]);
// }
// return result;
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity));
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// /**
// * Mark up a string with SRML.
// * @param context Current context
// * @param str String to mark up.
// * @return Marked-up CharSequence.
// */
// public static CharSequence markup(Context context, String str) {
// return sTransformer.transform(context, str);
// }
// }
// Path: app/src/main/java/co/jasonwyatt/srmldemoapp/TargetActivity.java
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import co.jasonwyatt.srml.SRML;
package co.jasonwyatt.srmldemoapp;
public class TargetActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_target);
setTitle(R.string.another_activity_title);
Intent i = getIntent();
TextView textView = (TextView) findViewById(R.id.text);
if (i.hasExtra("text")) { | textView.setText(SRML.getString(this, R.string.text_extra_sent, i.getStringExtra("text"))); |
jasonwyatt/SRML | library/src/main/java/co/jasonwyatt/srml/Transformer.java | // Path: library/src/main/java/co/jasonwyatt/srml/tags/TagFactory.java
// public final class TagFactory {
// private Map<String, Constructor<? extends Tag>> mConstructorMap = new HashMap<>();
// public TagFactory() {
// // nothing...
// }
//
// public Tag getTag(String tagName, String tagText, int startPosition) {
// if (Bold.NAME.equalsIgnoreCase(tagName)) {
// return new Bold(tagText, startPosition);
// }
// if (Italic.NAME.equalsIgnoreCase(tagName)) {
// return new Italic(tagText, startPosition);
// }
// if (Underline.NAME.equalsIgnoreCase(tagName)) {
// return new Underline(tagText, startPosition);
// }
// if (Strikethrough.NAME.equalsIgnoreCase(tagName)) {
// return new Strikethrough(tagText, startPosition);
// }
// if (Color.NAME.equalsIgnoreCase(tagName)) {
// return new Color(tagText, startPosition);
// }
// if (Link.NAME.equalsIgnoreCase(tagName)) {
// return new Link(tagText, startPosition);
// }
// if (Code.NAME.equalsIgnoreCase(tagName)) {
// return new Code(tagText, startPosition);
// }
// if (IntentTag.NAME.equalsIgnoreCase(tagName)) {
// return new IntentTag(tagText, startPosition);
// }
// if (DrawableTag.NAME.equalsIgnoreCase(tagName)) {
// return new DrawableTag(tagText, startPosition);
// }
// if (Superscript.NAME.equalsIgnoreCase(tagName)) {
// return new Superscript(tagText, startPosition);
// }
// if (Subscript.NAME.equalsIgnoreCase(tagName)) {
// return new Subscript(tagText, startPosition);
// }
// if (FontTag.NAME.equalsIgnoreCase(tagName)) {
// return new FontTag(tagText, startPosition);
// }
// if (mConstructorMap.containsKey(tagName.toLowerCase())) {
// try {
// return mConstructorMap.get(tagName.toLowerCase()).newInstance(tagText, startPosition);
// } catch (InstantiationException e) {
// throw new CouldNotCreateTagException(e, tagName);
// } catch (IllegalAccessException e) {
// throw new CouldNotCreateTagException(e, tagName);
// } catch (InvocationTargetException e) {
// throw new CouldNotCreateTagException(e, tagName);
// }
// }
// throw new BadTagException("Could not create Tag for {{" + tagText + "}} at position:" + startPosition);
// }
//
// public void registerTag(String tagName, Class<? extends Tag> tagClass) {
// try {
// mConstructorMap.put(tagName.toLowerCase(), tagClass.getConstructor(String.class, int.class));
// } catch (NoSuchMethodException e) {
// throw new CouldNotRegisterTagException(e, tagClass);
// }
// }
// }
| import android.content.Context;
import co.jasonwyatt.srml.tags.TagFactory; | package co.jasonwyatt.srml;
/**
* Defines an object which is capable of transforming a given SRML-marked-up String into a
* styled/spanned CharSequence according to the tags used in the string.
* @author jason
*/
public interface Transformer {
CharSequence transform(Context context, String srmlString);
Sanitizer getSanitizer();
/**
* Get the {@link TagFactory} for the transformer.
*/ | // Path: library/src/main/java/co/jasonwyatt/srml/tags/TagFactory.java
// public final class TagFactory {
// private Map<String, Constructor<? extends Tag>> mConstructorMap = new HashMap<>();
// public TagFactory() {
// // nothing...
// }
//
// public Tag getTag(String tagName, String tagText, int startPosition) {
// if (Bold.NAME.equalsIgnoreCase(tagName)) {
// return new Bold(tagText, startPosition);
// }
// if (Italic.NAME.equalsIgnoreCase(tagName)) {
// return new Italic(tagText, startPosition);
// }
// if (Underline.NAME.equalsIgnoreCase(tagName)) {
// return new Underline(tagText, startPosition);
// }
// if (Strikethrough.NAME.equalsIgnoreCase(tagName)) {
// return new Strikethrough(tagText, startPosition);
// }
// if (Color.NAME.equalsIgnoreCase(tagName)) {
// return new Color(tagText, startPosition);
// }
// if (Link.NAME.equalsIgnoreCase(tagName)) {
// return new Link(tagText, startPosition);
// }
// if (Code.NAME.equalsIgnoreCase(tagName)) {
// return new Code(tagText, startPosition);
// }
// if (IntentTag.NAME.equalsIgnoreCase(tagName)) {
// return new IntentTag(tagText, startPosition);
// }
// if (DrawableTag.NAME.equalsIgnoreCase(tagName)) {
// return new DrawableTag(tagText, startPosition);
// }
// if (Superscript.NAME.equalsIgnoreCase(tagName)) {
// return new Superscript(tagText, startPosition);
// }
// if (Subscript.NAME.equalsIgnoreCase(tagName)) {
// return new Subscript(tagText, startPosition);
// }
// if (FontTag.NAME.equalsIgnoreCase(tagName)) {
// return new FontTag(tagText, startPosition);
// }
// if (mConstructorMap.containsKey(tagName.toLowerCase())) {
// try {
// return mConstructorMap.get(tagName.toLowerCase()).newInstance(tagText, startPosition);
// } catch (InstantiationException e) {
// throw new CouldNotCreateTagException(e, tagName);
// } catch (IllegalAccessException e) {
// throw new CouldNotCreateTagException(e, tagName);
// } catch (InvocationTargetException e) {
// throw new CouldNotCreateTagException(e, tagName);
// }
// }
// throw new BadTagException("Could not create Tag for {{" + tagText + "}} at position:" + startPosition);
// }
//
// public void registerTag(String tagName, Class<? extends Tag> tagClass) {
// try {
// mConstructorMap.put(tagName.toLowerCase(), tagClass.getConstructor(String.class, int.class));
// } catch (NoSuchMethodException e) {
// throw new CouldNotRegisterTagException(e, tagClass);
// }
// }
// }
// Path: library/src/main/java/co/jasonwyatt/srml/Transformer.java
import android.content.Context;
import co.jasonwyatt.srml.tags.TagFactory;
package co.jasonwyatt.srml;
/**
* Defines an object which is capable of transforming a given SRML-marked-up String into a
* styled/spanned CharSequence according to the tags used in the string.
* @author jason
*/
public interface Transformer {
CharSequence transform(Context context, String srmlString);
Sanitizer getSanitizer();
/**
* Get the {@link TagFactory} for the transformer.
*/ | TagFactory getTagFactory(); |
jasonwyatt/SRML | library/src/main/java/co/jasonwyatt/srml/DefaultSanitizer.java | // Path: library/src/main/java/co/jasonwyatt/srml/utils/SafeString.java
// public class SafeString implements CharSequence, Serializable {
// private final String mString;
//
// public SafeString(@NonNull String s) {
// mString = s;
// }
//
// public boolean isEmpty() {
// return mString.isEmpty();
// }
//
// /**
// * Returns the length of this SafeString. The length is the number
// * of 16-bit <code>char</code>s in the sequence.</p>
// *
// * @return the number of <code>char</code>s in this sequence
// */
// @Override
// public int length() {
// return mString.length();
// }
//
// /**
// * Returns the <code>char</code> value at the specified index. An index ranges from zero
// * to <tt>length() - 1</tt>. The first <code>char</code> value of the sequence is at
// * index zero, the next at index one, and so on, as for array
// * indexing. </p>
// *
// * <p>If the <code>char</code> value specified by the index is a
// * <a href="{@docRoot}/java/lang/Character.html#unicode">surrogate</a>, the surrogate
// * value is returned.
// *
// * @param index the index of the <code>char</code> value to be returned
// *
// * @return the specified <code>char</code> value
// *
// * @throws IndexOutOfBoundsException
// * if the <tt>index</tt> argument is negative or not less than
// * <tt>length()</tt>
// */
// @Override
// public char charAt(int index) {
// return mString.charAt(index);
// }
//
// /**
// * Returns a new <code>CharSequence</code> that is a subsequence of this sequence.
// * The subsequence starts with the <code>char</code> value at the specified index and
// * ends with the <code>char</code> value at index <tt>end - 1</tt>. The length
// * (in <code>char</code>s) of the
// * returned sequence is <tt>end - start</tt>, so if <tt>start == end</tt>
// * then an empty sequence is returned. </p>
// *
// * @param start the start index, inclusive
// * @param end the end index, exclusive
// *
// * @return the specified subsequence
// *
// * @throws IndexOutOfBoundsException
// * if <tt>start</tt> or <tt>end</tt> are negative,
// * if <tt>end</tt> is greater than <tt>length()</tt>,
// * or if <tt>start</tt> is greater than <tt>end</tt>
// */
// @Override
// public CharSequence subSequence(int start, int end) {
// return mString.subSequence(start, end);
// }
//
// /**
// * Returns a string containing the characters in this sequence in the same
// * order as this sequence. The length of the string will be the length of
// * this sequence. </p>
// *
// * @return a string consisting of exactly this sequence of characters
// */
// @Override
// public String toString() {
// return mString;
// }
//
// /**
// * Whether or not the provided object matches this SafeString.
// * @param obj Other object.
// * @return Whether or not the other object is a SafeString and its inner string value matches
// * ours.
// */
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof SafeString)) {
// return false;
// }
// SafeString other = (SafeString) obj;
// return other.mString.equals(mString);
// }
//
// /**
// * Get the hashCode for this SafeString.
// * @return The hashcode for the inner {@link String} value.
// */
// @Override
// public int hashCode() {
// return mString.hashCode();
// }
// }
| import java.util.regex.Matcher;
import java.util.regex.Pattern;
import co.jasonwyatt.srml.utils.SafeString; | package co.jasonwyatt.srml;
/**
* @author jason
*
* Sanitizes parameters for parameterized strings, and unsanitizes them later.
*/
public class DefaultSanitizer implements Sanitizer {
private static final Pattern SANITIZE_PATTERN = Pattern.compile("\\{{2}");
private static final Pattern DESANITIZE_PATTERN = Pattern.compile("\u0000{2}");
private static final String SANITIZE_REPLACEMENT = "\u0000\u0000";
private static final String DESANITIZE_REPLACEMENT = "{{";
public DefaultSanitizer() {
//
}
@Override
public Object[] sanitizeArgs(Object[] formatArgs) {
if (formatArgs == null) {
return null;
}
for (int i = 0; i < formatArgs.length; i++) { | // Path: library/src/main/java/co/jasonwyatt/srml/utils/SafeString.java
// public class SafeString implements CharSequence, Serializable {
// private final String mString;
//
// public SafeString(@NonNull String s) {
// mString = s;
// }
//
// public boolean isEmpty() {
// return mString.isEmpty();
// }
//
// /**
// * Returns the length of this SafeString. The length is the number
// * of 16-bit <code>char</code>s in the sequence.</p>
// *
// * @return the number of <code>char</code>s in this sequence
// */
// @Override
// public int length() {
// return mString.length();
// }
//
// /**
// * Returns the <code>char</code> value at the specified index. An index ranges from zero
// * to <tt>length() - 1</tt>. The first <code>char</code> value of the sequence is at
// * index zero, the next at index one, and so on, as for array
// * indexing. </p>
// *
// * <p>If the <code>char</code> value specified by the index is a
// * <a href="{@docRoot}/java/lang/Character.html#unicode">surrogate</a>, the surrogate
// * value is returned.
// *
// * @param index the index of the <code>char</code> value to be returned
// *
// * @return the specified <code>char</code> value
// *
// * @throws IndexOutOfBoundsException
// * if the <tt>index</tt> argument is negative or not less than
// * <tt>length()</tt>
// */
// @Override
// public char charAt(int index) {
// return mString.charAt(index);
// }
//
// /**
// * Returns a new <code>CharSequence</code> that is a subsequence of this sequence.
// * The subsequence starts with the <code>char</code> value at the specified index and
// * ends with the <code>char</code> value at index <tt>end - 1</tt>. The length
// * (in <code>char</code>s) of the
// * returned sequence is <tt>end - start</tt>, so if <tt>start == end</tt>
// * then an empty sequence is returned. </p>
// *
// * @param start the start index, inclusive
// * @param end the end index, exclusive
// *
// * @return the specified subsequence
// *
// * @throws IndexOutOfBoundsException
// * if <tt>start</tt> or <tt>end</tt> are negative,
// * if <tt>end</tt> is greater than <tt>length()</tt>,
// * or if <tt>start</tt> is greater than <tt>end</tt>
// */
// @Override
// public CharSequence subSequence(int start, int end) {
// return mString.subSequence(start, end);
// }
//
// /**
// * Returns a string containing the characters in this sequence in the same
// * order as this sequence. The length of the string will be the length of
// * this sequence. </p>
// *
// * @return a string consisting of exactly this sequence of characters
// */
// @Override
// public String toString() {
// return mString;
// }
//
// /**
// * Whether or not the provided object matches this SafeString.
// * @param obj Other object.
// * @return Whether or not the other object is a SafeString and its inner string value matches
// * ours.
// */
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof SafeString)) {
// return false;
// }
// SafeString other = (SafeString) obj;
// return other.mString.equals(mString);
// }
//
// /**
// * Get the hashCode for this SafeString.
// * @return The hashcode for the inner {@link String} value.
// */
// @Override
// public int hashCode() {
// return mString.hashCode();
// }
// }
// Path: library/src/main/java/co/jasonwyatt/srml/DefaultSanitizer.java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import co.jasonwyatt.srml.utils.SafeString;
package co.jasonwyatt.srml;
/**
* @author jason
*
* Sanitizes parameters for parameterized strings, and unsanitizes them later.
*/
public class DefaultSanitizer implements Sanitizer {
private static final Pattern SANITIZE_PATTERN = Pattern.compile("\\{{2}");
private static final Pattern DESANITIZE_PATTERN = Pattern.compile("\u0000{2}");
private static final String SANITIZE_REPLACEMENT = "\u0000\u0000";
private static final String DESANITIZE_REPLACEMENT = "{{";
public DefaultSanitizer() {
//
}
@Override
public Object[] sanitizeArgs(Object[] formatArgs) {
if (formatArgs == null) {
return null;
}
for (int i = 0; i < formatArgs.length; i++) { | if (formatArgs[i] instanceof CharSequence && !(formatArgs[i] instanceof SafeString)) { |
jasonwyatt/SRML | app/src/main/java/co/jasonwyatt/srmldemoapp/App.java | // Path: library/src/main/java/co/jasonwyatt/srml/SRML.java
// public final class SRML {
// private static Transformer sTransformer;
//
// static {
// configure(new DefaultTransformer(), null);
// }
//
// private SRML() {
// // no outside instantiation needed plz
// }
//
// /**
// * Supply a {@link Transformer} for SRML.
// * @param transformer The new transformer.
// * @param imageLoader An {@link SRMLImageLoader} for SRML.
// */
// public static void configure(Transformer transformer, SRMLImageLoader imageLoader) {
// sTransformer = transformer;
// setImageLoader(imageLoader);
// }
//
// /**
// * Set an image loader for SRML.
// * @param imageLoader The new image loader.
// */
// public static void setImageLoader(SRMLImageLoader imageLoader) {
// Utils.setImageLoader(imageLoader);
// }
//
// /**
// * Register a new {@link Tag} type with SRML.
// * @param name The tag's name, aka: the first part in a tag after the <code>{{</code> or <code>{{/</code>
// * @param tagClass The class for an implementation of {@link Tag}
// */
// public static void registerTag(String name, Class<? extends Tag> tagClass) {
// sTransformer.getTagFactory().registerTag(name, tagClass);
// }
//
// /**
// * Analog of {@link Context#getString(int)} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId) {
// return getString(context, sTransformer, resId);
// }
//
// /**
// * Analog of {@link Context#getString(int, Object[])} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @param formatArgs Format arguments for the string, passed along to {@link Context#getString(int, Object[]}
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId, Object... formatArgs) {
// return getString(context, sTransformer, resId, formatArgs);
// }
//
// public static CharSequence[] getStringArray(Context context, @ArrayRes int resId) {
// return getStringArray(context, sTransformer, resId);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity) {
// return getQuantityString(context, sTransformer, resId, quantity);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return getQuantityString(context, sTransformer, resId, quantity, formatArgs);
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId) {
// return transformer.transform(context, context.getString(resId));
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId, Object... formatArgs) {
// return transformer.transform(context, context.getString(resId, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// public static CharSequence[] getStringArray(Context context, Transformer transformer, @ArrayRes int resId) {
// String[] strings = context.getResources().getStringArray(resId);
// CharSequence[] result = new CharSequence[strings.length];
// for (int i = 0, len = result.length; i < len; i++) {
// result[i] = transformer.transform(context, strings[i]);
// }
// return result;
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity));
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// /**
// * Mark up a string with SRML.
// * @param context Current context
// * @param str String to mark up.
// * @return Marked-up CharSequence.
// */
// public static CharSequence markup(Context context, String str) {
// return sTransformer.transform(context, str);
// }
// }
//
// Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
// /**
// * Load the image at the given url and return it as a Bitmap.
// * @param context The current context.
// * @param url The image's url.
// * @return A bitmap of the image.
// */
// Bitmap loadImage(Context context, String url);
//
// /**
// * Load the image at the given url and return it as a Bitmap in the provided size..
// * @param context The current context.
// * @param url The image's url.
// * @param width Requested width of the image.
// * @param height Requested height of the image.
// * @return A bitmap.
// */
// Bitmap loadImage(Context context, String url, int width, int height);
// }
| import android.app.Application;
import android.content.Context;
import android.graphics.Bitmap;
import com.squareup.picasso.Picasso;
import java.io.IOException;
import co.jasonwyatt.srml.SRML;
import co.jasonwyatt.srml.SRMLImageLoader; | package co.jasonwyatt.srmldemoapp;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
| // Path: library/src/main/java/co/jasonwyatt/srml/SRML.java
// public final class SRML {
// private static Transformer sTransformer;
//
// static {
// configure(new DefaultTransformer(), null);
// }
//
// private SRML() {
// // no outside instantiation needed plz
// }
//
// /**
// * Supply a {@link Transformer} for SRML.
// * @param transformer The new transformer.
// * @param imageLoader An {@link SRMLImageLoader} for SRML.
// */
// public static void configure(Transformer transformer, SRMLImageLoader imageLoader) {
// sTransformer = transformer;
// setImageLoader(imageLoader);
// }
//
// /**
// * Set an image loader for SRML.
// * @param imageLoader The new image loader.
// */
// public static void setImageLoader(SRMLImageLoader imageLoader) {
// Utils.setImageLoader(imageLoader);
// }
//
// /**
// * Register a new {@link Tag} type with SRML.
// * @param name The tag's name, aka: the first part in a tag after the <code>{{</code> or <code>{{/</code>
// * @param tagClass The class for an implementation of {@link Tag}
// */
// public static void registerTag(String name, Class<? extends Tag> tagClass) {
// sTransformer.getTagFactory().registerTag(name, tagClass);
// }
//
// /**
// * Analog of {@link Context#getString(int)} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId) {
// return getString(context, sTransformer, resId);
// }
//
// /**
// * Analog of {@link Context#getString(int, Object[])} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @param formatArgs Format arguments for the string, passed along to {@link Context#getString(int, Object[]}
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId, Object... formatArgs) {
// return getString(context, sTransformer, resId, formatArgs);
// }
//
// public static CharSequence[] getStringArray(Context context, @ArrayRes int resId) {
// return getStringArray(context, sTransformer, resId);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity) {
// return getQuantityString(context, sTransformer, resId, quantity);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return getQuantityString(context, sTransformer, resId, quantity, formatArgs);
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId) {
// return transformer.transform(context, context.getString(resId));
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId, Object... formatArgs) {
// return transformer.transform(context, context.getString(resId, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// public static CharSequence[] getStringArray(Context context, Transformer transformer, @ArrayRes int resId) {
// String[] strings = context.getResources().getStringArray(resId);
// CharSequence[] result = new CharSequence[strings.length];
// for (int i = 0, len = result.length; i < len; i++) {
// result[i] = transformer.transform(context, strings[i]);
// }
// return result;
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity));
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// /**
// * Mark up a string with SRML.
// * @param context Current context
// * @param str String to mark up.
// * @return Marked-up CharSequence.
// */
// public static CharSequence markup(Context context, String str) {
// return sTransformer.transform(context, str);
// }
// }
//
// Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
// /**
// * Load the image at the given url and return it as a Bitmap.
// * @param context The current context.
// * @param url The image's url.
// * @return A bitmap of the image.
// */
// Bitmap loadImage(Context context, String url);
//
// /**
// * Load the image at the given url and return it as a Bitmap in the provided size..
// * @param context The current context.
// * @param url The image's url.
// * @param width Requested width of the image.
// * @param height Requested height of the image.
// * @return A bitmap.
// */
// Bitmap loadImage(Context context, String url, int width, int height);
// }
// Path: app/src/main/java/co/jasonwyatt/srmldemoapp/App.java
import android.app.Application;
import android.content.Context;
import android.graphics.Bitmap;
import com.squareup.picasso.Picasso;
import java.io.IOException;
import co.jasonwyatt.srml.SRML;
import co.jasonwyatt.srml.SRMLImageLoader;
package co.jasonwyatt.srmldemoapp;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
| SRML.setImageLoader(new SRMLImageLoader() { |
jasonwyatt/SRML | app/src/main/java/co/jasonwyatt/srmldemoapp/App.java | // Path: library/src/main/java/co/jasonwyatt/srml/SRML.java
// public final class SRML {
// private static Transformer sTransformer;
//
// static {
// configure(new DefaultTransformer(), null);
// }
//
// private SRML() {
// // no outside instantiation needed plz
// }
//
// /**
// * Supply a {@link Transformer} for SRML.
// * @param transformer The new transformer.
// * @param imageLoader An {@link SRMLImageLoader} for SRML.
// */
// public static void configure(Transformer transformer, SRMLImageLoader imageLoader) {
// sTransformer = transformer;
// setImageLoader(imageLoader);
// }
//
// /**
// * Set an image loader for SRML.
// * @param imageLoader The new image loader.
// */
// public static void setImageLoader(SRMLImageLoader imageLoader) {
// Utils.setImageLoader(imageLoader);
// }
//
// /**
// * Register a new {@link Tag} type with SRML.
// * @param name The tag's name, aka: the first part in a tag after the <code>{{</code> or <code>{{/</code>
// * @param tagClass The class for an implementation of {@link Tag}
// */
// public static void registerTag(String name, Class<? extends Tag> tagClass) {
// sTransformer.getTagFactory().registerTag(name, tagClass);
// }
//
// /**
// * Analog of {@link Context#getString(int)} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId) {
// return getString(context, sTransformer, resId);
// }
//
// /**
// * Analog of {@link Context#getString(int, Object[])} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @param formatArgs Format arguments for the string, passed along to {@link Context#getString(int, Object[]}
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId, Object... formatArgs) {
// return getString(context, sTransformer, resId, formatArgs);
// }
//
// public static CharSequence[] getStringArray(Context context, @ArrayRes int resId) {
// return getStringArray(context, sTransformer, resId);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity) {
// return getQuantityString(context, sTransformer, resId, quantity);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return getQuantityString(context, sTransformer, resId, quantity, formatArgs);
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId) {
// return transformer.transform(context, context.getString(resId));
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId, Object... formatArgs) {
// return transformer.transform(context, context.getString(resId, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// public static CharSequence[] getStringArray(Context context, Transformer transformer, @ArrayRes int resId) {
// String[] strings = context.getResources().getStringArray(resId);
// CharSequence[] result = new CharSequence[strings.length];
// for (int i = 0, len = result.length; i < len; i++) {
// result[i] = transformer.transform(context, strings[i]);
// }
// return result;
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity));
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// /**
// * Mark up a string with SRML.
// * @param context Current context
// * @param str String to mark up.
// * @return Marked-up CharSequence.
// */
// public static CharSequence markup(Context context, String str) {
// return sTransformer.transform(context, str);
// }
// }
//
// Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
// /**
// * Load the image at the given url and return it as a Bitmap.
// * @param context The current context.
// * @param url The image's url.
// * @return A bitmap of the image.
// */
// Bitmap loadImage(Context context, String url);
//
// /**
// * Load the image at the given url and return it as a Bitmap in the provided size..
// * @param context The current context.
// * @param url The image's url.
// * @param width Requested width of the image.
// * @param height Requested height of the image.
// * @return A bitmap.
// */
// Bitmap loadImage(Context context, String url, int width, int height);
// }
| import android.app.Application;
import android.content.Context;
import android.graphics.Bitmap;
import com.squareup.picasso.Picasso;
import java.io.IOException;
import co.jasonwyatt.srml.SRML;
import co.jasonwyatt.srml.SRMLImageLoader; | package co.jasonwyatt.srmldemoapp;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
| // Path: library/src/main/java/co/jasonwyatt/srml/SRML.java
// public final class SRML {
// private static Transformer sTransformer;
//
// static {
// configure(new DefaultTransformer(), null);
// }
//
// private SRML() {
// // no outside instantiation needed plz
// }
//
// /**
// * Supply a {@link Transformer} for SRML.
// * @param transformer The new transformer.
// * @param imageLoader An {@link SRMLImageLoader} for SRML.
// */
// public static void configure(Transformer transformer, SRMLImageLoader imageLoader) {
// sTransformer = transformer;
// setImageLoader(imageLoader);
// }
//
// /**
// * Set an image loader for SRML.
// * @param imageLoader The new image loader.
// */
// public static void setImageLoader(SRMLImageLoader imageLoader) {
// Utils.setImageLoader(imageLoader);
// }
//
// /**
// * Register a new {@link Tag} type with SRML.
// * @param name The tag's name, aka: the first part in a tag after the <code>{{</code> or <code>{{/</code>
// * @param tagClass The class for an implementation of {@link Tag}
// */
// public static void registerTag(String name, Class<? extends Tag> tagClass) {
// sTransformer.getTagFactory().registerTag(name, tagClass);
// }
//
// /**
// * Analog of {@link Context#getString(int)} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId) {
// return getString(context, sTransformer, resId);
// }
//
// /**
// * Analog of {@link Context#getString(int, Object[])} for SRML.
// * @param context Context to retrieve the string resource from.
// * @param resId String resource.
// * @param formatArgs Format arguments for the string, passed along to {@link Context#getString(int, Object[]}
// * @return The templatized string.
// */
// public static CharSequence getString(Context context, @StringRes int resId, Object... formatArgs) {
// return getString(context, sTransformer, resId, formatArgs);
// }
//
// public static CharSequence[] getStringArray(Context context, @ArrayRes int resId) {
// return getStringArray(context, sTransformer, resId);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity) {
// return getQuantityString(context, sTransformer, resId, quantity);
// }
//
// public static CharSequence getQuantityString(Context context, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return getQuantityString(context, sTransformer, resId, quantity, formatArgs);
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId) {
// return transformer.transform(context, context.getString(resId));
// }
//
// public static CharSequence getString(Context context, Transformer transformer, @StringRes int resId, Object... formatArgs) {
// return transformer.transform(context, context.getString(resId, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// public static CharSequence[] getStringArray(Context context, Transformer transformer, @ArrayRes int resId) {
// String[] strings = context.getResources().getStringArray(resId);
// CharSequence[] result = new CharSequence[strings.length];
// for (int i = 0, len = result.length; i < len; i++) {
// result[i] = transformer.transform(context, strings[i]);
// }
// return result;
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity));
// }
//
// public static CharSequence getQuantityString(Context context, Transformer transformer, @PluralsRes int resId, int quantity, Object... formatArgs) {
// return transformer.transform(context, context.getResources().getQuantityString(resId, quantity, transformer.getSanitizer().sanitizeArgs(formatArgs)));
// }
//
// /**
// * Mark up a string with SRML.
// * @param context Current context
// * @param str String to mark up.
// * @return Marked-up CharSequence.
// */
// public static CharSequence markup(Context context, String str) {
// return sTransformer.transform(context, str);
// }
// }
//
// Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
// /**
// * Load the image at the given url and return it as a Bitmap.
// * @param context The current context.
// * @param url The image's url.
// * @return A bitmap of the image.
// */
// Bitmap loadImage(Context context, String url);
//
// /**
// * Load the image at the given url and return it as a Bitmap in the provided size..
// * @param context The current context.
// * @param url The image's url.
// * @param width Requested width of the image.
// * @param height Requested height of the image.
// * @return A bitmap.
// */
// Bitmap loadImage(Context context, String url, int width, int height);
// }
// Path: app/src/main/java/co/jasonwyatt/srmldemoapp/App.java
import android.app.Application;
import android.content.Context;
import android.graphics.Bitmap;
import com.squareup.picasso.Picasso;
import java.io.IOException;
import co.jasonwyatt.srml.SRML;
import co.jasonwyatt.srml.SRMLImageLoader;
package co.jasonwyatt.srmldemoapp;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
| SRML.setImageLoader(new SRMLImageLoader() { |
jasonwyatt/SRML | library/src/main/java/co/jasonwyatt/srml/utils/Utils.java | // Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
// /**
// * Load the image at the given url and return it as a Bitmap.
// * @param context The current context.
// * @param url The image's url.
// * @return A bitmap of the image.
// */
// Bitmap loadImage(Context context, String url);
//
// /**
// * Load the image at the given url and return it as a Bitmap in the provided size..
// * @param context The current context.
// * @param url The image's url.
// * @param width Requested width of the image.
// * @param height Requested height of the image.
// * @return A bitmap.
// */
// Bitmap loadImage(Context context, String url, int width, int height);
// }
//
// Path: library/src/main/java/co/jasonwyatt/srml/tags/BadParameterException.java
// public class BadParameterException extends RuntimeException {
// public BadParameterException(String message) {
// super(message);
// }
//
// public BadParameterException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.DisplayMetrics;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import co.jasonwyatt.srml.SRMLImageLoader;
import co.jasonwyatt.srml.tags.BadParameterException; | package co.jasonwyatt.srml.utils;
/**
* @author jason
*
* General utilities.
*/
public class Utils {
private static final Pattern SIZE_PATTERN = Pattern.compile("([0-9]+(\\.[0-9]+)?)(sp|dp|px)?", Pattern.CASE_INSENSITIVE);
private static final Pattern COLOR_VALUE_PATTERN = Pattern.compile("^#([0-9a-f]+)$", Pattern.CASE_INSENSITIVE);
private static final Map<String, Integer> sIdentifierCache = new HashMap<>(100); | // Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
// /**
// * Load the image at the given url and return it as a Bitmap.
// * @param context The current context.
// * @param url The image's url.
// * @return A bitmap of the image.
// */
// Bitmap loadImage(Context context, String url);
//
// /**
// * Load the image at the given url and return it as a Bitmap in the provided size..
// * @param context The current context.
// * @param url The image's url.
// * @param width Requested width of the image.
// * @param height Requested height of the image.
// * @return A bitmap.
// */
// Bitmap loadImage(Context context, String url, int width, int height);
// }
//
// Path: library/src/main/java/co/jasonwyatt/srml/tags/BadParameterException.java
// public class BadParameterException extends RuntimeException {
// public BadParameterException(String message) {
// super(message);
// }
//
// public BadParameterException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: library/src/main/java/co/jasonwyatt/srml/utils/Utils.java
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.DisplayMetrics;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import co.jasonwyatt.srml.SRMLImageLoader;
import co.jasonwyatt.srml.tags.BadParameterException;
package co.jasonwyatt.srml.utils;
/**
* @author jason
*
* General utilities.
*/
public class Utils {
private static final Pattern SIZE_PATTERN = Pattern.compile("([0-9]+(\\.[0-9]+)?)(sp|dp|px)?", Pattern.CASE_INSENSITIVE);
private static final Pattern COLOR_VALUE_PATTERN = Pattern.compile("^#([0-9a-f]+)$", Pattern.CASE_INSENSITIVE);
private static final Map<String, Integer> sIdentifierCache = new HashMap<>(100); | private static SRMLImageLoader sImageLoader; |
jasonwyatt/SRML | library/src/main/java/co/jasonwyatt/srml/utils/Utils.java | // Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
// /**
// * Load the image at the given url and return it as a Bitmap.
// * @param context The current context.
// * @param url The image's url.
// * @return A bitmap of the image.
// */
// Bitmap loadImage(Context context, String url);
//
// /**
// * Load the image at the given url and return it as a Bitmap in the provided size..
// * @param context The current context.
// * @param url The image's url.
// * @param width Requested width of the image.
// * @param height Requested height of the image.
// * @return A bitmap.
// */
// Bitmap loadImage(Context context, String url, int width, int height);
// }
//
// Path: library/src/main/java/co/jasonwyatt/srml/tags/BadParameterException.java
// public class BadParameterException extends RuntimeException {
// public BadParameterException(String message) {
// super(message);
// }
//
// public BadParameterException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.DisplayMetrics;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import co.jasonwyatt.srml.SRMLImageLoader;
import co.jasonwyatt.srml.tags.BadParameterException; |
/**
* Parses a color value hex string into its integer representation. If it's not a hex string, it
* tries to interpret {@param colorValue} as a resource identifier.
*
* @throws {@link NumberFormatException} if {@param colorValue} was not a hex string.
* @throws {@link BadParameterException} if the color value could not be parsed.
* @return Color int value.
*/
public static int getColorInt(String colorValue) {
Matcher m = COLOR_VALUE_PATTERN.matcher(colorValue);
if (!m.find()) {
throw new NumberFormatException();
}
colorValue = m.group(1);
int colorLength = colorValue.length();
if (colorLength == 3) {
int raw = Integer.parseInt(colorValue, 16);
// 0xFFFFFF
int first = (raw & 0xF00) >> 8;
int second = (raw & 0x0F0) >> 4;
int third = raw & 0x00F;
return (0xFF << 24) | (first << 20) | (first << 16) | (second << 12) | (second << 8) | (third << 4) | third;
} else if (colorLength == 6) {
return (0xFF << 24) | Integer.parseInt(colorValue, 16);
} else if (colorLength == 8) {
return (int) Long.parseLong(colorValue, 16);
} | // Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
// /**
// * Load the image at the given url and return it as a Bitmap.
// * @param context The current context.
// * @param url The image's url.
// * @return A bitmap of the image.
// */
// Bitmap loadImage(Context context, String url);
//
// /**
// * Load the image at the given url and return it as a Bitmap in the provided size..
// * @param context The current context.
// * @param url The image's url.
// * @param width Requested width of the image.
// * @param height Requested height of the image.
// * @return A bitmap.
// */
// Bitmap loadImage(Context context, String url, int width, int height);
// }
//
// Path: library/src/main/java/co/jasonwyatt/srml/tags/BadParameterException.java
// public class BadParameterException extends RuntimeException {
// public BadParameterException(String message) {
// super(message);
// }
//
// public BadParameterException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: library/src/main/java/co/jasonwyatt/srml/utils/Utils.java
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.DisplayMetrics;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import co.jasonwyatt.srml.SRMLImageLoader;
import co.jasonwyatt.srml.tags.BadParameterException;
/**
* Parses a color value hex string into its integer representation. If it's not a hex string, it
* tries to interpret {@param colorValue} as a resource identifier.
*
* @throws {@link NumberFormatException} if {@param colorValue} was not a hex string.
* @throws {@link BadParameterException} if the color value could not be parsed.
* @return Color int value.
*/
public static int getColorInt(String colorValue) {
Matcher m = COLOR_VALUE_PATTERN.matcher(colorValue);
if (!m.find()) {
throw new NumberFormatException();
}
colorValue = m.group(1);
int colorLength = colorValue.length();
if (colorLength == 3) {
int raw = Integer.parseInt(colorValue, 16);
// 0xFFFFFF
int first = (raw & 0xF00) >> 8;
int second = (raw & 0x0F0) >> 4;
int third = raw & 0x00F;
return (0xFF << 24) | (first << 20) | (first << 16) | (second << 12) | (second << 8) | (third << 4) | third;
} else if (colorLength == 6) {
return (0xFF << 24) | Integer.parseInt(colorValue, 16);
} else if (colorLength == 8) {
return (int) Long.parseLong(colorValue, 16);
} | throw new BadParameterException("could not parse color value: "+colorValue); |
telefonicaid/fiware-keypass | src/test/java/es/tid/fiware/iot/ac/xacml/PDPFactoryTest.java | // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
| import es.tid.fiware.iot.ac.util.Util;
import es.tid.fiware.iot.ac.util.Xml;
import org.testng.annotations.Test;
import org.wso2.balana.ParsingException;
import org.wso2.balana.Policy;
import org.wso2.balana.AbstractPolicy;
import static org.testng.AssertJUnit.assertEquals; | package es.tid.fiware.iot.ac.xacml;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
public class PDPFactoryTest {
@Test
public void testCreateValid() throws Exception { | // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
// Path: src/test/java/es/tid/fiware/iot/ac/xacml/PDPFactoryTest.java
import es.tid.fiware.iot.ac.util.Util;
import es.tid.fiware.iot.ac.util.Xml;
import org.testng.annotations.Test;
import org.wso2.balana.ParsingException;
import org.wso2.balana.Policy;
import org.wso2.balana.AbstractPolicy;
import static org.testng.AssertJUnit.assertEquals;
package es.tid.fiware.iot.ac.xacml;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
public class PDPFactoryTest {
@Test
public void testCreateValid() throws Exception { | AbstractPolicy p = new PDPFactory().create(Xml.toXml( |
telefonicaid/fiware-keypass | src/test/java/es/tid/fiware/iot/ac/xacml/PDPFactoryTest.java | // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
| import es.tid.fiware.iot.ac.util.Util;
import es.tid.fiware.iot.ac.util.Xml;
import org.testng.annotations.Test;
import org.wso2.balana.ParsingException;
import org.wso2.balana.Policy;
import org.wso2.balana.AbstractPolicy;
import static org.testng.AssertJUnit.assertEquals; | package es.tid.fiware.iot.ac.xacml;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
public class PDPFactoryTest {
@Test
public void testCreateValid() throws Exception {
AbstractPolicy p = new PDPFactory().create(Xml.toXml( | // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
// Path: src/test/java/es/tid/fiware/iot/ac/xacml/PDPFactoryTest.java
import es.tid.fiware.iot.ac.util.Util;
import es.tid.fiware.iot.ac.util.Xml;
import org.testng.annotations.Test;
import org.wso2.balana.ParsingException;
import org.wso2.balana.Policy;
import org.wso2.balana.AbstractPolicy;
import static org.testng.AssertJUnit.assertEquals;
package es.tid.fiware.iot.ac.xacml;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
public class PDPFactoryTest {
@Test
public void testCreateValid() throws Exception {
AbstractPolicy p = new PDPFactory().create(Xml.toXml( | Util.read(this.getClass(), "policy01.xml"))); |
telefonicaid/fiware-keypass | src/main/java/es/tid/fiware/iot/ac/pap/PoliciesEndpoint.java | // Path: src/main/java/es/tid/fiware/iot/ac/dao/PolicyDao.java
// public interface PolicyDao {
//
// Policy createPolicy(Policy policy);
//
// Policy loadPolicy(String tenant, String subject, String id);
//
// Collection<Policy> getPolicies(String tenant, String subject);
//
// Policy updatePolicy(Policy policy);
//
// Policy deletePolicy(Policy policy);
//
// /**
// * Removes the Tenant and all related objects: Tenant's Subjects and
// * Policies.
// */
// void deleteFromTenant(String tenant);
//
// /**
// * Removes the Subject from the Tenant, and its Policies.
// */
// void deleteFromSubject(String tenant, String subject);
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/model/Policy.java
// @Entity
// public class Policy {
//
// @Embeddable
// public static class PolicyId implements Serializable {
// private String id;
// private String tenant;
//
// public PolicyId() {
//
// }
//
// public PolicyId(String tenant, String id) {
// this.id = id;
// this.tenant = tenant;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTenant() {
// return tenant;
// }
// }
//
// @EmbeddedId
// private PolicyId internalId;
// private String subject;
//
// private String policy;
//
// public Policy() {
//
// }
//
// public Policy(String id, String tenant, String subject, String policy) {
// this.internalId = new PolicyId(tenant, id);
// this.subject = subject;
// this.policy = policy;
// }
//
// public String getId() {
// return internalId.getId();
// }
//
// public PolicyId getInternalId() {
// return internalId;
// }
//
// public void setInternalId(PolicyId id) {
// internalId = id;
// }
//
// public String getTenant() {
// return internalId.getTenant();
// }
//
// public String getSubject() {
// return subject;
// }
//
// public String getPolicy() {
// return policy;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import es.tid.fiware.iot.ac.dao.PolicyDao;
import es.tid.fiware.iot.ac.model.Policy;
import es.tid.fiware.iot.ac.rs.Tenant;
import es.tid.fiware.iot.ac.rs.Correlator;
import io.dropwizard.hibernate.UnitOfWork;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; | package es.tid.fiware.iot.ac.pap;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@Path("/pap/v1/subject/{subject}/policy/{policyId}")
@Produces(MediaType.APPLICATION_XML)
public class PoliciesEndpoint {
private static final Logger LOGGER = LoggerFactory.getLogger(PoliciesEndpoint.class);
| // Path: src/main/java/es/tid/fiware/iot/ac/dao/PolicyDao.java
// public interface PolicyDao {
//
// Policy createPolicy(Policy policy);
//
// Policy loadPolicy(String tenant, String subject, String id);
//
// Collection<Policy> getPolicies(String tenant, String subject);
//
// Policy updatePolicy(Policy policy);
//
// Policy deletePolicy(Policy policy);
//
// /**
// * Removes the Tenant and all related objects: Tenant's Subjects and
// * Policies.
// */
// void deleteFromTenant(String tenant);
//
// /**
// * Removes the Subject from the Tenant, and its Policies.
// */
// void deleteFromSubject(String tenant, String subject);
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/model/Policy.java
// @Entity
// public class Policy {
//
// @Embeddable
// public static class PolicyId implements Serializable {
// private String id;
// private String tenant;
//
// public PolicyId() {
//
// }
//
// public PolicyId(String tenant, String id) {
// this.id = id;
// this.tenant = tenant;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTenant() {
// return tenant;
// }
// }
//
// @EmbeddedId
// private PolicyId internalId;
// private String subject;
//
// private String policy;
//
// public Policy() {
//
// }
//
// public Policy(String id, String tenant, String subject, String policy) {
// this.internalId = new PolicyId(tenant, id);
// this.subject = subject;
// this.policy = policy;
// }
//
// public String getId() {
// return internalId.getId();
// }
//
// public PolicyId getInternalId() {
// return internalId;
// }
//
// public void setInternalId(PolicyId id) {
// internalId = id;
// }
//
// public String getTenant() {
// return internalId.getTenant();
// }
//
// public String getSubject() {
// return subject;
// }
//
// public String getPolicy() {
// return policy;
// }
//
// }
// Path: src/main/java/es/tid/fiware/iot/ac/pap/PoliciesEndpoint.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import es.tid.fiware.iot.ac.dao.PolicyDao;
import es.tid.fiware.iot.ac.model.Policy;
import es.tid.fiware.iot.ac.rs.Tenant;
import es.tid.fiware.iot.ac.rs.Correlator;
import io.dropwizard.hibernate.UnitOfWork;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
package es.tid.fiware.iot.ac.pap;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@Path("/pap/v1/subject/{subject}/policy/{policyId}")
@Produces(MediaType.APPLICATION_XML)
public class PoliciesEndpoint {
private static final Logger LOGGER = LoggerFactory.getLogger(PoliciesEndpoint.class);
| private PolicyDao dao; |
telefonicaid/fiware-keypass | src/main/java/es/tid/fiware/iot/ac/pap/PoliciesEndpoint.java | // Path: src/main/java/es/tid/fiware/iot/ac/dao/PolicyDao.java
// public interface PolicyDao {
//
// Policy createPolicy(Policy policy);
//
// Policy loadPolicy(String tenant, String subject, String id);
//
// Collection<Policy> getPolicies(String tenant, String subject);
//
// Policy updatePolicy(Policy policy);
//
// Policy deletePolicy(Policy policy);
//
// /**
// * Removes the Tenant and all related objects: Tenant's Subjects and
// * Policies.
// */
// void deleteFromTenant(String tenant);
//
// /**
// * Removes the Subject from the Tenant, and its Policies.
// */
// void deleteFromSubject(String tenant, String subject);
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/model/Policy.java
// @Entity
// public class Policy {
//
// @Embeddable
// public static class PolicyId implements Serializable {
// private String id;
// private String tenant;
//
// public PolicyId() {
//
// }
//
// public PolicyId(String tenant, String id) {
// this.id = id;
// this.tenant = tenant;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTenant() {
// return tenant;
// }
// }
//
// @EmbeddedId
// private PolicyId internalId;
// private String subject;
//
// private String policy;
//
// public Policy() {
//
// }
//
// public Policy(String id, String tenant, String subject, String policy) {
// this.internalId = new PolicyId(tenant, id);
// this.subject = subject;
// this.policy = policy;
// }
//
// public String getId() {
// return internalId.getId();
// }
//
// public PolicyId getInternalId() {
// return internalId;
// }
//
// public void setInternalId(PolicyId id) {
// internalId = id;
// }
//
// public String getTenant() {
// return internalId.getTenant();
// }
//
// public String getSubject() {
// return subject;
// }
//
// public String getPolicy() {
// return policy;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import es.tid.fiware.iot.ac.dao.PolicyDao;
import es.tid.fiware.iot.ac.model.Policy;
import es.tid.fiware.iot.ac.rs.Tenant;
import es.tid.fiware.iot.ac.rs.Correlator;
import io.dropwizard.hibernate.UnitOfWork;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; | package es.tid.fiware.iot.ac.pap;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@Path("/pap/v1/subject/{subject}/policy/{policyId}")
@Produces(MediaType.APPLICATION_XML)
public class PoliciesEndpoint {
private static final Logger LOGGER = LoggerFactory.getLogger(PoliciesEndpoint.class);
private PolicyDao dao;
public PoliciesEndpoint(PolicyDao dao) {
this.dao = dao;
}
@GET
@UnitOfWork
public Response getPolicy(@Tenant String tenant,
@Correlator String correlator,
@PathParam("subject") String subject,
@PathParam("policyId") String policyId) {
LOGGER.debug("Getting policy with id [{}] for [{}] and subject [{}]", policyId, tenant, subject);
String id = URLEncoding.decode(policyId);
| // Path: src/main/java/es/tid/fiware/iot/ac/dao/PolicyDao.java
// public interface PolicyDao {
//
// Policy createPolicy(Policy policy);
//
// Policy loadPolicy(String tenant, String subject, String id);
//
// Collection<Policy> getPolicies(String tenant, String subject);
//
// Policy updatePolicy(Policy policy);
//
// Policy deletePolicy(Policy policy);
//
// /**
// * Removes the Tenant and all related objects: Tenant's Subjects and
// * Policies.
// */
// void deleteFromTenant(String tenant);
//
// /**
// * Removes the Subject from the Tenant, and its Policies.
// */
// void deleteFromSubject(String tenant, String subject);
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/model/Policy.java
// @Entity
// public class Policy {
//
// @Embeddable
// public static class PolicyId implements Serializable {
// private String id;
// private String tenant;
//
// public PolicyId() {
//
// }
//
// public PolicyId(String tenant, String id) {
// this.id = id;
// this.tenant = tenant;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTenant() {
// return tenant;
// }
// }
//
// @EmbeddedId
// private PolicyId internalId;
// private String subject;
//
// private String policy;
//
// public Policy() {
//
// }
//
// public Policy(String id, String tenant, String subject, String policy) {
// this.internalId = new PolicyId(tenant, id);
// this.subject = subject;
// this.policy = policy;
// }
//
// public String getId() {
// return internalId.getId();
// }
//
// public PolicyId getInternalId() {
// return internalId;
// }
//
// public void setInternalId(PolicyId id) {
// internalId = id;
// }
//
// public String getTenant() {
// return internalId.getTenant();
// }
//
// public String getSubject() {
// return subject;
// }
//
// public String getPolicy() {
// return policy;
// }
//
// }
// Path: src/main/java/es/tid/fiware/iot/ac/pap/PoliciesEndpoint.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import es.tid.fiware.iot.ac.dao.PolicyDao;
import es.tid.fiware.iot.ac.model.Policy;
import es.tid.fiware.iot.ac.rs.Tenant;
import es.tid.fiware.iot.ac.rs.Correlator;
import io.dropwizard.hibernate.UnitOfWork;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
package es.tid.fiware.iot.ac.pap;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@Path("/pap/v1/subject/{subject}/policy/{policyId}")
@Produces(MediaType.APPLICATION_XML)
public class PoliciesEndpoint {
private static final Logger LOGGER = LoggerFactory.getLogger(PoliciesEndpoint.class);
private PolicyDao dao;
public PoliciesEndpoint(PolicyDao dao) {
this.dao = dao;
}
@GET
@UnitOfWork
public Response getPolicy(@Tenant String tenant,
@Correlator String correlator,
@PathParam("subject") String subject,
@PathParam("policyId") String policyId) {
LOGGER.debug("Getting policy with id [{}] for [{}] and subject [{}]", policyId, tenant, subject);
String id = URLEncoding.decode(policyId);
| Policy p = dao.loadPolicy(tenant, subject, id); |
telefonicaid/fiware-keypass | src/main/java/es/tid/fiware/iot/ac/xacml/Extractors.java | // Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
| import java.util.List;
import es.tid.fiware.iot.ac.util.Xml;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import javax.xml.xpath.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection; | package es.tid.fiware.iot.ac.xacml;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Some XACML utilities methods.
*/
public class Extractors {
// XPath is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
private static XPathExpression decisionExp() {
return buildExp("//*[local-name()='Decision']/text()");
}
private static XPathExpression sujectIdsExp() {
return buildExp("//*[@AttributeId='urn:oasis:names:tc:xacml:1.0:subject:subject-id']/*[local-name()='AttributeValue']");
}
private static XPathExpression policyIdExp() {
return buildExp("//*[local-name()='Policy']/@PolicyId");
}
private static XPathExpression policysetIdExp() {
return buildExp("//*[local-name()='PolicySet']/@PolicySetId");
}
public static Collection<String> extractSubjectIds(String xacmlRequest)
throws XPathExpressionException, IOException, SAXException {
| // Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
// Path: src/main/java/es/tid/fiware/iot/ac/xacml/Extractors.java
import java.util.List;
import es.tid.fiware.iot.ac.util.Xml;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import javax.xml.xpath.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
package es.tid.fiware.iot.ac.xacml;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Some XACML utilities methods.
*/
public class Extractors {
// XPath is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
private static XPathExpression decisionExp() {
return buildExp("//*[local-name()='Decision']/text()");
}
private static XPathExpression sujectIdsExp() {
return buildExp("//*[@AttributeId='urn:oasis:names:tc:xacml:1.0:subject:subject-id']/*[local-name()='AttributeValue']");
}
private static XPathExpression policyIdExp() {
return buildExp("//*[local-name()='Policy']/@PolicyId");
}
private static XPathExpression policysetIdExp() {
return buildExp("//*[local-name()='PolicySet']/@PolicySetId");
}
public static Collection<String> extractSubjectIds(String xacmlRequest)
throws XPathExpressionException, IOException, SAXException {
| Document xacml = Xml.toXml(xacmlRequest); |
telefonicaid/fiware-keypass | src/main/java/es/tid/fiware/iot/ac/pdp/PdpEndpoint.java | // Path: src/main/java/es/tid/fiware/iot/ac/xacml/Extractors.java
// public class Extractors {
//
// // XPath is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static XPathExpression decisionExp() {
// return buildExp("//*[local-name()='Decision']/text()");
// }
//
// private static XPathExpression sujectIdsExp() {
// return buildExp("//*[@AttributeId='urn:oasis:names:tc:xacml:1.0:subject:subject-id']/*[local-name()='AttributeValue']");
// }
//
// private static XPathExpression policyIdExp() {
// return buildExp("//*[local-name()='Policy']/@PolicyId");
// }
//
// private static XPathExpression policysetIdExp() {
// return buildExp("//*[local-name()='PolicySet']/@PolicySetId");
// }
//
// public static Collection<String> extractSubjectIds(String xacmlRequest)
// throws XPathExpressionException, IOException, SAXException {
//
// Document xacml = Xml.toXml(xacmlRequest);
//
// NodeList nodes = (NodeList) sujectIdsExp().evaluate(xacml,
// XPathConstants.NODESET);
//
// List<String> subjects = new ArrayList<String>();
// for (int i = 0; i < nodes.getLength(); i++) {
// subjects.add(nodes.item(i).getTextContent());
// }
//
// return subjects;
// }
//
// public static String extractDecision(String xacmlRes)
// throws XPathExpressionException, IOException, SAXException {
// return decisionExp().evaluate(Xml.toXml(xacmlRes));
// }
//
// public static String extractPolicyId(String xacmlPolicy)
// throws XPathExpressionException, IOException, SAXException {
// return policyIdExp().evaluate(Xml.toXml(xacmlPolicy));
// }
//
// public static String extractPolicySetId(String xacmlPolicySet)
// throws XPathExpressionException, IOException, SAXException {
// return policysetIdExp().evaluate(Xml.toXml(xacmlPolicySet));
// }
//
// private static XPathExpression buildExp(String exp) {
// try {
// return XPathFactory.newInstance().newXPath().compile(exp);
// } catch (XPathExpressionException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
| import com.codahale.metrics.annotation.Timed;
import es.tid.fiware.iot.ac.rs.Tenant;
import es.tid.fiware.iot.ac.rs.Correlator;
import es.tid.fiware.iot.ac.xacml.Extractors;
import io.dropwizard.hibernate.UnitOfWork;
import java.io.IOException;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.wso2.balana.PDP;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.HashSet;
import java.util.Set;
import java.util.ArrayList;
import java.util.List;
import javax.xml.xpath.XPathExpressionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException; | LOGGER.debug("XACML Request subjectIds: {}", subjectIds);
String evaluation = null;
// Check if work in Pep-steelskin mode or not
if (pdpFactory.getSteelSkinPepMode()) {
// Iterate by all SubjectIs to evaluate by each subjectId
for (String subjectId : subjectIds) {
List<String> set_subjectId = new ArrayList<String>();
set_subjectId.add(subjectId);
PDP pdp = pdpFactory.get(tenant, new HashSet(set_subjectId));
evaluation = pdp.evaluate(xacmlRequest);
String response = extractDecision(evaluation);
LOGGER.debug("XACML partial evaluation for Role {} is {}",
subjectId, response);
if (response.equals("Permit")){
LOGGER.debug("XACML partial evaluation match for {}", subjectId);
LOGGER.debug("Skipping other subjects");
break;
}
}
} else {
PDP pdp = pdpFactory.get(tenant, extractSubjectIds(xacmlRequest));
evaluation = pdp.evaluate(xacmlRequest);
LOGGER.trace("XACML evaluation: {}", evaluation);
}
return Response.ok(evaluation).build();
}
private Set<String> extractSubjectIds(String xacmlRequest)
throws WebApplicationException {
try { | // Path: src/main/java/es/tid/fiware/iot/ac/xacml/Extractors.java
// public class Extractors {
//
// // XPath is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static XPathExpression decisionExp() {
// return buildExp("//*[local-name()='Decision']/text()");
// }
//
// private static XPathExpression sujectIdsExp() {
// return buildExp("//*[@AttributeId='urn:oasis:names:tc:xacml:1.0:subject:subject-id']/*[local-name()='AttributeValue']");
// }
//
// private static XPathExpression policyIdExp() {
// return buildExp("//*[local-name()='Policy']/@PolicyId");
// }
//
// private static XPathExpression policysetIdExp() {
// return buildExp("//*[local-name()='PolicySet']/@PolicySetId");
// }
//
// public static Collection<String> extractSubjectIds(String xacmlRequest)
// throws XPathExpressionException, IOException, SAXException {
//
// Document xacml = Xml.toXml(xacmlRequest);
//
// NodeList nodes = (NodeList) sujectIdsExp().evaluate(xacml,
// XPathConstants.NODESET);
//
// List<String> subjects = new ArrayList<String>();
// for (int i = 0; i < nodes.getLength(); i++) {
// subjects.add(nodes.item(i).getTextContent());
// }
//
// return subjects;
// }
//
// public static String extractDecision(String xacmlRes)
// throws XPathExpressionException, IOException, SAXException {
// return decisionExp().evaluate(Xml.toXml(xacmlRes));
// }
//
// public static String extractPolicyId(String xacmlPolicy)
// throws XPathExpressionException, IOException, SAXException {
// return policyIdExp().evaluate(Xml.toXml(xacmlPolicy));
// }
//
// public static String extractPolicySetId(String xacmlPolicySet)
// throws XPathExpressionException, IOException, SAXException {
// return policysetIdExp().evaluate(Xml.toXml(xacmlPolicySet));
// }
//
// private static XPathExpression buildExp(String exp) {
// try {
// return XPathFactory.newInstance().newXPath().compile(exp);
// } catch (XPathExpressionException e) {
// throw new RuntimeException(e);
// }
// }
//
// }
// Path: src/main/java/es/tid/fiware/iot/ac/pdp/PdpEndpoint.java
import com.codahale.metrics.annotation.Timed;
import es.tid.fiware.iot.ac.rs.Tenant;
import es.tid.fiware.iot.ac.rs.Correlator;
import es.tid.fiware.iot.ac.xacml.Extractors;
import io.dropwizard.hibernate.UnitOfWork;
import java.io.IOException;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.wso2.balana.PDP;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.HashSet;
import java.util.Set;
import java.util.ArrayList;
import java.util.List;
import javax.xml.xpath.XPathExpressionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
LOGGER.debug("XACML Request subjectIds: {}", subjectIds);
String evaluation = null;
// Check if work in Pep-steelskin mode or not
if (pdpFactory.getSteelSkinPepMode()) {
// Iterate by all SubjectIs to evaluate by each subjectId
for (String subjectId : subjectIds) {
List<String> set_subjectId = new ArrayList<String>();
set_subjectId.add(subjectId);
PDP pdp = pdpFactory.get(tenant, new HashSet(set_subjectId));
evaluation = pdp.evaluate(xacmlRequest);
String response = extractDecision(evaluation);
LOGGER.debug("XACML partial evaluation for Role {} is {}",
subjectId, response);
if (response.equals("Permit")){
LOGGER.debug("XACML partial evaluation match for {}", subjectId);
LOGGER.debug("Skipping other subjects");
break;
}
}
} else {
PDP pdp = pdpFactory.get(tenant, extractSubjectIds(xacmlRequest));
evaluation = pdp.evaluate(xacmlRequest);
LOGGER.trace("XACML evaluation: {}", evaluation);
}
return Response.ok(evaluation).build();
}
private Set<String> extractSubjectIds(String xacmlRequest)
throws WebApplicationException {
try { | return new HashSet(Extractors.extractSubjectIds(xacmlRequest)); |
telefonicaid/fiware-keypass | src/main/java/es/tid/fiware/iot/ac/pap/TenantEndpoint.java | // Path: src/main/java/es/tid/fiware/iot/ac/dao/PolicyDao.java
// public interface PolicyDao {
//
// Policy createPolicy(Policy policy);
//
// Policy loadPolicy(String tenant, String subject, String id);
//
// Collection<Policy> getPolicies(String tenant, String subject);
//
// Policy updatePolicy(Policy policy);
//
// Policy deletePolicy(Policy policy);
//
// /**
// * Removes the Tenant and all related objects: Tenant's Subjects and
// * Policies.
// */
// void deleteFromTenant(String tenant);
//
// /**
// * Removes the Subject from the Tenant, and its Policies.
// */
// void deleteFromSubject(String tenant, String subject);
// }
| import org.slf4j.LoggerFactory;
import es.tid.fiware.iot.ac.dao.PolicyDao;
import es.tid.fiware.iot.ac.rs.Tenant;
import es.tid.fiware.iot.ac.rs.Correlator;
import io.dropwizard.hibernate.UnitOfWork;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.slf4j.Logger; | package es.tid.fiware.iot.ac.pap;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Tenant Policy management.
*/
@Path("/pap/v1")
@Produces(MediaType.APPLICATION_XML)
public class TenantEndpoint {
| // Path: src/main/java/es/tid/fiware/iot/ac/dao/PolicyDao.java
// public interface PolicyDao {
//
// Policy createPolicy(Policy policy);
//
// Policy loadPolicy(String tenant, String subject, String id);
//
// Collection<Policy> getPolicies(String tenant, String subject);
//
// Policy updatePolicy(Policy policy);
//
// Policy deletePolicy(Policy policy);
//
// /**
// * Removes the Tenant and all related objects: Tenant's Subjects and
// * Policies.
// */
// void deleteFromTenant(String tenant);
//
// /**
// * Removes the Subject from the Tenant, and its Policies.
// */
// void deleteFromSubject(String tenant, String subject);
// }
// Path: src/main/java/es/tid/fiware/iot/ac/pap/TenantEndpoint.java
import org.slf4j.LoggerFactory;
import es.tid.fiware.iot.ac.dao.PolicyDao;
import es.tid.fiware.iot.ac.rs.Tenant;
import es.tid.fiware.iot.ac.rs.Correlator;
import io.dropwizard.hibernate.UnitOfWork;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.slf4j.Logger;
package es.tid.fiware.iot.ac.pap;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Tenant Policy management.
*/
@Path("/pap/v1")
@Produces(MediaType.APPLICATION_XML)
public class TenantEndpoint {
| private final PolicyDao dao; |
telefonicaid/fiware-keypass | src/main/java/es/tid/fiware/iot/ac/model/PolicySet.java | // Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
| import es.tid.fiware.iot.ac.util.Xml;
import java.io.IOException;
import java.util.Collection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException; | package es.tid.fiware.iot.ac.model;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
*
* @author dmj
*/
public class PolicySet {
static private final String COMBINING_POLICY = "urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides";
static private final String VERSION = "1.0";
static private final String NAMESPACE = "urn:oasis:names:tc:xacml:3.0:core:schema:wd-17";
private Collection<Policy> policies;
private String id;
public PolicySet(String policySetId, Collection<Policy> policies) {
this.policies = policies;
this.id = policySetId;
}
public Document toXml() throws IOException, SAXException { | // Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
// Path: src/main/java/es/tid/fiware/iot/ac/model/PolicySet.java
import es.tid.fiware.iot.ac.util.Xml;
import java.io.IOException;
import java.util.Collection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
package es.tid.fiware.iot.ac.model;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
*
* @author dmj
*/
public class PolicySet {
static private final String COMBINING_POLICY = "urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides";
static private final String VERSION = "1.0";
static private final String NAMESPACE = "urn:oasis:names:tc:xacml:3.0:core:schema:wd-17";
private Collection<Policy> policies;
private String id;
public PolicySet(String policySetId, Collection<Policy> policies) {
this.policies = policies;
this.id = policySetId;
}
public Document toXml() throws IOException, SAXException { | Document setDocument = Xml.newDocument(); |
telefonicaid/fiware-keypass | src/test/java/es/tid/fiware/iot/ac/dao/PolicyDaoInMemoryTest.java | // Path: src/main/java/es/tid/fiware/iot/ac/model/Policy.java
// @Entity
// public class Policy {
//
// @Embeddable
// public static class PolicyId implements Serializable {
// private String id;
// private String tenant;
//
// public PolicyId() {
//
// }
//
// public PolicyId(String tenant, String id) {
// this.id = id;
// this.tenant = tenant;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTenant() {
// return tenant;
// }
// }
//
// @EmbeddedId
// private PolicyId internalId;
// private String subject;
//
// private String policy;
//
// public Policy() {
//
// }
//
// public Policy(String id, String tenant, String subject, String policy) {
// this.internalId = new PolicyId(tenant, id);
// this.subject = subject;
// this.policy = policy;
// }
//
// public String getId() {
// return internalId.getId();
// }
//
// public PolicyId getInternalId() {
// return internalId;
// }
//
// public void setInternalId(PolicyId id) {
// internalId = id;
// }
//
// public String getTenant() {
// return internalId.getTenant();
// }
//
// public String getSubject() {
// return subject;
// }
//
// public String getPolicy() {
// return policy;
// }
//
// }
| import org.testng.annotations.Test;
import java.util.Collection;
import static org.testng.AssertJUnit.assertEquals;
import es.tid.fiware.iot.ac.model.Policy; | package es.tid.fiware.iot.ac.dao;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
public class PolicyDaoInMemoryTest {
@Test
public void testListAllFromTenant() {
PolicyDao dao = new PolicyDaoInMemory(); | // Path: src/main/java/es/tid/fiware/iot/ac/model/Policy.java
// @Entity
// public class Policy {
//
// @Embeddable
// public static class PolicyId implements Serializable {
// private String id;
// private String tenant;
//
// public PolicyId() {
//
// }
//
// public PolicyId(String tenant, String id) {
// this.id = id;
// this.tenant = tenant;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTenant() {
// return tenant;
// }
// }
//
// @EmbeddedId
// private PolicyId internalId;
// private String subject;
//
// private String policy;
//
// public Policy() {
//
// }
//
// public Policy(String id, String tenant, String subject, String policy) {
// this.internalId = new PolicyId(tenant, id);
// this.subject = subject;
// this.policy = policy;
// }
//
// public String getId() {
// return internalId.getId();
// }
//
// public PolicyId getInternalId() {
// return internalId;
// }
//
// public void setInternalId(PolicyId id) {
// internalId = id;
// }
//
// public String getTenant() {
// return internalId.getTenant();
// }
//
// public String getSubject() {
// return subject;
// }
//
// public String getPolicy() {
// return policy;
// }
//
// }
// Path: src/test/java/es/tid/fiware/iot/ac/dao/PolicyDaoInMemoryTest.java
import org.testng.annotations.Test;
import java.util.Collection;
import static org.testng.AssertJUnit.assertEquals;
import es.tid.fiware.iot.ac.model.Policy;
package es.tid.fiware.iot.ac.dao;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
public class PolicyDaoInMemoryTest {
@Test
public void testListAllFromTenant() {
PolicyDao dao = new PolicyDaoInMemory(); | dao.createPolicy(new Policy("rule1", "myTenant", "subject1", "policyTwo")); |
telefonicaid/fiware-keypass | src/test/java/es/tid/fiware/iot/ac/xacml/TestSamplesXACML.java | // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.testng.AssertJUnit.assertEquals;
import es.tid.fiware.iot.ac.util.Util;
import es.tid.fiware.iot.ac.util.Xml;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.wso2.balana.PDP;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory; | "policy01_request01.xml", "Permit" },
{ "One Policy, two Subjects and Permit",
Arrays.asList("policy01.xml"),
"policy01_request03.xml", "Permit" },
{ "Policy with resource target",
Arrays.asList("policy03.xml"),
"policy01_request01.xml", "Permit" },
{ "Policy with several actions permitted",
Arrays.asList("policy05.xml"),
"policy01_request01.xml", "Permit" },
{ "Policy with any action permitted",
Arrays.asList("policy06.xml"),
"policy01_request01.xml", "Permit" },
{ "One PolicySet, one Subject and Permit",
Arrays.asList("policyset01.xml"),
"policyset01_request01.xml", "Permit" },
};
}
@Test(dataProvider = "policies")
public void testPolicyEval(String testName, List<String> policies,
String request, String decision) throws Exception {
PDP pdp = createPDP(policies);
| // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
// Path: src/test/java/es/tid/fiware/iot/ac/xacml/TestSamplesXACML.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.testng.AssertJUnit.assertEquals;
import es.tid.fiware.iot.ac.util.Util;
import es.tid.fiware.iot.ac.util.Xml;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.wso2.balana.PDP;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
"policy01_request01.xml", "Permit" },
{ "One Policy, two Subjects and Permit",
Arrays.asList("policy01.xml"),
"policy01_request03.xml", "Permit" },
{ "Policy with resource target",
Arrays.asList("policy03.xml"),
"policy01_request01.xml", "Permit" },
{ "Policy with several actions permitted",
Arrays.asList("policy05.xml"),
"policy01_request01.xml", "Permit" },
{ "Policy with any action permitted",
Arrays.asList("policy06.xml"),
"policy01_request01.xml", "Permit" },
{ "One PolicySet, one Subject and Permit",
Arrays.asList("policyset01.xml"),
"policyset01_request01.xml", "Permit" },
};
}
@Test(dataProvider = "policies")
public void testPolicyEval(String testName, List<String> policies,
String request, String decision) throws Exception {
PDP pdp = createPDP(policies);
| String xacmlRes = pdp.evaluate(Util.read(this.getClass(), request)); |
telefonicaid/fiware-keypass | src/test/java/es/tid/fiware/iot/ac/xacml/TestSamplesXACML.java | // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.testng.AssertJUnit.assertEquals;
import es.tid.fiware.iot.ac.util.Util;
import es.tid.fiware.iot.ac.util.Xml;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.wso2.balana.PDP;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory; | "policy01_request01.xml", "Permit" },
{ "Policy with several actions permitted",
Arrays.asList("policy05.xml"),
"policy01_request01.xml", "Permit" },
{ "Policy with any action permitted",
Arrays.asList("policy06.xml"),
"policy01_request01.xml", "Permit" },
{ "One PolicySet, one Subject and Permit",
Arrays.asList("policyset01.xml"),
"policyset01_request01.xml", "Permit" },
};
}
@Test(dataProvider = "policies")
public void testPolicyEval(String testName, List<String> policies,
String request, String decision) throws Exception {
PDP pdp = createPDP(policies);
String xacmlRes = pdp.evaluate(Util.read(this.getClass(), request));
assertEquals(decision, Extractors.extractDecision(xacmlRes));
}
private PDP createPDP(List<String> policiesFiles) throws Exception {
List<Document> policies = new ArrayList<Document>();
for (String policyFile : policiesFiles) { | // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
//
// Path: src/main/java/es/tid/fiware/iot/ac/util/Xml.java
// public class Xml {
//
// // DocumentBuilder is not thread safe: <http://stackoverflow.com/a/3442674/1035380>
//
// private static DocumentBuilder db() {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setIgnoringComments(true);
// factory.setNamespaceAware(true);
// try {
// return factory.newDocumentBuilder();
// } catch (ParserConfigurationException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static String toString(Document doc) throws TransformerConfigurationException, TransformerException {
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// StringWriter writer = new StringWriter();
// transformer.transform(new DOMSource(doc), new StreamResult(writer));
// return writer.getBuffer().toString().replaceAll("\n|\r", "");
// }
//
// public static Document toXml(String str) throws IOException, SAXException {
// return db().parse(new InputSource(new StringReader(str)));
// }
//
// public static Document newDocument() {
// return db().newDocument();
// }
// }
// Path: src/test/java/es/tid/fiware/iot/ac/xacml/TestSamplesXACML.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.testng.AssertJUnit.assertEquals;
import es.tid.fiware.iot.ac.util.Util;
import es.tid.fiware.iot.ac.util.Xml;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.wso2.balana.PDP;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
"policy01_request01.xml", "Permit" },
{ "Policy with several actions permitted",
Arrays.asList("policy05.xml"),
"policy01_request01.xml", "Permit" },
{ "Policy with any action permitted",
Arrays.asList("policy06.xml"),
"policy01_request01.xml", "Permit" },
{ "One PolicySet, one Subject and Permit",
Arrays.asList("policyset01.xml"),
"policyset01_request01.xml", "Permit" },
};
}
@Test(dataProvider = "policies")
public void testPolicyEval(String testName, List<String> policies,
String request, String decision) throws Exception {
PDP pdp = createPDP(policies);
String xacmlRes = pdp.evaluate(Util.read(this.getClass(), request));
assertEquals(decision, Extractors.extractDecision(xacmlRes));
}
private PDP createPDP(List<String> policiesFiles) throws Exception {
List<Document> policies = new ArrayList<Document>();
for (String policyFile : policiesFiles) { | policies.add(Xml.toXml(Util.read(this.getClass(), policyFile))); |
telefonicaid/fiware-keypass | src/test/java/es/tid/fiware/iot/ac/xacml/TestExtractors.java | // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
| import es.tid.fiware.iot.ac.util.Util;
import org.testng.annotations.Test;
import java.util.Collection;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue; | package es.tid.fiware.iot.ac.xacml;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
public class TestExtractors {
@Test
public void testExtractSubjects() throws Exception { | // Path: src/main/java/es/tid/fiware/iot/ac/util/Util.java
// public class Util {
//
// public static String read(Class clazz, String f) {
// return new Scanner(clazz.getResourceAsStream(f)).useDelimiter("\\Z").next();
// }
//
// }
// Path: src/test/java/es/tid/fiware/iot/ac/xacml/TestExtractors.java
import es.tid.fiware.iot.ac.util.Util;
import org.testng.annotations.Test;
import java.util.Collection;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
package es.tid.fiware.iot.ac.xacml;
/*
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
public class TestExtractors {
@Test
public void testExtractSubjects() throws Exception { | String xacmlStr = Util.read(this.getClass(), "policy01_request03.xml"); |
zhangjikai/samples | spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.utils.ServiceResults;
import java.util.List; | package com.zhangjikai.service;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
public interface UserService {
public boolean isExists(User user);
public User findUser(User user);
public List<User> findUsers();
| // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
import com.zhangjikai.bean.User;
import com.zhangjikai.utils.ServiceResults;
import java.util.List;
package com.zhangjikai.service;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
public interface UserService {
public boolean isExists(User user);
public User findUser(User user);
public List<User> findUsers();
| public ServiceResults addUser(User user); |
zhangjikai/samples | spring-mybatis-login/login/src/main/java/com/zhangjikai/service/impl/UserServiceImpl.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/mapper/UserMapper.java
// public interface UserMapper {
//
//
// public String isExists(User user);
//
// public User findUser(User user);
//
// public int addUser(User user);
//
// public int updateUser(User user);
//
// public int deleteUser(User user);
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.mapper.UserMapper;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.ServiceResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List; | package com.zhangjikai.service.impl;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
@Transactional
@Service("userService") | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/mapper/UserMapper.java
// public interface UserMapper {
//
//
// public String isExists(User user);
//
// public User findUser(User user);
//
// public int addUser(User user);
//
// public int updateUser(User user);
//
// public int deleteUser(User user);
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/impl/UserServiceImpl.java
import com.zhangjikai.bean.User;
import com.zhangjikai.mapper.UserMapper;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.ServiceResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List;
package com.zhangjikai.service.impl;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
@Transactional
@Service("userService") | public class UserServiceImpl implements UserService { |
zhangjikai/samples | spring-mybatis-login/login/src/main/java/com/zhangjikai/service/impl/UserServiceImpl.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/mapper/UserMapper.java
// public interface UserMapper {
//
//
// public String isExists(User user);
//
// public User findUser(User user);
//
// public int addUser(User user);
//
// public int updateUser(User user);
//
// public int deleteUser(User user);
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.mapper.UserMapper;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.ServiceResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List; | package com.zhangjikai.service.impl;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
@Transactional
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/mapper/UserMapper.java
// public interface UserMapper {
//
//
// public String isExists(User user);
//
// public User findUser(User user);
//
// public int addUser(User user);
//
// public int updateUser(User user);
//
// public int deleteUser(User user);
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/impl/UserServiceImpl.java
import com.zhangjikai.bean.User;
import com.zhangjikai.mapper.UserMapper;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.ServiceResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List;
package com.zhangjikai.service.impl;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
@Transactional
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired | private UserMapper userMapper; |
zhangjikai/samples | spring-mybatis-login/login/src/main/java/com/zhangjikai/service/impl/UserServiceImpl.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/mapper/UserMapper.java
// public interface UserMapper {
//
//
// public String isExists(User user);
//
// public User findUser(User user);
//
// public int addUser(User user);
//
// public int updateUser(User user);
//
// public int deleteUser(User user);
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.mapper.UserMapper;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.ServiceResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List; | package com.zhangjikai.service.impl;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
@Transactional
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Override | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/mapper/UserMapper.java
// public interface UserMapper {
//
//
// public String isExists(User user);
//
// public User findUser(User user);
//
// public int addUser(User user);
//
// public int updateUser(User user);
//
// public int deleteUser(User user);
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/impl/UserServiceImpl.java
import com.zhangjikai.bean.User;
import com.zhangjikai.mapper.UserMapper;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.ServiceResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List;
package com.zhangjikai.service.impl;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
@Transactional
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Override | public boolean isExists(User user) { |
zhangjikai/samples | spring-mybatis-login/login/src/main/java/com/zhangjikai/service/impl/UserServiceImpl.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/mapper/UserMapper.java
// public interface UserMapper {
//
//
// public String isExists(User user);
//
// public User findUser(User user);
//
// public int addUser(User user);
//
// public int updateUser(User user);
//
// public int deleteUser(User user);
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.mapper.UserMapper;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.ServiceResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List; | package com.zhangjikai.service.impl;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
@Transactional
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Override
public boolean isExists(User user) {
String result = userMapper.isExists(user);
if (result == null) {
return false;
}
return true;
}
@Override
public User findUser(User user) {
User user2 = null;
user2 = userMapper.findUser(user);
return user2;
}
@Override
public List<User> findUsers() {
return null;
}
@Override | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/mapper/UserMapper.java
// public interface UserMapper {
//
//
// public String isExists(User user);
//
// public User findUser(User user);
//
// public int addUser(User user);
//
// public int updateUser(User user);
//
// public int deleteUser(User user);
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/impl/UserServiceImpl.java
import com.zhangjikai.bean.User;
import com.zhangjikai.mapper.UserMapper;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.ServiceResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.List;
package com.zhangjikai.service.impl;
/**
* Created by Zhang Jikai on 2016/5/12.
*/
@Transactional
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Override
public boolean isExists(User user) {
String result = userMapper.isExists(user);
if (result == null) {
return false;
}
return true;
}
@Override
public User findUser(User user) {
User user2 = null;
user2 = userMapper.findUser(user);
return user2;
}
@Override
public List<User> findUsers() {
return null;
}
@Override | public ServiceResults addUser(User user) { |
zhangjikai/samples | encryption/src/test/java/TestEncryption.java | // Path: encryption/src/main/java/com/zhangjikai/encrypt/Encryption.java
// public class Encryption {
//
//
// public static String base64Encode(String original) {
// String encyStr = "";
// try {
// byte[] bytes = original.getBytes("UTF-8");
// encyStr = Base64.getEncoder().encodeToString(bytes);
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// encyStr = "";
// }
// return encyStr;
// //String enStr =
// }
//
// public static String base64Decode(String encyStr) {
// String original = "";
// byte[] bytes = Base64.getDecoder().decode(encyStr);
// original = new String(bytes);
// return original;
// }
//
// public static String MD5(String original) {
// String encyStr = "";
// try {
// MessageDigest md5 = MessageDigest.getInstance("MD5");
// byte[] bytes = original.getBytes("UTF-8");
// md5.update(bytes);
// BigInteger integer = new BigInteger(md5.digest());
// encyStr = integer.toString(16);
// } catch (NoSuchAlgorithmException e) {
// e.printStackTrace();
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
// return encyStr;
// }
// }
| import com.zhangjikai.encrypt.Encryption;
import org.junit.Test; |
/**
* Created by ZhangJikai on 2016/10/26.
*/
public class TestEncryption {
@Test
public void testBase64() {
String s = "\n" +
"\n" +
" Sulfate-(O-6)+\n" +
" |\n" +
" Sulfate-(O-6)-a-D-Glcp2Me3Me4Me-(1-4)-b-D-GlcpA2Me3Me-(1-4)+| Sulfate-(O-6)+\n" +
" || |\n" +
" a-D-Glcp-(1-4)-a-L-IdopA2Me3Me-(1-4)+|\n" +
" || ||\n" +
" Sulfate-(O-3)+| a-D-Glcp-(1-1)-methyl\n" +
" | ||\n" +
" Sulfate-(O-2)+ Sulfate-(O-3)+|\n" +
" |\n" +
" Sulfate-(O-2)+\n";
| // Path: encryption/src/main/java/com/zhangjikai/encrypt/Encryption.java
// public class Encryption {
//
//
// public static String base64Encode(String original) {
// String encyStr = "";
// try {
// byte[] bytes = original.getBytes("UTF-8");
// encyStr = Base64.getEncoder().encodeToString(bytes);
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// encyStr = "";
// }
// return encyStr;
// //String enStr =
// }
//
// public static String base64Decode(String encyStr) {
// String original = "";
// byte[] bytes = Base64.getDecoder().decode(encyStr);
// original = new String(bytes);
// return original;
// }
//
// public static String MD5(String original) {
// String encyStr = "";
// try {
// MessageDigest md5 = MessageDigest.getInstance("MD5");
// byte[] bytes = original.getBytes("UTF-8");
// md5.update(bytes);
// BigInteger integer = new BigInteger(md5.digest());
// encyStr = integer.toString(16);
// } catch (NoSuchAlgorithmException e) {
// e.printStackTrace();
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
// return encyStr;
// }
// }
// Path: encryption/src/test/java/TestEncryption.java
import com.zhangjikai.encrypt.Encryption;
import org.junit.Test;
/**
* Created by ZhangJikai on 2016/10/26.
*/
public class TestEncryption {
@Test
public void testBase64() {
String s = "\n" +
"\n" +
" Sulfate-(O-6)+\n" +
" |\n" +
" Sulfate-(O-6)-a-D-Glcp2Me3Me4Me-(1-4)-b-D-GlcpA2Me3Me-(1-4)+| Sulfate-(O-6)+\n" +
" || |\n" +
" a-D-Glcp-(1-4)-a-L-IdopA2Me3Me-(1-4)+|\n" +
" || ||\n" +
" Sulfate-(O-3)+| a-D-Glcp-(1-1)-methyl\n" +
" | ||\n" +
" Sulfate-(O-2)+ Sulfate-(O-3)+|\n" +
" |\n" +
" Sulfate-(O-2)+\n";
| String encodeStr = Encryption.base64Encode(s); |
zhangjikai/samples | spring-mybatis-login/login/src/main/java/com/zhangjikai/controller/UserController.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/Constants.java
// public class Constants {
// public static final String USER_EXISTS = "yes";
// public static final String USER_NO_EXISTS = "no";
// public static final String USER_REGISTER_SUCCESS = "success";
// public static final String USER_REGISTER_FAIL = "fail";
//
// public static final String LOGIN_SUCCESS = "success";
// public static final String LOGIN_INTERNAL_ERROR = "internal";
// public static final String LOGIN_USERNAME_ERROR = "username";
// public static final String LOGIN_PASSWORD_ERROR = "password";
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.Constants;
import com.zhangjikai.utils.ServiceResults;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package com.zhangjikai.controller;
/**
* Created by Zhang Jikai on 2016/5/13.
*/
@RestController
public class UserController {
@Autowired | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/Constants.java
// public class Constants {
// public static final String USER_EXISTS = "yes";
// public static final String USER_NO_EXISTS = "no";
// public static final String USER_REGISTER_SUCCESS = "success";
// public static final String USER_REGISTER_FAIL = "fail";
//
// public static final String LOGIN_SUCCESS = "success";
// public static final String LOGIN_INTERNAL_ERROR = "internal";
// public static final String LOGIN_USERNAME_ERROR = "username";
// public static final String LOGIN_PASSWORD_ERROR = "password";
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/controller/UserController.java
import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.Constants;
import com.zhangjikai.utils.ServiceResults;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package com.zhangjikai.controller;
/**
* Created by Zhang Jikai on 2016/5/13.
*/
@RestController
public class UserController {
@Autowired | private UserService userService; |
zhangjikai/samples | spring-mybatis-login/login/src/main/java/com/zhangjikai/controller/UserController.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/Constants.java
// public class Constants {
// public static final String USER_EXISTS = "yes";
// public static final String USER_NO_EXISTS = "no";
// public static final String USER_REGISTER_SUCCESS = "success";
// public static final String USER_REGISTER_FAIL = "fail";
//
// public static final String LOGIN_SUCCESS = "success";
// public static final String LOGIN_INTERNAL_ERROR = "internal";
// public static final String LOGIN_USERNAME_ERROR = "username";
// public static final String LOGIN_PASSWORD_ERROR = "password";
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.Constants;
import com.zhangjikai.utils.ServiceResults;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package com.zhangjikai.controller;
/**
* Created by Zhang Jikai on 2016/5/13.
*/
@RestController
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "/checkUsername", method = RequestMethod.POST, produces = "application/json;charset=utf8")
@ResponseBody
public String checkUsername(@RequestParam String username) {
if (isNull(username)) { | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/Constants.java
// public class Constants {
// public static final String USER_EXISTS = "yes";
// public static final String USER_NO_EXISTS = "no";
// public static final String USER_REGISTER_SUCCESS = "success";
// public static final String USER_REGISTER_FAIL = "fail";
//
// public static final String LOGIN_SUCCESS = "success";
// public static final String LOGIN_INTERNAL_ERROR = "internal";
// public static final String LOGIN_USERNAME_ERROR = "username";
// public static final String LOGIN_PASSWORD_ERROR = "password";
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/controller/UserController.java
import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.Constants;
import com.zhangjikai.utils.ServiceResults;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package com.zhangjikai.controller;
/**
* Created by Zhang Jikai on 2016/5/13.
*/
@RestController
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "/checkUsername", method = RequestMethod.POST, produces = "application/json;charset=utf8")
@ResponseBody
public String checkUsername(@RequestParam String username) {
if (isNull(username)) { | return Constants.USER_EXISTS; |
zhangjikai/samples | spring-mybatis-login/login/src/main/java/com/zhangjikai/controller/UserController.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/Constants.java
// public class Constants {
// public static final String USER_EXISTS = "yes";
// public static final String USER_NO_EXISTS = "no";
// public static final String USER_REGISTER_SUCCESS = "success";
// public static final String USER_REGISTER_FAIL = "fail";
//
// public static final String LOGIN_SUCCESS = "success";
// public static final String LOGIN_INTERNAL_ERROR = "internal";
// public static final String LOGIN_USERNAME_ERROR = "username";
// public static final String LOGIN_PASSWORD_ERROR = "password";
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.Constants;
import com.zhangjikai.utils.ServiceResults;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package com.zhangjikai.controller;
/**
* Created by Zhang Jikai on 2016/5/13.
*/
@RestController
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "/checkUsername", method = RequestMethod.POST, produces = "application/json;charset=utf8")
@ResponseBody
public String checkUsername(@RequestParam String username) {
if (isNull(username)) {
return Constants.USER_EXISTS;
} | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/Constants.java
// public class Constants {
// public static final String USER_EXISTS = "yes";
// public static final String USER_NO_EXISTS = "no";
// public static final String USER_REGISTER_SUCCESS = "success";
// public static final String USER_REGISTER_FAIL = "fail";
//
// public static final String LOGIN_SUCCESS = "success";
// public static final String LOGIN_INTERNAL_ERROR = "internal";
// public static final String LOGIN_USERNAME_ERROR = "username";
// public static final String LOGIN_PASSWORD_ERROR = "password";
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/controller/UserController.java
import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.Constants;
import com.zhangjikai.utils.ServiceResults;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package com.zhangjikai.controller;
/**
* Created by Zhang Jikai on 2016/5/13.
*/
@RestController
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "/checkUsername", method = RequestMethod.POST, produces = "application/json;charset=utf8")
@ResponseBody
public String checkUsername(@RequestParam String username) {
if (isNull(username)) {
return Constants.USER_EXISTS;
} | User user = new User(); |
zhangjikai/samples | spring-mybatis-login/login/src/main/java/com/zhangjikai/controller/UserController.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/Constants.java
// public class Constants {
// public static final String USER_EXISTS = "yes";
// public static final String USER_NO_EXISTS = "no";
// public static final String USER_REGISTER_SUCCESS = "success";
// public static final String USER_REGISTER_FAIL = "fail";
//
// public static final String LOGIN_SUCCESS = "success";
// public static final String LOGIN_INTERNAL_ERROR = "internal";
// public static final String LOGIN_USERNAME_ERROR = "username";
// public static final String LOGIN_PASSWORD_ERROR = "password";
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.Constants;
import com.zhangjikai.utils.ServiceResults;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | public String register(@RequestBody User user) {
if(user == null) {
return Constants.USER_REGISTER_FAIL;
}
if(isNull(user.getUserName()) || isNull(user.getPassword()) || isNull(user.getEmail())) {
return Constants.USER_REGISTER_FAIL;
}
if(checkLen(user.getUserName(), 6) || checkLen(user.getPassword(), 8)) {
return Constants.USER_REGISTER_FAIL;
}
if(!isEmail(user.getEmail())) {
return Constants.USER_REGISTER_FAIL;
}
user.setPassword(BCrypt.hashpw(user.getPassword(), BCrypt.gensalt()));
User user2 = new User();
user2.setUserName(user.getUserName());
if(userService.isExists(user2)) {
return Constants.USER_REGISTER_FAIL;
}
user2.setUserName(null);
user2.setEmail(user.getEmail());
if(userService.isExists(user2)) {
return Constants.USER_REGISTER_FAIL;
}
| // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/Constants.java
// public class Constants {
// public static final String USER_EXISTS = "yes";
// public static final String USER_NO_EXISTS = "no";
// public static final String USER_REGISTER_SUCCESS = "success";
// public static final String USER_REGISTER_FAIL = "fail";
//
// public static final String LOGIN_SUCCESS = "success";
// public static final String LOGIN_INTERNAL_ERROR = "internal";
// public static final String LOGIN_USERNAME_ERROR = "username";
// public static final String LOGIN_PASSWORD_ERROR = "password";
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/utils/ServiceResults.java
// public enum ServiceResults {
// SUCCESS, FAILURE, DATABASE_ERROR
// }
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/controller/UserController.java
import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import com.zhangjikai.utils.Constants;
import com.zhangjikai.utils.ServiceResults;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public String register(@RequestBody User user) {
if(user == null) {
return Constants.USER_REGISTER_FAIL;
}
if(isNull(user.getUserName()) || isNull(user.getPassword()) || isNull(user.getEmail())) {
return Constants.USER_REGISTER_FAIL;
}
if(checkLen(user.getUserName(), 6) || checkLen(user.getPassword(), 8)) {
return Constants.USER_REGISTER_FAIL;
}
if(!isEmail(user.getEmail())) {
return Constants.USER_REGISTER_FAIL;
}
user.setPassword(BCrypt.hashpw(user.getPassword(), BCrypt.gensalt()));
User user2 = new User();
user2.setUserName(user.getUserName());
if(userService.isExists(user2)) {
return Constants.USER_REGISTER_FAIL;
}
user2.setUserName(null);
user2.setEmail(user.getEmail());
if(userService.isExists(user2)) {
return Constants.USER_REGISTER_FAIL;
}
| if(userService.addUser(user) == ServiceResults.FAILURE) { |
zhangjikai/samples | spring-mybatis-login/login/src/test/java/TestUser.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import org.junit.*;
import org.junit.Test;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; |
/**
* Created by Administrator on 2016/5/12.
*/
public class TestUser {
private ApplicationContext applicationContext;
@Before
public void initSpringContext() {
applicationContext = new ClassPathXmlApplicationContext("classpath:/applicationContext.xml");
}
@Test
public void testBCrypt() {
String hashed = BCrypt.hashpw("111%@11", BCrypt.gensalt());
if(BCrypt.checkpw("111111","$2a$10$q9EEM6FTWBY11n26R/OZQOlK2GoWdRa2eQp88f4iIsAXdM45hiHtq")) {
System.out.println(true);
}
System.out.println(hashed);
}
@Test
public void testAddUser() {
System.out.println(applicationContext); | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
// Path: spring-mybatis-login/login/src/test/java/TestUser.java
import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import org.junit.*;
import org.junit.Test;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Created by Administrator on 2016/5/12.
*/
public class TestUser {
private ApplicationContext applicationContext;
@Before
public void initSpringContext() {
applicationContext = new ClassPathXmlApplicationContext("classpath:/applicationContext.xml");
}
@Test
public void testBCrypt() {
String hashed = BCrypt.hashpw("111%@11", BCrypt.gensalt());
if(BCrypt.checkpw("111111","$2a$10$q9EEM6FTWBY11n26R/OZQOlK2GoWdRa2eQp88f4iIsAXdM45hiHtq")) {
System.out.println(true);
}
System.out.println(hashed);
}
@Test
public void testAddUser() {
System.out.println(applicationContext); | User user = new User(); |
zhangjikai/samples | spring-mybatis-login/login/src/test/java/TestUser.java | // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
| import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import org.junit.*;
import org.junit.Test;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; |
/**
* Created by Administrator on 2016/5/12.
*/
public class TestUser {
private ApplicationContext applicationContext;
@Before
public void initSpringContext() {
applicationContext = new ClassPathXmlApplicationContext("classpath:/applicationContext.xml");
}
@Test
public void testBCrypt() {
String hashed = BCrypt.hashpw("111%@11", BCrypt.gensalt());
if(BCrypt.checkpw("111111","$2a$10$q9EEM6FTWBY11n26R/OZQOlK2GoWdRa2eQp88f4iIsAXdM45hiHtq")) {
System.out.println(true);
}
System.out.println(hashed);
}
@Test
public void testAddUser() {
System.out.println(applicationContext);
User user = new User();
user.setUserName("zhangjikai5");
user.setPassword(BCrypt.hashpw("111111", BCrypt.gensalt()));
user.setEmail("aaa@qq.com");
| // Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/bean/User.java
// public class User implements Serializable {
//
// private static final long serialVersionUID = -5646388155422186664L;
//
// private Long userId;
// private String userName;
// private String password;
// private String email;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Long getUserId() {
// return userId;
// }
//
// public void setUserId(Long userId) {
// this.userId = userId;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "userId=" + userId +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: spring-mybatis-login/login/src/main/java/com/zhangjikai/service/UserService.java
// public interface UserService {
//
//
// public boolean isExists(User user);
//
// public User findUser(User user);
//
// public List<User> findUsers();
//
// public ServiceResults addUser(User user);
//
// public ServiceResults updateUser(User user);
//
// public ServiceResults deleteUser(User user);
//
//
//
// }
// Path: spring-mybatis-login/login/src/test/java/TestUser.java
import com.zhangjikai.bean.User;
import com.zhangjikai.service.UserService;
import org.junit.*;
import org.junit.Test;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Created by Administrator on 2016/5/12.
*/
public class TestUser {
private ApplicationContext applicationContext;
@Before
public void initSpringContext() {
applicationContext = new ClassPathXmlApplicationContext("classpath:/applicationContext.xml");
}
@Test
public void testBCrypt() {
String hashed = BCrypt.hashpw("111%@11", BCrypt.gensalt());
if(BCrypt.checkpw("111111","$2a$10$q9EEM6FTWBY11n26R/OZQOlK2GoWdRa2eQp88f4iIsAXdM45hiHtq")) {
System.out.println(true);
}
System.out.println(hashed);
}
@Test
public void testAddUser() {
System.out.println(applicationContext);
User user = new User();
user.setUserName("zhangjikai5");
user.setPassword(BCrypt.hashpw("111111", BCrypt.gensalt()));
user.setEmail("aaa@qq.com");
| UserService userService = (UserService) applicationContext.getBean("userService"); |
abraao/FastPicasaBrowser | src/com/guaranacode/android/fastpicasabrowser/picasa/model/AlbumEntry.java | // Path: src/com/guaranacode/android/fastpicasabrowser/storage/IStorableModel.java
// public interface IStorableModel {
//
// /**
// * The URL to the resource.
// * @return
// */
// String getUrl();
//
// /**
// * Get the directory in the application's path where we store files.
// * @return
// */
// String getDir();
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/util/StringUtils.java
// public class StringUtils {
//
// /**
// * Returns true if the string is null or contains only whitespace.
// *
// * @param string
// * @return
// */
// public static boolean isNullOrEmpty(String string) {
// return (null == string) || (string.trim().length() == 0);
// }
// }
| import com.google.api.client.util.Key;
import com.guaranacode.android.fastpicasabrowser.storage.IStorableModel;
import com.guaranacode.android.fastpicasabrowser.util.StringUtils; | package com.guaranacode.android.fastpicasabrowser.picasa.model;
/**
* An album from the Picasa API feed.
*
* @author abe@guaranacode.com
*
*/
public class AlbumEntry extends Entry implements IStorableModel {
@Key("gphoto:access")
public String access;
@Key
public Category category = Category.newKind("album");
@Key("media:group")
public MediaGroup mediaGroup;
@Key("gphoto:id")
public String albumId;
public String thumbnailUrl;
@Key
public String updated;
public String getUrl() { | // Path: src/com/guaranacode/android/fastpicasabrowser/storage/IStorableModel.java
// public interface IStorableModel {
//
// /**
// * The URL to the resource.
// * @return
// */
// String getUrl();
//
// /**
// * Get the directory in the application's path where we store files.
// * @return
// */
// String getDir();
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/util/StringUtils.java
// public class StringUtils {
//
// /**
// * Returns true if the string is null or contains only whitespace.
// *
// * @param string
// * @return
// */
// public static boolean isNullOrEmpty(String string) {
// return (null == string) || (string.trim().length() == 0);
// }
// }
// Path: src/com/guaranacode/android/fastpicasabrowser/picasa/model/AlbumEntry.java
import com.google.api.client.util.Key;
import com.guaranacode.android.fastpicasabrowser.storage.IStorableModel;
import com.guaranacode.android.fastpicasabrowser.util.StringUtils;
package com.guaranacode.android.fastpicasabrowser.picasa.model;
/**
* An album from the Picasa API feed.
*
* @author abe@guaranacode.com
*
*/
public class AlbumEntry extends Entry implements IStorableModel {
@Key("gphoto:access")
public String access;
@Key
public Category category = Category.newKind("album");
@Key("media:group")
public MediaGroup mediaGroup;
@Key("gphoto:id")
public String albumId;
public String thumbnailUrl;
@Key
public String updated;
public String getUrl() { | if(!StringUtils.isNullOrEmpty(thumbnailUrl)) { |
abraao/FastPicasaBrowser | src/com/guaranacode/android/fastpicasabrowser/database/DatabaseHelper.java | // Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/AlbumsTable.java
// public class AlbumsTable implements ITable {
//
// private AlbumsTable() {}
//
// /*
// * Column names
// */
// public static final String ALBUM_ID = "album_id";
//
// public static final String THUMBNAIL_URL = "thumbnail_url";
//
// public static final String ETAG = "etag";
//
// public static final String TITLE = "title";
//
// public static final String UPDATED = "updated";
//
// public static final String THUMBNAIL_LOCAL_PATH = "thumbnail_local_path";
//
// /*
// * ITable interface methods
// */
//
// private static AlbumsTable mInstance;
//
// public static ITable getInstance() {
// if(null == mInstance) {
// mInstance = new AlbumsTable();
// }
//
// return mInstance;
// }
//
// public String getTableName() {
// return "albums";
// }
//
// public String getCreateTableSQL() {
// String sql = "CREATE TABLE " + getTableName() + " ("
// + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
// + ALBUM_ID + " TEXT,"
// + ETAG + " TEXT,"
// + TITLE + " TEXT,"
// + UPDATED + " TEXT,"
// + THUMBNAIL_LOCAL_PATH + " TEXT"
// + ");";
//
// return sql;
// }
//
// private static HashMap<String, String> mProjectionMap;
// public HashMap<String, String> getProjectionMap() {
// return mProjectionMap;
// }
//
// static {
// mProjectionMap = new HashMap<String, String>();
// mProjectionMap.put(_ID, _ID);
// mProjectionMap.put(ALBUM_ID, ALBUM_ID);
// mProjectionMap.put(ETAG, ETAG);
// mProjectionMap.put(TITLE, TITLE);
// mProjectionMap.put(UPDATED, UPDATED);
// mProjectionMap.put(THUMBNAIL_LOCAL_PATH, THUMBNAIL_LOCAL_PATH);
// }
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/ITable.java
// public interface ITable extends BaseColumns {
//
// String getTableName();
//
// String getCreateTableSQL();
//
// HashMap<String, String> getProjectionMap();
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/PhotosTable.java
// public class PhotosTable implements ITable {
//
// private PhotosTable() {}
//
// /*
// * Column names
// */
// public static final String PHOTO_ID = "photo_id";
//
// public static final String THUMBNAIL_URL = "thumbnail_url";
//
// public static final String ETAG = "etag";
//
// public static final String THUMBNAIL_LOCAL_PATH = "thumbnail_local_path";
//
// public static final String PHOTO_URL = "photo_url";
//
// public static final String ALBUM_ID = "album_id";
//
// /*
// * ITable interface members
// */
//
// private static PhotosTable mInstance;
//
// public static ITable getInstance() {
// if(null == mInstance) {
// mInstance = new PhotosTable();
// }
//
// return mInstance;
// }
//
// public String getCreateTableSQL() {
// String sql = "CREATE TABLE " + getTableName() + " ("
// + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
// + PHOTO_ID + " TEXT,"
// + ETAG + " TEXT,"
// + THUMBNAIL_LOCAL_PATH + " TEXT,"
// + PHOTO_URL + " TEXT,"
// + ALBUM_ID + " TEXT"
// + ");";
//
// return sql;
// }
//
// public String getTableName() {
// return "photos";
// }
//
// private static HashMap<String, String> mProjectionMap;
// public HashMap<String, String> getProjectionMap() {
// return mProjectionMap;
// }
//
// static {
// mProjectionMap = new HashMap<String, String>();
// mProjectionMap.put(_ID, _ID);
// mProjectionMap.put(PHOTO_ID, PHOTO_ID);
// mProjectionMap.put(ETAG, ETAG);
// mProjectionMap.put(PHOTO_URL, PHOTO_URL);
// mProjectionMap.put(THUMBNAIL_LOCAL_PATH, THUMBNAIL_LOCAL_PATH);
// mProjectionMap.put(ALBUM_ID, ALBUM_ID);
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.guaranacode.android.fastpicasabrowser.database.tables.AlbumsTable;
import com.guaranacode.android.fastpicasabrowser.database.tables.ITable;
import com.guaranacode.android.fastpicasabrowser.database.tables.PhotosTable;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; | package com.guaranacode.android.fastpicasabrowser.database;
/**
* Helper for the databased used by the application.
*
* @author abe@guaranacode.com
*
*/
public class DatabaseHelper extends SQLiteOpenHelper {
private List<ITable> mAllTables;
public DatabaseHelper(Context context) {
super(context, DbConstants.DATABASE_NAME, null, DbConstants.DATABASE_VERSION);
mAllTables = new ArrayList<ITable>();
//JAVASUCKS: no collection initializers. | // Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/AlbumsTable.java
// public class AlbumsTable implements ITable {
//
// private AlbumsTable() {}
//
// /*
// * Column names
// */
// public static final String ALBUM_ID = "album_id";
//
// public static final String THUMBNAIL_URL = "thumbnail_url";
//
// public static final String ETAG = "etag";
//
// public static final String TITLE = "title";
//
// public static final String UPDATED = "updated";
//
// public static final String THUMBNAIL_LOCAL_PATH = "thumbnail_local_path";
//
// /*
// * ITable interface methods
// */
//
// private static AlbumsTable mInstance;
//
// public static ITable getInstance() {
// if(null == mInstance) {
// mInstance = new AlbumsTable();
// }
//
// return mInstance;
// }
//
// public String getTableName() {
// return "albums";
// }
//
// public String getCreateTableSQL() {
// String sql = "CREATE TABLE " + getTableName() + " ("
// + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
// + ALBUM_ID + " TEXT,"
// + ETAG + " TEXT,"
// + TITLE + " TEXT,"
// + UPDATED + " TEXT,"
// + THUMBNAIL_LOCAL_PATH + " TEXT"
// + ");";
//
// return sql;
// }
//
// private static HashMap<String, String> mProjectionMap;
// public HashMap<String, String> getProjectionMap() {
// return mProjectionMap;
// }
//
// static {
// mProjectionMap = new HashMap<String, String>();
// mProjectionMap.put(_ID, _ID);
// mProjectionMap.put(ALBUM_ID, ALBUM_ID);
// mProjectionMap.put(ETAG, ETAG);
// mProjectionMap.put(TITLE, TITLE);
// mProjectionMap.put(UPDATED, UPDATED);
// mProjectionMap.put(THUMBNAIL_LOCAL_PATH, THUMBNAIL_LOCAL_PATH);
// }
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/ITable.java
// public interface ITable extends BaseColumns {
//
// String getTableName();
//
// String getCreateTableSQL();
//
// HashMap<String, String> getProjectionMap();
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/PhotosTable.java
// public class PhotosTable implements ITable {
//
// private PhotosTable() {}
//
// /*
// * Column names
// */
// public static final String PHOTO_ID = "photo_id";
//
// public static final String THUMBNAIL_URL = "thumbnail_url";
//
// public static final String ETAG = "etag";
//
// public static final String THUMBNAIL_LOCAL_PATH = "thumbnail_local_path";
//
// public static final String PHOTO_URL = "photo_url";
//
// public static final String ALBUM_ID = "album_id";
//
// /*
// * ITable interface members
// */
//
// private static PhotosTable mInstance;
//
// public static ITable getInstance() {
// if(null == mInstance) {
// mInstance = new PhotosTable();
// }
//
// return mInstance;
// }
//
// public String getCreateTableSQL() {
// String sql = "CREATE TABLE " + getTableName() + " ("
// + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
// + PHOTO_ID + " TEXT,"
// + ETAG + " TEXT,"
// + THUMBNAIL_LOCAL_PATH + " TEXT,"
// + PHOTO_URL + " TEXT,"
// + ALBUM_ID + " TEXT"
// + ");";
//
// return sql;
// }
//
// public String getTableName() {
// return "photos";
// }
//
// private static HashMap<String, String> mProjectionMap;
// public HashMap<String, String> getProjectionMap() {
// return mProjectionMap;
// }
//
// static {
// mProjectionMap = new HashMap<String, String>();
// mProjectionMap.put(_ID, _ID);
// mProjectionMap.put(PHOTO_ID, PHOTO_ID);
// mProjectionMap.put(ETAG, ETAG);
// mProjectionMap.put(PHOTO_URL, PHOTO_URL);
// mProjectionMap.put(THUMBNAIL_LOCAL_PATH, THUMBNAIL_LOCAL_PATH);
// mProjectionMap.put(ALBUM_ID, ALBUM_ID);
// }
//
// }
// Path: src/com/guaranacode/android/fastpicasabrowser/database/DatabaseHelper.java
import java.util.ArrayList;
import java.util.List;
import com.guaranacode.android.fastpicasabrowser.database.tables.AlbumsTable;
import com.guaranacode.android.fastpicasabrowser.database.tables.ITable;
import com.guaranacode.android.fastpicasabrowser.database.tables.PhotosTable;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
package com.guaranacode.android.fastpicasabrowser.database;
/**
* Helper for the databased used by the application.
*
* @author abe@guaranacode.com
*
*/
public class DatabaseHelper extends SQLiteOpenHelper {
private List<ITable> mAllTables;
public DatabaseHelper(Context context) {
super(context, DbConstants.DATABASE_NAME, null, DbConstants.DATABASE_VERSION);
mAllTables = new ArrayList<ITable>();
//JAVASUCKS: no collection initializers. | mAllTables.add(AlbumsTable.getInstance()); |
abraao/FastPicasaBrowser | src/com/guaranacode/android/fastpicasabrowser/database/DatabaseHelper.java | // Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/AlbumsTable.java
// public class AlbumsTable implements ITable {
//
// private AlbumsTable() {}
//
// /*
// * Column names
// */
// public static final String ALBUM_ID = "album_id";
//
// public static final String THUMBNAIL_URL = "thumbnail_url";
//
// public static final String ETAG = "etag";
//
// public static final String TITLE = "title";
//
// public static final String UPDATED = "updated";
//
// public static final String THUMBNAIL_LOCAL_PATH = "thumbnail_local_path";
//
// /*
// * ITable interface methods
// */
//
// private static AlbumsTable mInstance;
//
// public static ITable getInstance() {
// if(null == mInstance) {
// mInstance = new AlbumsTable();
// }
//
// return mInstance;
// }
//
// public String getTableName() {
// return "albums";
// }
//
// public String getCreateTableSQL() {
// String sql = "CREATE TABLE " + getTableName() + " ("
// + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
// + ALBUM_ID + " TEXT,"
// + ETAG + " TEXT,"
// + TITLE + " TEXT,"
// + UPDATED + " TEXT,"
// + THUMBNAIL_LOCAL_PATH + " TEXT"
// + ");";
//
// return sql;
// }
//
// private static HashMap<String, String> mProjectionMap;
// public HashMap<String, String> getProjectionMap() {
// return mProjectionMap;
// }
//
// static {
// mProjectionMap = new HashMap<String, String>();
// mProjectionMap.put(_ID, _ID);
// mProjectionMap.put(ALBUM_ID, ALBUM_ID);
// mProjectionMap.put(ETAG, ETAG);
// mProjectionMap.put(TITLE, TITLE);
// mProjectionMap.put(UPDATED, UPDATED);
// mProjectionMap.put(THUMBNAIL_LOCAL_PATH, THUMBNAIL_LOCAL_PATH);
// }
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/ITable.java
// public interface ITable extends BaseColumns {
//
// String getTableName();
//
// String getCreateTableSQL();
//
// HashMap<String, String> getProjectionMap();
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/PhotosTable.java
// public class PhotosTable implements ITable {
//
// private PhotosTable() {}
//
// /*
// * Column names
// */
// public static final String PHOTO_ID = "photo_id";
//
// public static final String THUMBNAIL_URL = "thumbnail_url";
//
// public static final String ETAG = "etag";
//
// public static final String THUMBNAIL_LOCAL_PATH = "thumbnail_local_path";
//
// public static final String PHOTO_URL = "photo_url";
//
// public static final String ALBUM_ID = "album_id";
//
// /*
// * ITable interface members
// */
//
// private static PhotosTable mInstance;
//
// public static ITable getInstance() {
// if(null == mInstance) {
// mInstance = new PhotosTable();
// }
//
// return mInstance;
// }
//
// public String getCreateTableSQL() {
// String sql = "CREATE TABLE " + getTableName() + " ("
// + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
// + PHOTO_ID + " TEXT,"
// + ETAG + " TEXT,"
// + THUMBNAIL_LOCAL_PATH + " TEXT,"
// + PHOTO_URL + " TEXT,"
// + ALBUM_ID + " TEXT"
// + ");";
//
// return sql;
// }
//
// public String getTableName() {
// return "photos";
// }
//
// private static HashMap<String, String> mProjectionMap;
// public HashMap<String, String> getProjectionMap() {
// return mProjectionMap;
// }
//
// static {
// mProjectionMap = new HashMap<String, String>();
// mProjectionMap.put(_ID, _ID);
// mProjectionMap.put(PHOTO_ID, PHOTO_ID);
// mProjectionMap.put(ETAG, ETAG);
// mProjectionMap.put(PHOTO_URL, PHOTO_URL);
// mProjectionMap.put(THUMBNAIL_LOCAL_PATH, THUMBNAIL_LOCAL_PATH);
// mProjectionMap.put(ALBUM_ID, ALBUM_ID);
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.guaranacode.android.fastpicasabrowser.database.tables.AlbumsTable;
import com.guaranacode.android.fastpicasabrowser.database.tables.ITable;
import com.guaranacode.android.fastpicasabrowser.database.tables.PhotosTable;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; | package com.guaranacode.android.fastpicasabrowser.database;
/**
* Helper for the databased used by the application.
*
* @author abe@guaranacode.com
*
*/
public class DatabaseHelper extends SQLiteOpenHelper {
private List<ITable> mAllTables;
public DatabaseHelper(Context context) {
super(context, DbConstants.DATABASE_NAME, null, DbConstants.DATABASE_VERSION);
mAllTables = new ArrayList<ITable>();
//JAVASUCKS: no collection initializers.
mAllTables.add(AlbumsTable.getInstance()); | // Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/AlbumsTable.java
// public class AlbumsTable implements ITable {
//
// private AlbumsTable() {}
//
// /*
// * Column names
// */
// public static final String ALBUM_ID = "album_id";
//
// public static final String THUMBNAIL_URL = "thumbnail_url";
//
// public static final String ETAG = "etag";
//
// public static final String TITLE = "title";
//
// public static final String UPDATED = "updated";
//
// public static final String THUMBNAIL_LOCAL_PATH = "thumbnail_local_path";
//
// /*
// * ITable interface methods
// */
//
// private static AlbumsTable mInstance;
//
// public static ITable getInstance() {
// if(null == mInstance) {
// mInstance = new AlbumsTable();
// }
//
// return mInstance;
// }
//
// public String getTableName() {
// return "albums";
// }
//
// public String getCreateTableSQL() {
// String sql = "CREATE TABLE " + getTableName() + " ("
// + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
// + ALBUM_ID + " TEXT,"
// + ETAG + " TEXT,"
// + TITLE + " TEXT,"
// + UPDATED + " TEXT,"
// + THUMBNAIL_LOCAL_PATH + " TEXT"
// + ");";
//
// return sql;
// }
//
// private static HashMap<String, String> mProjectionMap;
// public HashMap<String, String> getProjectionMap() {
// return mProjectionMap;
// }
//
// static {
// mProjectionMap = new HashMap<String, String>();
// mProjectionMap.put(_ID, _ID);
// mProjectionMap.put(ALBUM_ID, ALBUM_ID);
// mProjectionMap.put(ETAG, ETAG);
// mProjectionMap.put(TITLE, TITLE);
// mProjectionMap.put(UPDATED, UPDATED);
// mProjectionMap.put(THUMBNAIL_LOCAL_PATH, THUMBNAIL_LOCAL_PATH);
// }
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/ITable.java
// public interface ITable extends BaseColumns {
//
// String getTableName();
//
// String getCreateTableSQL();
//
// HashMap<String, String> getProjectionMap();
// }
//
// Path: src/com/guaranacode/android/fastpicasabrowser/database/tables/PhotosTable.java
// public class PhotosTable implements ITable {
//
// private PhotosTable() {}
//
// /*
// * Column names
// */
// public static final String PHOTO_ID = "photo_id";
//
// public static final String THUMBNAIL_URL = "thumbnail_url";
//
// public static final String ETAG = "etag";
//
// public static final String THUMBNAIL_LOCAL_PATH = "thumbnail_local_path";
//
// public static final String PHOTO_URL = "photo_url";
//
// public static final String ALBUM_ID = "album_id";
//
// /*
// * ITable interface members
// */
//
// private static PhotosTable mInstance;
//
// public static ITable getInstance() {
// if(null == mInstance) {
// mInstance = new PhotosTable();
// }
//
// return mInstance;
// }
//
// public String getCreateTableSQL() {
// String sql = "CREATE TABLE " + getTableName() + " ("
// + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
// + PHOTO_ID + " TEXT,"
// + ETAG + " TEXT,"
// + THUMBNAIL_LOCAL_PATH + " TEXT,"
// + PHOTO_URL + " TEXT,"
// + ALBUM_ID + " TEXT"
// + ");";
//
// return sql;
// }
//
// public String getTableName() {
// return "photos";
// }
//
// private static HashMap<String, String> mProjectionMap;
// public HashMap<String, String> getProjectionMap() {
// return mProjectionMap;
// }
//
// static {
// mProjectionMap = new HashMap<String, String>();
// mProjectionMap.put(_ID, _ID);
// mProjectionMap.put(PHOTO_ID, PHOTO_ID);
// mProjectionMap.put(ETAG, ETAG);
// mProjectionMap.put(PHOTO_URL, PHOTO_URL);
// mProjectionMap.put(THUMBNAIL_LOCAL_PATH, THUMBNAIL_LOCAL_PATH);
// mProjectionMap.put(ALBUM_ID, ALBUM_ID);
// }
//
// }
// Path: src/com/guaranacode/android/fastpicasabrowser/database/DatabaseHelper.java
import java.util.ArrayList;
import java.util.List;
import com.guaranacode.android.fastpicasabrowser.database.tables.AlbumsTable;
import com.guaranacode.android.fastpicasabrowser.database.tables.ITable;
import com.guaranacode.android.fastpicasabrowser.database.tables.PhotosTable;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
package com.guaranacode.android.fastpicasabrowser.database;
/**
* Helper for the databased used by the application.
*
* @author abe@guaranacode.com
*
*/
public class DatabaseHelper extends SQLiteOpenHelper {
private List<ITable> mAllTables;
public DatabaseHelper(Context context) {
super(context, DbConstants.DATABASE_NAME, null, DbConstants.DATABASE_VERSION);
mAllTables = new ArrayList<ITable>();
//JAVASUCKS: no collection initializers.
mAllTables.add(AlbumsTable.getInstance()); | mAllTables.add(PhotosTable.getInstance()); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.