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
|
---|---|---|---|---|---|---|
IPEldorado/RemoteResources | src/com/eldorado/remoteresources/android/common/connection/messages/control/AcknowledgmentMessage.java | // Path: src/com/eldorado/remoteresources/android/common/Status.java
// public enum Status {
// OK, ERROR
// }
| import com.eldorado.remoteresources.android.common.Status; | /*
* (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
*
* This file is part of the software Remote Resources
*
* All rights reserved. This file and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.eldorado.remoteresources.android.common.connection.messages.control;
/**
* This control message acknowledges a control message. If there are any need to
* data to be sent to client, it can be done through data field.
*
* The ack message sequence number is the same of the message that originated
* this ack
*
* @author Marcelo Marzola Bossoni
*
*/
public class AcknowledgmentMessage extends ControlMessage {
private static final long serialVersionUID = -2892553829246464532L;
| // Path: src/com/eldorado/remoteresources/android/common/Status.java
// public enum Status {
// OK, ERROR
// }
// Path: src/com/eldorado/remoteresources/android/common/connection/messages/control/AcknowledgmentMessage.java
import com.eldorado.remoteresources.android.common.Status;
/*
* (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
*
* This file is part of the software Remote Resources
*
* All rights reserved. This file and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.eldorado.remoteresources.android.common.connection.messages.control;
/**
* This control message acknowledges a control message. If there are any need to
* data to be sent to client, it can be done through data field.
*
* The ack message sequence number is the same of the message that originated
* this ack
*
* @author Marcelo Marzola Bossoni
*
*/
public class AcknowledgmentMessage extends ControlMessage {
private static final long serialVersionUID = -2892553829246464532L;
| private final Status status; |
IPEldorado/RemoteResources | src/com/eldorado/remoteresources/ui/KeyButton.java | // Path: src/com/eldorado/remoteresources/android/common/Keys.java
// public enum Keys {
// /** */
// HOME,
// /** */
// BACK,
// /** */
// VOLUME_UP,
// /** */
// VOLUME_DOWN,
// /** */
// POWER,
// /** */
// CAMERA,
// /** */
// CLEAR,
// /** */
// DEL,
// /** */
// FOCUS,
// /** */
// MENU,
// /** */
// SEARCH;
//
// @Override
// public String toString() {
// return "KEYCODE_" + super.toString();
// }
// }
| import javax.swing.JButton;
import com.eldorado.remoteresources.android.common.Keys; | /*
* (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
*
* This file is part of the software Remote Resources
*
* All rights reserved. This file and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.eldorado.remoteresources.ui;
/**
*
*
*
*/
public class KeyButton extends JButton {
private static final long serialVersionUID = 8637146572121840078L;
| // Path: src/com/eldorado/remoteresources/android/common/Keys.java
// public enum Keys {
// /** */
// HOME,
// /** */
// BACK,
// /** */
// VOLUME_UP,
// /** */
// VOLUME_DOWN,
// /** */
// POWER,
// /** */
// CAMERA,
// /** */
// CLEAR,
// /** */
// DEL,
// /** */
// FOCUS,
// /** */
// MENU,
// /** */
// SEARCH;
//
// @Override
// public String toString() {
// return "KEYCODE_" + super.toString();
// }
// }
// Path: src/com/eldorado/remoteresources/ui/KeyButton.java
import javax.swing.JButton;
import com.eldorado.remoteresources.android.common.Keys;
/*
* (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
*
* This file is part of the software Remote Resources
*
* All rights reserved. This file and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.eldorado.remoteresources.ui;
/**
*
*
*
*/
public class KeyButton extends JButton {
private static final long serialVersionUID = 8637146572121840078L;
| private final Keys key; |
IPEldorado/RemoteResources | src/com/eldorado/remoteresources/android/common/connection/messages/control/ControlMessage.java | // Path: src/com/eldorado/remoteresources/android/common/connection/messages/Message.java
// public abstract class Message implements Serializable {
//
// private static final long serialVersionUID = -1051009758389055769L;
//
// public static final int MAX_SEQUENCE_NUMBER = 1 << 16;
//
// /**
// * The message type: check {@link MessageType}
// */
// private final MessageType type;
//
// /**
// * The message sequence number for the client/server connection
// */
// private final int sequenceNumber;
//
// /**
// * Create a new message with a sequence number and type
// *
// * @param sequenceNumber
// * the sequence number
// * @param type
// * the message type
// */
// public Message(int sequenceNumber, MessageType type) {
// this.type = type;
// this.sequenceNumber = sequenceNumber;
// }
//
// /**
// * Get this message type.
// *
// * @return the type of this message
// * @see {@link MessageType} for available types
// */
// public MessageType getMessageType() {
// return type;
// }
//
// /**
// * Get this message sequence number
// *
// * @return this message sequence number
// */
// public int getSequenceNumber() {
// return sequenceNumber;
// }
//
// }
//
// Path: src/com/eldorado/remoteresources/android/common/connection/messages/MessageType.java
// public enum MessageType {
// CONTROL_MESSAGE, DATA_MESSAGE;
// }
| import com.eldorado.remoteresources.android.common.connection.messages.Message;
import com.eldorado.remoteresources.android.common.connection.messages.MessageType; | /*
* (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
*
* This file is part of the software Remote Resources
*
* All rights reserved. This file and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.eldorado.remoteresources.android.common.connection.messages.control;
/**
* The base control message
*
* @author Marcelo Marzola Bossoni
*
*/
public abstract class ControlMessage extends Message {
private static final long serialVersionUID = 110689265311286266L;
/**
* Check {@link ControlMessageType}
*/
private final ControlMessageType messageType;
/**
* Create a new control message
*
* @param sequenceNumber
* @param messageType
*/
public ControlMessage(int sequenceNumber, ControlMessageType messageType) { | // Path: src/com/eldorado/remoteresources/android/common/connection/messages/Message.java
// public abstract class Message implements Serializable {
//
// private static final long serialVersionUID = -1051009758389055769L;
//
// public static final int MAX_SEQUENCE_NUMBER = 1 << 16;
//
// /**
// * The message type: check {@link MessageType}
// */
// private final MessageType type;
//
// /**
// * The message sequence number for the client/server connection
// */
// private final int sequenceNumber;
//
// /**
// * Create a new message with a sequence number and type
// *
// * @param sequenceNumber
// * the sequence number
// * @param type
// * the message type
// */
// public Message(int sequenceNumber, MessageType type) {
// this.type = type;
// this.sequenceNumber = sequenceNumber;
// }
//
// /**
// * Get this message type.
// *
// * @return the type of this message
// * @see {@link MessageType} for available types
// */
// public MessageType getMessageType() {
// return type;
// }
//
// /**
// * Get this message sequence number
// *
// * @return this message sequence number
// */
// public int getSequenceNumber() {
// return sequenceNumber;
// }
//
// }
//
// Path: src/com/eldorado/remoteresources/android/common/connection/messages/MessageType.java
// public enum MessageType {
// CONTROL_MESSAGE, DATA_MESSAGE;
// }
// Path: src/com/eldorado/remoteresources/android/common/connection/messages/control/ControlMessage.java
import com.eldorado.remoteresources.android.common.connection.messages.Message;
import com.eldorado.remoteresources.android.common.connection.messages.MessageType;
/*
* (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
*
* This file is part of the software Remote Resources
*
* All rights reserved. This file and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.eldorado.remoteresources.android.common.connection.messages.control;
/**
* The base control message
*
* @author Marcelo Marzola Bossoni
*
*/
public abstract class ControlMessage extends Message {
private static final long serialVersionUID = 110689265311286266L;
/**
* Check {@link ControlMessageType}
*/
private final ControlMessageType messageType;
/**
* Create a new control message
*
* @param sequenceNumber
* @param messageType
*/
public ControlMessage(int sequenceNumber, ControlMessageType messageType) { | super(sequenceNumber, MessageType.CONTROL_MESSAGE); |
IPEldorado/RemoteResources | src/com/eldorado/remoteresources/ui/wizard/WizardPage.java | // Path: src/com/eldorado/remoteresources/ui/wizard/IWizard.java
// public enum WizardStatus {
// OK, INFO, WARNING, ERROR
// };
| import com.eldorado.remoteresources.ui.wizard.IWizard.WizardStatus;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.SwingWorker; | /*
* (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
*
* This file is part of the software Remote Resources
*
* All rights reserved. This file and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.eldorado.remoteresources.ui.wizard;
/**
* This class is a basic implementation of the {@link IWizardPage} interface
*
* @author Marcelo Marzola Bossoni
*
*/
public abstract class WizardPage extends JPanel implements IWizardPage {
private static final long serialVersionUID = 7968343445732154001L;
private IWizardPage nextPage = null;
private IWizardPage previousPage = null;
private String errorMessage = null;
private String description = null;
| // Path: src/com/eldorado/remoteresources/ui/wizard/IWizard.java
// public enum WizardStatus {
// OK, INFO, WARNING, ERROR
// };
// Path: src/com/eldorado/remoteresources/ui/wizard/WizardPage.java
import com.eldorado.remoteresources.ui.wizard.IWizard.WizardStatus;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
/*
* (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
*
* This file is part of the software Remote Resources
*
* All rights reserved. This file and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.eldorado.remoteresources.ui.wizard;
/**
* This class is a basic implementation of the {@link IWizardPage} interface
*
* @author Marcelo Marzola Bossoni
*
*/
public abstract class WizardPage extends JPanel implements IWizardPage {
private static final long serialVersionUID = 7968343445732154001L;
private IWizardPage nextPage = null;
private IWizardPage previousPage = null;
private String errorMessage = null;
private String description = null;
| private WizardStatus errorLevel = WizardStatus.OK; |
florian-mollin/loto-associatif-app | Loto/src/main/java/com/mollin/loto/gui/parameters/utils/TooltipUtils.java | // Path: Loto/src/main/java/com/mollin/loto/gui/utils/GlyphUtils.java
// public class GlyphUtils {
// private static final GlyphFont GLYPH_FONT_AWESOME = GlyphFontRegistry.font("FontAwesome");
//
// /**
// * Constructeur privé car classe utilitaire
// */
// private GlyphUtils() {
// }
//
// /**
// * Configure un bouton pour lui ajouter un texte et un icon
// *
// * @param <T> Le type de bouton
// * @param button Le bouton à parametrer
// * @param icon L'icon du bouton
// * @param text Le label du bouton
// * @param fontSize La taille de la police
// * @param contentDisplay La position de l'icone
// * @return Le bouton avec l'icone et le label
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon, String text, Double fontSize, ContentDisplay contentDisplay) {
// if (text != null) {
// button.setText(text);
// if (fontSize != null) {
// button.setStyle("-fx-font-size: " + fontSize + "px;");
// }
// }
// if (icon != null) {
// org.controlsfx.glyphfont.Glyph glyphFont = GLYPH_FONT_AWESOME.create(icon);
// if (fontSize != null && fontSize > 0) {
// glyphFont.size(fontSize);
// }
// button.setGraphic(glyphFont);
// }
// if (contentDisplay != null) {
// button.setContentDisplay(contentDisplay);
// }
// return button;
// }
//
// /**
// * @see GlyphUtils#configureButton(javafx.scene.control.ButtonBase,
// * org.controlsfx.glyphfont.FontAwesome.Glyph, java.lang.String,
// * java.lang.Double, javafx.scene.control.ContentDisplay)
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon, String text, Double fontSize) {
// return configureButton(button, icon, text, fontSize, null);
// }
//
// /**
// * @see GlyphUtils#configureButton(javafx.scene.control.ButtonBase,
// * org.controlsfx.glyphfont.FontAwesome.Glyph, java.lang.String,
// * java.lang.Double, javafx.scene.control.ContentDisplay)
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon, String text) {
// return configureButton(button, icon, text, null, null);
// }
//
// /**
// * @see GlyphUtils#configureButton(javafx.scene.control.ButtonBase,
// * org.controlsfx.glyphfont.FontAwesome.Glyph, java.lang.String,
// * java.lang.Double, javafx.scene.control.ContentDisplay)
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon) {
// return configureButton(button, icon, null, null, null);
// }
//
// /**
// * @see GlyphUtils#configureButton(javafx.scene.control.ButtonBase,
// * org.controlsfx.glyphfont.FontAwesome.Glyph, java.lang.String,
// * java.lang.Double, javafx.scene.control.ContentDisplay)
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon, Double fontSize) {
// return configureButton(button, icon, null, fontSize, null);
// }
//
// /**
// * Crée un icon
// *
// * @param icon L'icone à créer
// * @param fontSize La taille de l'icone
// * @return L'icone (sous forme de Label)
// */
// public static Label createLabel(Glyph icon, Double fontSize) {
// if (icon != null) {
// org.controlsfx.glyphfont.Glyph glyphFont = GLYPH_FONT_AWESOME.create(icon);
// if (fontSize != null && fontSize > 0) {
// glyphFont.size(fontSize);
// }
// return glyphFont;
// }
// return new Label();
// }
//
// /**
// * @see GlyphUtils#createLabel(org.controlsfx.glyphfont.FontAwesome.Glyph,
// * java.lang.Double)
// */
// public static Label createLabel(Glyph icon) {
// return createLabel(icon, null);
// }
//
// }
| import com.mollin.loto.gui.utils.GlyphUtils;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import org.controlsfx.control.PopOver;
import org.controlsfx.glyphfont.FontAwesome; | package com.mollin.loto.gui.parameters.utils;
/**
* Classe utilitaires pour la création de "tooltip"
*
* @author MOLLIN Florian
*/
public class TooltipUtils {
/**
* Constructeur privé car classe utilitaire
*/
private TooltipUtils() {
}
/**
* Création d'un icone pour l'affichage de "tooltip"
*
* @param tooltipContent Contenu du "tooltip"
* @return Le label (icon) pour l'affichage du "tooltip"
*/
public static Label createTooltipIcon(String tooltipContent) { | // Path: Loto/src/main/java/com/mollin/loto/gui/utils/GlyphUtils.java
// public class GlyphUtils {
// private static final GlyphFont GLYPH_FONT_AWESOME = GlyphFontRegistry.font("FontAwesome");
//
// /**
// * Constructeur privé car classe utilitaire
// */
// private GlyphUtils() {
// }
//
// /**
// * Configure un bouton pour lui ajouter un texte et un icon
// *
// * @param <T> Le type de bouton
// * @param button Le bouton à parametrer
// * @param icon L'icon du bouton
// * @param text Le label du bouton
// * @param fontSize La taille de la police
// * @param contentDisplay La position de l'icone
// * @return Le bouton avec l'icone et le label
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon, String text, Double fontSize, ContentDisplay contentDisplay) {
// if (text != null) {
// button.setText(text);
// if (fontSize != null) {
// button.setStyle("-fx-font-size: " + fontSize + "px;");
// }
// }
// if (icon != null) {
// org.controlsfx.glyphfont.Glyph glyphFont = GLYPH_FONT_AWESOME.create(icon);
// if (fontSize != null && fontSize > 0) {
// glyphFont.size(fontSize);
// }
// button.setGraphic(glyphFont);
// }
// if (contentDisplay != null) {
// button.setContentDisplay(contentDisplay);
// }
// return button;
// }
//
// /**
// * @see GlyphUtils#configureButton(javafx.scene.control.ButtonBase,
// * org.controlsfx.glyphfont.FontAwesome.Glyph, java.lang.String,
// * java.lang.Double, javafx.scene.control.ContentDisplay)
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon, String text, Double fontSize) {
// return configureButton(button, icon, text, fontSize, null);
// }
//
// /**
// * @see GlyphUtils#configureButton(javafx.scene.control.ButtonBase,
// * org.controlsfx.glyphfont.FontAwesome.Glyph, java.lang.String,
// * java.lang.Double, javafx.scene.control.ContentDisplay)
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon, String text) {
// return configureButton(button, icon, text, null, null);
// }
//
// /**
// * @see GlyphUtils#configureButton(javafx.scene.control.ButtonBase,
// * org.controlsfx.glyphfont.FontAwesome.Glyph, java.lang.String,
// * java.lang.Double, javafx.scene.control.ContentDisplay)
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon) {
// return configureButton(button, icon, null, null, null);
// }
//
// /**
// * @see GlyphUtils#configureButton(javafx.scene.control.ButtonBase,
// * org.controlsfx.glyphfont.FontAwesome.Glyph, java.lang.String,
// * java.lang.Double, javafx.scene.control.ContentDisplay)
// */
// public static <T extends ButtonBase> T configureButton(T button, Glyph icon, Double fontSize) {
// return configureButton(button, icon, null, fontSize, null);
// }
//
// /**
// * Crée un icon
// *
// * @param icon L'icone à créer
// * @param fontSize La taille de l'icone
// * @return L'icone (sous forme de Label)
// */
// public static Label createLabel(Glyph icon, Double fontSize) {
// if (icon != null) {
// org.controlsfx.glyphfont.Glyph glyphFont = GLYPH_FONT_AWESOME.create(icon);
// if (fontSize != null && fontSize > 0) {
// glyphFont.size(fontSize);
// }
// return glyphFont;
// }
// return new Label();
// }
//
// /**
// * @see GlyphUtils#createLabel(org.controlsfx.glyphfont.FontAwesome.Glyph,
// * java.lang.Double)
// */
// public static Label createLabel(Glyph icon) {
// return createLabel(icon, null);
// }
//
// }
// Path: Loto/src/main/java/com/mollin/loto/gui/parameters/utils/TooltipUtils.java
import com.mollin.loto.gui.utils.GlyphUtils;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import org.controlsfx.control.PopOver;
import org.controlsfx.glyphfont.FontAwesome;
package com.mollin.loto.gui.parameters.utils;
/**
* Classe utilitaires pour la création de "tooltip"
*
* @author MOLLIN Florian
*/
public class TooltipUtils {
/**
* Constructeur privé car classe utilitaire
*/
private TooltipUtils() {
}
/**
* Création d'un icone pour l'affichage de "tooltip"
*
* @param tooltipContent Contenu du "tooltip"
* @return Le label (icon) pour l'affichage du "tooltip"
*/
public static Label createTooltipIcon(String tooltipContent) { | Label label = GlyphUtils.createLabel(FontAwesome.Glyph.QUESTION_CIRCLE); |
florian-mollin/loto-associatif-app | Loto/src/main/java/com/mollin/loto/gui/utils/Utils.java | // Path: Loto/src/main/java/com/mollin/loto/gui/main/utils/ScreenFormat.java
// public enum ScreenFormat {
// /**
// * Ecran au format 4:3
// */
// _4_3,
// /**
// * Ecran au format 16:9
// */
// _16_9
// }
| import com.mollin.loto.gui.main.utils.ScreenFormat;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.TextFormatter;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.lang.reflect.Field;
import java.util.function.UnaryOperator; | package com.mollin.loto.gui.utils;
/**
* Classe contenant les méthodes utilitaires
*
* @author MOLLIN Florian
*/
public class Utils {
/**
* Constructeur privé car classe utilitaire
*/
private Utils() {
}
/**
* Css permettant de masquer les séparateurs (des splitPanes)
*/
private static final String DISABLE_SPLIT_PANE_SEPARATOR_CSS = "DisableSplitPaneSeparator.css";
/**
* Nom de l'icone par defaut de l'application
*/
private static final String ICON = "icon.png";
/**
* Permet de masquer ou de faire apparaitre les séparateurs des splitPanes.
*
* @param scene La scene (pour le chargement du css)
* @param display Vrai pour afficher les séparateurs, faux sinon
*/
public static void displaySplitPaneSeparator(Scene scene, boolean display) {
if (display) {
scene.getStylesheets().remove(Utils.class.getResource(DISABLE_SPLIT_PANE_SEPARATOR_CSS).toExternalForm());
} else {
scene.getStylesheets().add(Utils.class.getResource(DISABLE_SPLIT_PANE_SEPARATOR_CSS).toExternalForm());
}
}
/**
* Crée un fond de couleur unie
*
* @param color La couleur du fond
* @return Le fond de couleur donnée
*/
public static Background createBackground(Color color) {
return new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY));
}
/**
* Crée une bordure de couleur unie
*
* @param color La couleur de la bordure
* @param borderWidth La taille de la bordure
* @return Une bordure de couleur unie
*/
public static Border createBorder(Color color, int borderWidth) {
return new Border(new BorderStroke(color, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(borderWidth)));
}
/**
* Renvoi le format courant de l'écran
*
* @param stage Le stage
* @return La taille de l'écran
*/ | // Path: Loto/src/main/java/com/mollin/loto/gui/main/utils/ScreenFormat.java
// public enum ScreenFormat {
// /**
// * Ecran au format 4:3
// */
// _4_3,
// /**
// * Ecran au format 16:9
// */
// _16_9
// }
// Path: Loto/src/main/java/com/mollin/loto/gui/utils/Utils.java
import com.mollin.loto.gui.main.utils.ScreenFormat;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.TextFormatter;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.lang.reflect.Field;
import java.util.function.UnaryOperator;
package com.mollin.loto.gui.utils;
/**
* Classe contenant les méthodes utilitaires
*
* @author MOLLIN Florian
*/
public class Utils {
/**
* Constructeur privé car classe utilitaire
*/
private Utils() {
}
/**
* Css permettant de masquer les séparateurs (des splitPanes)
*/
private static final String DISABLE_SPLIT_PANE_SEPARATOR_CSS = "DisableSplitPaneSeparator.css";
/**
* Nom de l'icone par defaut de l'application
*/
private static final String ICON = "icon.png";
/**
* Permet de masquer ou de faire apparaitre les séparateurs des splitPanes.
*
* @param scene La scene (pour le chargement du css)
* @param display Vrai pour afficher les séparateurs, faux sinon
*/
public static void displaySplitPaneSeparator(Scene scene, boolean display) {
if (display) {
scene.getStylesheets().remove(Utils.class.getResource(DISABLE_SPLIT_PANE_SEPARATOR_CSS).toExternalForm());
} else {
scene.getStylesheets().add(Utils.class.getResource(DISABLE_SPLIT_PANE_SEPARATOR_CSS).toExternalForm());
}
}
/**
* Crée un fond de couleur unie
*
* @param color La couleur du fond
* @return Le fond de couleur donnée
*/
public static Background createBackground(Color color) {
return new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY));
}
/**
* Crée une bordure de couleur unie
*
* @param color La couleur de la bordure
* @param borderWidth La taille de la bordure
* @return Une bordure de couleur unie
*/
public static Border createBorder(Color color, int borderWidth) {
return new Border(new BorderStroke(color, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(borderWidth)));
}
/**
* Renvoi le format courant de l'écran
*
* @param stage Le stage
* @return La taille de l'écran
*/ | public static ScreenFormat getScreenFormat(Stage stage) { |
florian-mollin/loto-associatif-app | Loto/src/main/java/com/mollin/loto/logic/main/grid/LotoGrid.java | // Path: Loto/src/main/java/com/mollin/loto/gui/main/grid/LotoGridGUIListener.java
// public interface LotoGridGUIListener {
//
// /**
// * Evenement lors d'un clic sur un nombre de la grille.
// *
// * @param number Le nombre cliqué par l'utilisateur
// */
// void onClic(int number);
// }
//
// Path: Loto/src/main/java/com/mollin/loto/logic/main/utils/SizedStack.java
// public class SizedStack<T> extends Stack<T> {
// /**
// * Taille maximale de la pile.
// */
// private final int size;
//
// /**
// * Constructeur de la pile.
// *
// * @param size Taille max de la pile.
// */
// public SizedStack(int size) {
// super();
// this.size = size;
// }
//
// @Override
// public T push(T item) {
// while (this.size() >= size) {
// this.remove(0);
// }
// return super.push(item);
// }
//
// @Override
// public boolean add(T item) {
// while (this.size() >= size) {
// this.remove(0);
// }
// return super.add(item);
// }
// }
//
// Path: Loto/src/main/java/com/mollin/loto/logic/storage/GridStorage.java
// public class GridStorage {
// private static final Gson GSON = new GsonBuilder().create();
//
// /**
// * Constructeur privé car classe utilitaire
// */
// private GridStorage() {
// }
//
// /**
// * Sauvegarde de la grille
// *
// * @param grid La grille
// * @param profileName Le nom du profil
// */
// public static void saveGrid(LotoGrid grid, String profileName) {
// Path filePath = Paths.get(Constants.File.PROFILES_FOLDER_PATH, profileName, Constants.File.GRID_FILE_NAME);
// String json = GSON.toJson(grid, LotoGrid.class);
// FileUtils.write(filePath, json);
// }
//
// /**
// * Chargement de la grille
// *
// * @param profileName Le nom du profil
// * @return La grille chargé (ou une grille par défaut si erreur)
// */
// public static LotoGrid loadGrid(String profileName) {
// try {
// Path filePath = Paths.get(Constants.File.PROFILES_FOLDER_PATH, profileName, Constants.File.GRID_FILE_NAME);
// if (filePath == null) {
// return getDefaultGrid(profileName);
// }
// List<String> fileContent = FileUtils.read(filePath);
// if (fileContent == null) {
// return getDefaultGrid(profileName);
// }
// String json = String.join("", fileContent);
// return GSON.fromJson(json, LotoGrid.class);
// } catch (Exception e) {
// return getDefaultGrid(profileName);
// }
// }
//
// /**
// * Renvoi la grille par défaut (grille vierge)
// *
// * @param profileName le nom du profil
// * @return La grille
// */
// private static LotoGrid getDefaultGrid(String profileName) {
// return new LotoGrid(Constants.Size.HISTORY_DEPTH, Constants.Number.MAX_NUMBER, profileName);
// }
// }
| import com.mollin.loto.gui.main.grid.LotoGridGUIListener;
import com.mollin.loto.logic.main.utils.SizedStack;
import com.mollin.loto.logic.storage.GridStorage;
import org.javatuples.Pair;
import java.util.HashSet;
import java.util.Set;
import java.util.Stack; | package com.mollin.loto.logic.main.grid;
/**
* Cette grille représente la "vraie" grille de loto.<br>
* Représente le tirage des nombres, ainsi que l'historique de celui-ci.
*
* @author MOLLIN Florian
*/
public class LotoGrid implements LotoGridInterface, LotoGridGUIListener {
/**
* Nombre max autorisé dans la grille
*/
private final int maxNumber;
/**
* File d'historique des couples (grille;dernier numéro)
*/
private final Stack<Pair<Grid, Integer>> gridHistory;
/**
* Ecouteurs de la grille (pour la partie graphique)
*/
private transient Set<LotoGridListener> listeners;
/**
* Nom du profil
*/
private final String profileName;
/**
* Constructeur de la grille.
*
* @param historyDepth Profondeur de l'historique
* @param maxNumber Nombre maximum autorisé lors d'un tirage
* @param profileName Chemin du fichier de sauvegarde/chargement
*/
public LotoGrid(int historyDepth, int maxNumber, String profileName) { | // Path: Loto/src/main/java/com/mollin/loto/gui/main/grid/LotoGridGUIListener.java
// public interface LotoGridGUIListener {
//
// /**
// * Evenement lors d'un clic sur un nombre de la grille.
// *
// * @param number Le nombre cliqué par l'utilisateur
// */
// void onClic(int number);
// }
//
// Path: Loto/src/main/java/com/mollin/loto/logic/main/utils/SizedStack.java
// public class SizedStack<T> extends Stack<T> {
// /**
// * Taille maximale de la pile.
// */
// private final int size;
//
// /**
// * Constructeur de la pile.
// *
// * @param size Taille max de la pile.
// */
// public SizedStack(int size) {
// super();
// this.size = size;
// }
//
// @Override
// public T push(T item) {
// while (this.size() >= size) {
// this.remove(0);
// }
// return super.push(item);
// }
//
// @Override
// public boolean add(T item) {
// while (this.size() >= size) {
// this.remove(0);
// }
// return super.add(item);
// }
// }
//
// Path: Loto/src/main/java/com/mollin/loto/logic/storage/GridStorage.java
// public class GridStorage {
// private static final Gson GSON = new GsonBuilder().create();
//
// /**
// * Constructeur privé car classe utilitaire
// */
// private GridStorage() {
// }
//
// /**
// * Sauvegarde de la grille
// *
// * @param grid La grille
// * @param profileName Le nom du profil
// */
// public static void saveGrid(LotoGrid grid, String profileName) {
// Path filePath = Paths.get(Constants.File.PROFILES_FOLDER_PATH, profileName, Constants.File.GRID_FILE_NAME);
// String json = GSON.toJson(grid, LotoGrid.class);
// FileUtils.write(filePath, json);
// }
//
// /**
// * Chargement de la grille
// *
// * @param profileName Le nom du profil
// * @return La grille chargé (ou une grille par défaut si erreur)
// */
// public static LotoGrid loadGrid(String profileName) {
// try {
// Path filePath = Paths.get(Constants.File.PROFILES_FOLDER_PATH, profileName, Constants.File.GRID_FILE_NAME);
// if (filePath == null) {
// return getDefaultGrid(profileName);
// }
// List<String> fileContent = FileUtils.read(filePath);
// if (fileContent == null) {
// return getDefaultGrid(profileName);
// }
// String json = String.join("", fileContent);
// return GSON.fromJson(json, LotoGrid.class);
// } catch (Exception e) {
// return getDefaultGrid(profileName);
// }
// }
//
// /**
// * Renvoi la grille par défaut (grille vierge)
// *
// * @param profileName le nom du profil
// * @return La grille
// */
// private static LotoGrid getDefaultGrid(String profileName) {
// return new LotoGrid(Constants.Size.HISTORY_DEPTH, Constants.Number.MAX_NUMBER, profileName);
// }
// }
// Path: Loto/src/main/java/com/mollin/loto/logic/main/grid/LotoGrid.java
import com.mollin.loto.gui.main.grid.LotoGridGUIListener;
import com.mollin.loto.logic.main.utils.SizedStack;
import com.mollin.loto.logic.storage.GridStorage;
import org.javatuples.Pair;
import java.util.HashSet;
import java.util.Set;
import java.util.Stack;
package com.mollin.loto.logic.main.grid;
/**
* Cette grille représente la "vraie" grille de loto.<br>
* Représente le tirage des nombres, ainsi que l'historique de celui-ci.
*
* @author MOLLIN Florian
*/
public class LotoGrid implements LotoGridInterface, LotoGridGUIListener {
/**
* Nombre max autorisé dans la grille
*/
private final int maxNumber;
/**
* File d'historique des couples (grille;dernier numéro)
*/
private final Stack<Pair<Grid, Integer>> gridHistory;
/**
* Ecouteurs de la grille (pour la partie graphique)
*/
private transient Set<LotoGridListener> listeners;
/**
* Nom du profil
*/
private final String profileName;
/**
* Constructeur de la grille.
*
* @param historyDepth Profondeur de l'historique
* @param maxNumber Nombre maximum autorisé lors d'un tirage
* @param profileName Chemin du fichier de sauvegarde/chargement
*/
public LotoGrid(int historyDepth, int maxNumber, String profileName) { | this.gridHistory = new SizedStack<>(historyDepth); |
florian-mollin/loto-associatif-app | Loto/src/main/java/com/mollin/loto/logic/main/grid/LotoGrid.java | // Path: Loto/src/main/java/com/mollin/loto/gui/main/grid/LotoGridGUIListener.java
// public interface LotoGridGUIListener {
//
// /**
// * Evenement lors d'un clic sur un nombre de la grille.
// *
// * @param number Le nombre cliqué par l'utilisateur
// */
// void onClic(int number);
// }
//
// Path: Loto/src/main/java/com/mollin/loto/logic/main/utils/SizedStack.java
// public class SizedStack<T> extends Stack<T> {
// /**
// * Taille maximale de la pile.
// */
// private final int size;
//
// /**
// * Constructeur de la pile.
// *
// * @param size Taille max de la pile.
// */
// public SizedStack(int size) {
// super();
// this.size = size;
// }
//
// @Override
// public T push(T item) {
// while (this.size() >= size) {
// this.remove(0);
// }
// return super.push(item);
// }
//
// @Override
// public boolean add(T item) {
// while (this.size() >= size) {
// this.remove(0);
// }
// return super.add(item);
// }
// }
//
// Path: Loto/src/main/java/com/mollin/loto/logic/storage/GridStorage.java
// public class GridStorage {
// private static final Gson GSON = new GsonBuilder().create();
//
// /**
// * Constructeur privé car classe utilitaire
// */
// private GridStorage() {
// }
//
// /**
// * Sauvegarde de la grille
// *
// * @param grid La grille
// * @param profileName Le nom du profil
// */
// public static void saveGrid(LotoGrid grid, String profileName) {
// Path filePath = Paths.get(Constants.File.PROFILES_FOLDER_PATH, profileName, Constants.File.GRID_FILE_NAME);
// String json = GSON.toJson(grid, LotoGrid.class);
// FileUtils.write(filePath, json);
// }
//
// /**
// * Chargement de la grille
// *
// * @param profileName Le nom du profil
// * @return La grille chargé (ou une grille par défaut si erreur)
// */
// public static LotoGrid loadGrid(String profileName) {
// try {
// Path filePath = Paths.get(Constants.File.PROFILES_FOLDER_PATH, profileName, Constants.File.GRID_FILE_NAME);
// if (filePath == null) {
// return getDefaultGrid(profileName);
// }
// List<String> fileContent = FileUtils.read(filePath);
// if (fileContent == null) {
// return getDefaultGrid(profileName);
// }
// String json = String.join("", fileContent);
// return GSON.fromJson(json, LotoGrid.class);
// } catch (Exception e) {
// return getDefaultGrid(profileName);
// }
// }
//
// /**
// * Renvoi la grille par défaut (grille vierge)
// *
// * @param profileName le nom du profil
// * @return La grille
// */
// private static LotoGrid getDefaultGrid(String profileName) {
// return new LotoGrid(Constants.Size.HISTORY_DEPTH, Constants.Number.MAX_NUMBER, profileName);
// }
// }
| import com.mollin.loto.gui.main.grid.LotoGridGUIListener;
import com.mollin.loto.logic.main.utils.SizedStack;
import com.mollin.loto.logic.storage.GridStorage;
import org.javatuples.Pair;
import java.util.HashSet;
import java.util.Set;
import java.util.Stack; | this.gridHistory.push(Pair.with(newGrid, newLastNumber));
save();
fireUpdate();
}
}
@Override
public void clear() {
if (!this.gridHistory.peek().getValue0().isEmpty()) {
Grid newGrid = new Grid();
this.gridHistory.push(Pair.with(newGrid, null));
save();
fireUpdate();
}
}
@Override
public void undo() {
if (this.gridHistory.size() > 1) {
this.gridHistory.pop();
save();
fireUpdate();
}
}
/**
* Sauvegarde la grille
*/
public void save() {
if (this.profileName != null) { | // Path: Loto/src/main/java/com/mollin/loto/gui/main/grid/LotoGridGUIListener.java
// public interface LotoGridGUIListener {
//
// /**
// * Evenement lors d'un clic sur un nombre de la grille.
// *
// * @param number Le nombre cliqué par l'utilisateur
// */
// void onClic(int number);
// }
//
// Path: Loto/src/main/java/com/mollin/loto/logic/main/utils/SizedStack.java
// public class SizedStack<T> extends Stack<T> {
// /**
// * Taille maximale de la pile.
// */
// private final int size;
//
// /**
// * Constructeur de la pile.
// *
// * @param size Taille max de la pile.
// */
// public SizedStack(int size) {
// super();
// this.size = size;
// }
//
// @Override
// public T push(T item) {
// while (this.size() >= size) {
// this.remove(0);
// }
// return super.push(item);
// }
//
// @Override
// public boolean add(T item) {
// while (this.size() >= size) {
// this.remove(0);
// }
// return super.add(item);
// }
// }
//
// Path: Loto/src/main/java/com/mollin/loto/logic/storage/GridStorage.java
// public class GridStorage {
// private static final Gson GSON = new GsonBuilder().create();
//
// /**
// * Constructeur privé car classe utilitaire
// */
// private GridStorage() {
// }
//
// /**
// * Sauvegarde de la grille
// *
// * @param grid La grille
// * @param profileName Le nom du profil
// */
// public static void saveGrid(LotoGrid grid, String profileName) {
// Path filePath = Paths.get(Constants.File.PROFILES_FOLDER_PATH, profileName, Constants.File.GRID_FILE_NAME);
// String json = GSON.toJson(grid, LotoGrid.class);
// FileUtils.write(filePath, json);
// }
//
// /**
// * Chargement de la grille
// *
// * @param profileName Le nom du profil
// * @return La grille chargé (ou une grille par défaut si erreur)
// */
// public static LotoGrid loadGrid(String profileName) {
// try {
// Path filePath = Paths.get(Constants.File.PROFILES_FOLDER_PATH, profileName, Constants.File.GRID_FILE_NAME);
// if (filePath == null) {
// return getDefaultGrid(profileName);
// }
// List<String> fileContent = FileUtils.read(filePath);
// if (fileContent == null) {
// return getDefaultGrid(profileName);
// }
// String json = String.join("", fileContent);
// return GSON.fromJson(json, LotoGrid.class);
// } catch (Exception e) {
// return getDefaultGrid(profileName);
// }
// }
//
// /**
// * Renvoi la grille par défaut (grille vierge)
// *
// * @param profileName le nom du profil
// * @return La grille
// */
// private static LotoGrid getDefaultGrid(String profileName) {
// return new LotoGrid(Constants.Size.HISTORY_DEPTH, Constants.Number.MAX_NUMBER, profileName);
// }
// }
// Path: Loto/src/main/java/com/mollin/loto/logic/main/grid/LotoGrid.java
import com.mollin.loto.gui.main.grid.LotoGridGUIListener;
import com.mollin.loto.logic.main.utils.SizedStack;
import com.mollin.loto.logic.storage.GridStorage;
import org.javatuples.Pair;
import java.util.HashSet;
import java.util.Set;
import java.util.Stack;
this.gridHistory.push(Pair.with(newGrid, newLastNumber));
save();
fireUpdate();
}
}
@Override
public void clear() {
if (!this.gridHistory.peek().getValue0().isEmpty()) {
Grid newGrid = new Grid();
this.gridHistory.push(Pair.with(newGrid, null));
save();
fireUpdate();
}
}
@Override
public void undo() {
if (this.gridHistory.size() > 1) {
this.gridHistory.pop();
save();
fireUpdate();
}
}
/**
* Sauvegarde la grille
*/
public void save() {
if (this.profileName != null) { | GridStorage.saveGrid(this, this.profileName); |
florian-mollin/loto-associatif-app | Loto/src/main/java/com/mollin/loto/logic/main/utils/Constants.java | // Path: Loto/src/main/java/com/mollin/loto/Loto.java
// public class Loto extends Application {
//
// @Override
// public void init() {
// Font.loadFont(Loto.class.getResource("fontawesome-webfont.ttf").toExternalForm(), -1);
// }
//
// @Override
// public void start(Stage primaryStage) {
// ProfileStageConfigurator.configureStage(primaryStage);
// primaryStage.show();
// }
//
// /**
// * @param args the command line arguments
// */
// public static void main(String[] args) {
// launch(args);
// }
//
// }
| import com.mollin.loto.Loto;
import org.controlsfx.glyphfont.FontAwesome.Glyph;
import java.util.Arrays;
import java.util.List; | package com.mollin.loto.logic.main.utils;
/**
* @author MOLLIN Florian
*/
public interface Constants {
interface Number {
int NB_ROWS = 10;
int NB_COLS = 9;
int MAX_NUMBER = NB_COLS * NB_ROWS;
}
interface Style {
/**
* Classe CSS pour le texte des cellules de la grille
*/
String STYLE_CLASS_CELL_TEXT = "cell_text";
/**
* Classe CSS pour le texte du panneau de dernier numéro
*/
String STYLE_CLASS_PANE_TEXT = "last_number_style_text";
/**
* Classe CSS pour le texte (numéro) du panneau de dernier numéro
*/
String STYLE_CLASS_PANE_NUMBER = "last_number_style_number";
/**
* Classe CSS pour le texte du panneau à textes multiples
*/
String STYLE_CLASS_MULTI_TEXT = "multi_text";
/**
* Feuilles de style (CSS) de l'appli
*/ | // Path: Loto/src/main/java/com/mollin/loto/Loto.java
// public class Loto extends Application {
//
// @Override
// public void init() {
// Font.loadFont(Loto.class.getResource("fontawesome-webfont.ttf").toExternalForm(), -1);
// }
//
// @Override
// public void start(Stage primaryStage) {
// ProfileStageConfigurator.configureStage(primaryStage);
// primaryStage.show();
// }
//
// /**
// * @param args the command line arguments
// */
// public static void main(String[] args) {
// launch(args);
// }
//
// }
// Path: Loto/src/main/java/com/mollin/loto/logic/main/utils/Constants.java
import com.mollin.loto.Loto;
import org.controlsfx.glyphfont.FontAwesome.Glyph;
import java.util.Arrays;
import java.util.List;
package com.mollin.loto.logic.main.utils;
/**
* @author MOLLIN Florian
*/
public interface Constants {
interface Number {
int NB_ROWS = 10;
int NB_COLS = 9;
int MAX_NUMBER = NB_COLS * NB_ROWS;
}
interface Style {
/**
* Classe CSS pour le texte des cellules de la grille
*/
String STYLE_CLASS_CELL_TEXT = "cell_text";
/**
* Classe CSS pour le texte du panneau de dernier numéro
*/
String STYLE_CLASS_PANE_TEXT = "last_number_style_text";
/**
* Classe CSS pour le texte (numéro) du panneau de dernier numéro
*/
String STYLE_CLASS_PANE_NUMBER = "last_number_style_number";
/**
* Classe CSS pour le texte du panneau à textes multiples
*/
String STYLE_CLASS_MULTI_TEXT = "multi_text";
/**
* Feuilles de style (CSS) de l'appli
*/ | List<String> ALL_STYLESHEETS = Arrays.asList(Loto.class.getResource("mainSheet.css").toExternalForm()); |
jpaoletti/jPOS-Presentation-Manager | modules/pm_struts/src/org/jpos/ee/pm/struts/actions/SelectedAction.java | // Path: modules/pm_struts/src/org/jpos/ee/pm/struts/PMStrutsContext.java
// public class PMStrutsContext extends PMContext {
//
// public static final String PM_MAPPINGS = "PM_MAPPINGS";
// public static final String PM_ACTION_FORM = "PM_ACTION_FORM";
// public static final String PM_HTTP_REQUEST = "PM_HTTP_REQUEST";
// public static final String PM_HTTP_RESPONSE = "PM_HTTP_RESPONSE";
// public static final String CONTINUE = "continue";
// public static final String SUCCESS = "success";
// public static final String FAILURE = "failure";
// public static final String USER = "user";
// public static final String DENIED = "denied";
// public static final String STRUTS_LOGIN = "login";
// public static final String PM_LIST = "PMLIST";
// public static final String ENTITY = "entity";
// public static final String REPORT = "report";
// public static final String LOGGER_NAME = "Q2";
// public static final String ACCESS_COUNT = "accessCount";
// public static final String ENTITY_INSTANCE = "entity_instance";
// public static final String ENTITY_SUPPORT = "es";
// public static final String CONTEXT_PATH = "context_path";
// public static final String MENU = "menu";
// public static final String FINISH = "finish";
// public static final String OPERATION = "operation";
// public static final String OPERATIONS = "operations";
// public static final String ITEM_OPERATIONS = "item_operations";
// public static final String PM_ID = "pmid";
// public static final String PM_RID = "pmrid";
// public static final String LAST_PM_ID = "last_pmid";
// public static final String MODIFIED_OWNER_COLLECTION = "moc";
// public static final String PM_MONITOR_CONTINUE = "PM_MONITOR_CONTINUE";
// public static final String PM_MONITOR = "PM_MONITOR";
//
// public PMStrutsContext(String sessionId) {
// super(sessionId);
// }
//
// /**
// * @return the mapping
// */
// public ActionMapping getMapping() {
// return (ActionMapping) get(PM_MAPPINGS);
// }
//
// /**
// * @param mapping the mapping to set
// */
// public void setMapping(ActionMapping mapping) {
// put(PM_MAPPINGS, mapping);
// }
//
// /**
// * @return the form
// */
// public ActionForm getForm() {
// return (ActionForm) get(PM_ACTION_FORM);
// }
//
// /**
// * @param form the form to set
// */
// public void setForm(ActionForm form) {
// put(PM_ACTION_FORM, form);
// }
//
// /**
// * @return the request
// */
// public HttpServletRequest getRequest() {
// return (HttpServletRequest) get(PM_HTTP_REQUEST);
// }
//
// /**
// * @param request the request to set
// */
// public void setRequest(HttpServletRequest request) {
// put(PM_HTTP_REQUEST, request);
// }
//
// /**
// * @return the response
// */
// public HttpServletResponse getResponse() {
// return (HttpServletResponse) get(PM_HTTP_RESPONSE);
// }
//
// /**
// * @param response the response to set
// */
// public void setResponse(HttpServletResponse response) {
// put(PM_HTTP_RESPONSE, response);
// }
//
// /* ActionForwards Helpers */
// /**
// * Helper for success action forward
// * @return success action forward
// */
// public ActionForward successful() {
// return getMapping().findForward(SUCCESS);
// }
//
// /**
// * Helper for continue action forward
// * @return continue action forward
// */
// public ActionForward go() {
// return getMapping().findForward(CONTINUE);
// }
//
// /**
// * Helper for deny action forward
// * @return deny action forward
// */
// public ActionForward deny() {
// return getMapping().findForward(DENIED);
// }
//
// /**
// * Retrieve the http session
// * @return The session
// */
// public HttpSession getSession() {
// return getRequest().getSession();
// }
//
// /**
// * Getter for the entity support helper object
// * @return The entity support
// */
// public PMEntitySupport getEntitySupport() {
// PMEntitySupport r = (PMEntitySupport) getRequest().getSession().getAttribute(ENTITY_SUPPORT);
// return r;
// }
//
// private String getPmId() {
// return (String) getRequest().getAttribute(PM_ID);
// }
//
// public String getTmpName() throws PMException {
// Field field = (Field) get(Constants.PM_FIELD);
// return "tmp_" + getEntity().getId() + "_" + field.getId();
// }
//
// public List<?> getTmpList() {
// try {
// final List<?> r = (List<?>) getSession().getAttribute(getTmpName());
// return r;
// } catch (PMException ex) {
// getPresentationManager().error(ex);
// return null;
// }
// }
// }
| import org.jpos.ee.pm.core.PMException;
import org.jpos.ee.pm.struts.PMStrutsContext; | package org.jpos.ee.pm.struts.actions;
/**This class is specific just for set selected item and use it in general propose
* actions. Main functionality must be in jsp
*
* @author jpaoletti
* */
public class SelectedAction extends RowActionSupport {
@Override | // Path: modules/pm_struts/src/org/jpos/ee/pm/struts/PMStrutsContext.java
// public class PMStrutsContext extends PMContext {
//
// public static final String PM_MAPPINGS = "PM_MAPPINGS";
// public static final String PM_ACTION_FORM = "PM_ACTION_FORM";
// public static final String PM_HTTP_REQUEST = "PM_HTTP_REQUEST";
// public static final String PM_HTTP_RESPONSE = "PM_HTTP_RESPONSE";
// public static final String CONTINUE = "continue";
// public static final String SUCCESS = "success";
// public static final String FAILURE = "failure";
// public static final String USER = "user";
// public static final String DENIED = "denied";
// public static final String STRUTS_LOGIN = "login";
// public static final String PM_LIST = "PMLIST";
// public static final String ENTITY = "entity";
// public static final String REPORT = "report";
// public static final String LOGGER_NAME = "Q2";
// public static final String ACCESS_COUNT = "accessCount";
// public static final String ENTITY_INSTANCE = "entity_instance";
// public static final String ENTITY_SUPPORT = "es";
// public static final String CONTEXT_PATH = "context_path";
// public static final String MENU = "menu";
// public static final String FINISH = "finish";
// public static final String OPERATION = "operation";
// public static final String OPERATIONS = "operations";
// public static final String ITEM_OPERATIONS = "item_operations";
// public static final String PM_ID = "pmid";
// public static final String PM_RID = "pmrid";
// public static final String LAST_PM_ID = "last_pmid";
// public static final String MODIFIED_OWNER_COLLECTION = "moc";
// public static final String PM_MONITOR_CONTINUE = "PM_MONITOR_CONTINUE";
// public static final String PM_MONITOR = "PM_MONITOR";
//
// public PMStrutsContext(String sessionId) {
// super(sessionId);
// }
//
// /**
// * @return the mapping
// */
// public ActionMapping getMapping() {
// return (ActionMapping) get(PM_MAPPINGS);
// }
//
// /**
// * @param mapping the mapping to set
// */
// public void setMapping(ActionMapping mapping) {
// put(PM_MAPPINGS, mapping);
// }
//
// /**
// * @return the form
// */
// public ActionForm getForm() {
// return (ActionForm) get(PM_ACTION_FORM);
// }
//
// /**
// * @param form the form to set
// */
// public void setForm(ActionForm form) {
// put(PM_ACTION_FORM, form);
// }
//
// /**
// * @return the request
// */
// public HttpServletRequest getRequest() {
// return (HttpServletRequest) get(PM_HTTP_REQUEST);
// }
//
// /**
// * @param request the request to set
// */
// public void setRequest(HttpServletRequest request) {
// put(PM_HTTP_REQUEST, request);
// }
//
// /**
// * @return the response
// */
// public HttpServletResponse getResponse() {
// return (HttpServletResponse) get(PM_HTTP_RESPONSE);
// }
//
// /**
// * @param response the response to set
// */
// public void setResponse(HttpServletResponse response) {
// put(PM_HTTP_RESPONSE, response);
// }
//
// /* ActionForwards Helpers */
// /**
// * Helper for success action forward
// * @return success action forward
// */
// public ActionForward successful() {
// return getMapping().findForward(SUCCESS);
// }
//
// /**
// * Helper for continue action forward
// * @return continue action forward
// */
// public ActionForward go() {
// return getMapping().findForward(CONTINUE);
// }
//
// /**
// * Helper for deny action forward
// * @return deny action forward
// */
// public ActionForward deny() {
// return getMapping().findForward(DENIED);
// }
//
// /**
// * Retrieve the http session
// * @return The session
// */
// public HttpSession getSession() {
// return getRequest().getSession();
// }
//
// /**
// * Getter for the entity support helper object
// * @return The entity support
// */
// public PMEntitySupport getEntitySupport() {
// PMEntitySupport r = (PMEntitySupport) getRequest().getSession().getAttribute(ENTITY_SUPPORT);
// return r;
// }
//
// private String getPmId() {
// return (String) getRequest().getAttribute(PM_ID);
// }
//
// public String getTmpName() throws PMException {
// Field field = (Field) get(Constants.PM_FIELD);
// return "tmp_" + getEntity().getId() + "_" + field.getId();
// }
//
// public List<?> getTmpList() {
// try {
// final List<?> r = (List<?>) getSession().getAttribute(getTmpName());
// return r;
// } catch (PMException ex) {
// getPresentationManager().error(ex);
// return null;
// }
// }
// }
// Path: modules/pm_struts/src/org/jpos/ee/pm/struts/actions/SelectedAction.java
import org.jpos.ee.pm.core.PMException;
import org.jpos.ee.pm.struts.PMStrutsContext;
package org.jpos.ee.pm.struts.actions;
/**This class is specific just for set selected item and use it in general propose
* actions. Main functionality must be in jsp
*
* @author jpaoletti
* */
public class SelectedAction extends RowActionSupport {
@Override | protected void doExecute(PMStrutsContext ctx) throws PMException { |
jpaoletti/jPOS-Presentation-Manager | modules/pm_struts/src/org/jpos/ee/pm/struts/PMStrutsService.java | // Path: modules/pm_struts/src/org/jpos/ee/pm/struts/converter/DefaultStrutsConverter.java
// public class DefaultStrutsConverter extends Converter {
//
// @Override
// public Object visualize(PMContext ctx) throws ConverterException {
// Object s = ctx.get(PM_FIELD_VALUE);
// if (s == null) {
// return "void.jsp?text=";
// }
// if (s instanceof String && s.toString().contains(".jsp?") || s.toString().contains(".do?")) {
// return s;
// } else {
// return "void.jsp?text=" + s;
// }
// }
// }
| import org.jpos.ee.Constants;
import org.jpos.ee.pm.core.PMService;
import org.jpos.ee.pm.struts.converter.DefaultStrutsConverter; | /*
* jPOS Project [http://jpos.org]
* Copyright (C) 2000-2010 Alejandro P. Revilla
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jpos.ee.pm.struts;
/**This is an implementation of the PMService for struts.*/
/**
* QBean for struts Presentation Manager service
*
* @author jpaoletti
*/
public class PMStrutsService extends PMService implements Constants {
@Override
protected void initService() throws Exception {
super.initService();
if (getDefaultConverter() == null) { | // Path: modules/pm_struts/src/org/jpos/ee/pm/struts/converter/DefaultStrutsConverter.java
// public class DefaultStrutsConverter extends Converter {
//
// @Override
// public Object visualize(PMContext ctx) throws ConverterException {
// Object s = ctx.get(PM_FIELD_VALUE);
// if (s == null) {
// return "void.jsp?text=";
// }
// if (s instanceof String && s.toString().contains(".jsp?") || s.toString().contains(".do?")) {
// return s;
// } else {
// return "void.jsp?text=" + s;
// }
// }
// }
// Path: modules/pm_struts/src/org/jpos/ee/pm/struts/PMStrutsService.java
import org.jpos.ee.Constants;
import org.jpos.ee.pm.core.PMService;
import org.jpos.ee.pm.struts.converter.DefaultStrutsConverter;
/*
* jPOS Project [http://jpos.org]
* Copyright (C) 2000-2010 Alejandro P. Revilla
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jpos.ee.pm.struts;
/**This is an implementation of the PMService for struts.*/
/**
* QBean for struts Presentation Manager service
*
* @author jpaoletti
*/
public class PMStrutsService extends PMService implements Constants {
@Override
protected void initService() throws Exception {
super.initService();
if (getDefaultConverter() == null) { | setDefaultConverter(new DefaultStrutsConverter()); |
jpaoletti/jPOS-Presentation-Manager | modules/pm_struts/src/org/jpos/ee/pm/struts/actions/ClearFilterAction.java | // Path: modules/pm_struts/src/org/jpos/ee/pm/struts/PMStrutsContext.java
// public class PMStrutsContext extends PMContext {
//
// public static final String PM_MAPPINGS = "PM_MAPPINGS";
// public static final String PM_ACTION_FORM = "PM_ACTION_FORM";
// public static final String PM_HTTP_REQUEST = "PM_HTTP_REQUEST";
// public static final String PM_HTTP_RESPONSE = "PM_HTTP_RESPONSE";
// public static final String CONTINUE = "continue";
// public static final String SUCCESS = "success";
// public static final String FAILURE = "failure";
// public static final String USER = "user";
// public static final String DENIED = "denied";
// public static final String STRUTS_LOGIN = "login";
// public static final String PM_LIST = "PMLIST";
// public static final String ENTITY = "entity";
// public static final String REPORT = "report";
// public static final String LOGGER_NAME = "Q2";
// public static final String ACCESS_COUNT = "accessCount";
// public static final String ENTITY_INSTANCE = "entity_instance";
// public static final String ENTITY_SUPPORT = "es";
// public static final String CONTEXT_PATH = "context_path";
// public static final String MENU = "menu";
// public static final String FINISH = "finish";
// public static final String OPERATION = "operation";
// public static final String OPERATIONS = "operations";
// public static final String ITEM_OPERATIONS = "item_operations";
// public static final String PM_ID = "pmid";
// public static final String PM_RID = "pmrid";
// public static final String LAST_PM_ID = "last_pmid";
// public static final String MODIFIED_OWNER_COLLECTION = "moc";
// public static final String PM_MONITOR_CONTINUE = "PM_MONITOR_CONTINUE";
// public static final String PM_MONITOR = "PM_MONITOR";
//
// public PMStrutsContext(String sessionId) {
// super(sessionId);
// }
//
// /**
// * @return the mapping
// */
// public ActionMapping getMapping() {
// return (ActionMapping) get(PM_MAPPINGS);
// }
//
// /**
// * @param mapping the mapping to set
// */
// public void setMapping(ActionMapping mapping) {
// put(PM_MAPPINGS, mapping);
// }
//
// /**
// * @return the form
// */
// public ActionForm getForm() {
// return (ActionForm) get(PM_ACTION_FORM);
// }
//
// /**
// * @param form the form to set
// */
// public void setForm(ActionForm form) {
// put(PM_ACTION_FORM, form);
// }
//
// /**
// * @return the request
// */
// public HttpServletRequest getRequest() {
// return (HttpServletRequest) get(PM_HTTP_REQUEST);
// }
//
// /**
// * @param request the request to set
// */
// public void setRequest(HttpServletRequest request) {
// put(PM_HTTP_REQUEST, request);
// }
//
// /**
// * @return the response
// */
// public HttpServletResponse getResponse() {
// return (HttpServletResponse) get(PM_HTTP_RESPONSE);
// }
//
// /**
// * @param response the response to set
// */
// public void setResponse(HttpServletResponse response) {
// put(PM_HTTP_RESPONSE, response);
// }
//
// /* ActionForwards Helpers */
// /**
// * Helper for success action forward
// * @return success action forward
// */
// public ActionForward successful() {
// return getMapping().findForward(SUCCESS);
// }
//
// /**
// * Helper for continue action forward
// * @return continue action forward
// */
// public ActionForward go() {
// return getMapping().findForward(CONTINUE);
// }
//
// /**
// * Helper for deny action forward
// * @return deny action forward
// */
// public ActionForward deny() {
// return getMapping().findForward(DENIED);
// }
//
// /**
// * Retrieve the http session
// * @return The session
// */
// public HttpSession getSession() {
// return getRequest().getSession();
// }
//
// /**
// * Getter for the entity support helper object
// * @return The entity support
// */
// public PMEntitySupport getEntitySupport() {
// PMEntitySupport r = (PMEntitySupport) getRequest().getSession().getAttribute(ENTITY_SUPPORT);
// return r;
// }
//
// private String getPmId() {
// return (String) getRequest().getAttribute(PM_ID);
// }
//
// public String getTmpName() throws PMException {
// Field field = (Field) get(Constants.PM_FIELD);
// return "tmp_" + getEntity().getId() + "_" + field.getId();
// }
//
// public List<?> getTmpList() {
// try {
// final List<?> r = (List<?>) getSession().getAttribute(getTmpName());
// return r;
// } catch (PMException ex) {
// getPresentationManager().error(ex);
// return null;
// }
// }
// }
| import org.jpos.ee.pm.core.PMException;
import org.jpos.ee.pm.core.operations.ClearFilterOperation;
import org.jpos.ee.pm.struts.PMStrutsContext; | /*
* jPOS Project [http://jpos.org]
* Copyright (C) 2000-2010 Alejandro P. Revilla
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jpos.ee.pm.struts.actions;
/**
*
* @author jpaoletti
*/
public class ClearFilterAction extends ActionSupport{
@Override | // Path: modules/pm_struts/src/org/jpos/ee/pm/struts/PMStrutsContext.java
// public class PMStrutsContext extends PMContext {
//
// public static final String PM_MAPPINGS = "PM_MAPPINGS";
// public static final String PM_ACTION_FORM = "PM_ACTION_FORM";
// public static final String PM_HTTP_REQUEST = "PM_HTTP_REQUEST";
// public static final String PM_HTTP_RESPONSE = "PM_HTTP_RESPONSE";
// public static final String CONTINUE = "continue";
// public static final String SUCCESS = "success";
// public static final String FAILURE = "failure";
// public static final String USER = "user";
// public static final String DENIED = "denied";
// public static final String STRUTS_LOGIN = "login";
// public static final String PM_LIST = "PMLIST";
// public static final String ENTITY = "entity";
// public static final String REPORT = "report";
// public static final String LOGGER_NAME = "Q2";
// public static final String ACCESS_COUNT = "accessCount";
// public static final String ENTITY_INSTANCE = "entity_instance";
// public static final String ENTITY_SUPPORT = "es";
// public static final String CONTEXT_PATH = "context_path";
// public static final String MENU = "menu";
// public static final String FINISH = "finish";
// public static final String OPERATION = "operation";
// public static final String OPERATIONS = "operations";
// public static final String ITEM_OPERATIONS = "item_operations";
// public static final String PM_ID = "pmid";
// public static final String PM_RID = "pmrid";
// public static final String LAST_PM_ID = "last_pmid";
// public static final String MODIFIED_OWNER_COLLECTION = "moc";
// public static final String PM_MONITOR_CONTINUE = "PM_MONITOR_CONTINUE";
// public static final String PM_MONITOR = "PM_MONITOR";
//
// public PMStrutsContext(String sessionId) {
// super(sessionId);
// }
//
// /**
// * @return the mapping
// */
// public ActionMapping getMapping() {
// return (ActionMapping) get(PM_MAPPINGS);
// }
//
// /**
// * @param mapping the mapping to set
// */
// public void setMapping(ActionMapping mapping) {
// put(PM_MAPPINGS, mapping);
// }
//
// /**
// * @return the form
// */
// public ActionForm getForm() {
// return (ActionForm) get(PM_ACTION_FORM);
// }
//
// /**
// * @param form the form to set
// */
// public void setForm(ActionForm form) {
// put(PM_ACTION_FORM, form);
// }
//
// /**
// * @return the request
// */
// public HttpServletRequest getRequest() {
// return (HttpServletRequest) get(PM_HTTP_REQUEST);
// }
//
// /**
// * @param request the request to set
// */
// public void setRequest(HttpServletRequest request) {
// put(PM_HTTP_REQUEST, request);
// }
//
// /**
// * @return the response
// */
// public HttpServletResponse getResponse() {
// return (HttpServletResponse) get(PM_HTTP_RESPONSE);
// }
//
// /**
// * @param response the response to set
// */
// public void setResponse(HttpServletResponse response) {
// put(PM_HTTP_RESPONSE, response);
// }
//
// /* ActionForwards Helpers */
// /**
// * Helper for success action forward
// * @return success action forward
// */
// public ActionForward successful() {
// return getMapping().findForward(SUCCESS);
// }
//
// /**
// * Helper for continue action forward
// * @return continue action forward
// */
// public ActionForward go() {
// return getMapping().findForward(CONTINUE);
// }
//
// /**
// * Helper for deny action forward
// * @return deny action forward
// */
// public ActionForward deny() {
// return getMapping().findForward(DENIED);
// }
//
// /**
// * Retrieve the http session
// * @return The session
// */
// public HttpSession getSession() {
// return getRequest().getSession();
// }
//
// /**
// * Getter for the entity support helper object
// * @return The entity support
// */
// public PMEntitySupport getEntitySupport() {
// PMEntitySupport r = (PMEntitySupport) getRequest().getSession().getAttribute(ENTITY_SUPPORT);
// return r;
// }
//
// private String getPmId() {
// return (String) getRequest().getAttribute(PM_ID);
// }
//
// public String getTmpName() throws PMException {
// Field field = (Field) get(Constants.PM_FIELD);
// return "tmp_" + getEntity().getId() + "_" + field.getId();
// }
//
// public List<?> getTmpList() {
// try {
// final List<?> r = (List<?>) getSession().getAttribute(getTmpName());
// return r;
// } catch (PMException ex) {
// getPresentationManager().error(ex);
// return null;
// }
// }
// }
// Path: modules/pm_struts/src/org/jpos/ee/pm/struts/actions/ClearFilterAction.java
import org.jpos.ee.pm.core.PMException;
import org.jpos.ee.pm.core.operations.ClearFilterOperation;
import org.jpos.ee.pm.struts.PMStrutsContext;
/*
* jPOS Project [http://jpos.org]
* Copyright (C) 2000-2010 Alejandro P. Revilla
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jpos.ee.pm.struts.actions;
/**
*
* @author jpaoletti
*/
public class ClearFilterAction extends ActionSupport{
@Override | protected void doExecute(PMStrutsContext ctx) throws PMException { |
biojava/biojava | biojava-core/src/test/java/org/biojava/nbio/core/alignment/SimpleAlignedSequenceTest.java | // Path: biojava-core/src/main/java/org/biojava/nbio/core/sequence/compound/AminoAcidCompound.java
// public class AminoAcidCompound extends AbstractCompound implements Serializable {
//
// /**
// *
// */
// private static final long serialVersionUID = -1955116496725902319L;
// private final AminoAcidCompoundSet compoundSet;
//
//
// public AminoAcidCompound(AminoAcidCompoundSet compoundSet, String shortName,
// String longName, String description, Float molecularWeight) {
// super(shortName);
// setShortName(shortName);
// setLongName(longName);
// setDescription(description);
// setMolecularWeight(molecularWeight);
// this.compoundSet = compoundSet;
// }
//
// // TODO need to allow for modified name; that's not equality though is it?
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof AminoAcidCompound)) {
// return false;
// }
// AminoAcidCompound them = (AminoAcidCompound) obj;
// if (toString().equals(them.toString())) {
// return true;
// }
// return getLongName().equals(them.getLongName());
//
// }
//
// @Override
// public int hashCode() {
// return toString().hashCode();
// }
//
// @Override
// public boolean equalsIgnoreCase(Compound compound) {
// if (compound == null) {
// return false;
// }
// if (!(compound instanceof AminoAcidCompound)) {
// return false;
// }
// AminoAcidCompound them = (AminoAcidCompound) compound;
// if (toString().equalsIgnoreCase(them.toString())) {
// return true;
// }
// return getLongName().equalsIgnoreCase(them.getLongName());
// }
//
// public CompoundSet<AminoAcidCompound> getCompoundSet() {
// return compoundSet;
// }
// }
| import org.biojava.nbio.core.sequence.location.SimpleLocation;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.*;
import org.biojava.nbio.core.alignment.template.AlignedSequence;
import org.biojava.nbio.core.alignment.template.AlignedSequence.Step;
import org.biojava.nbio.core.exceptions.CompoundNotFoundException;
import org.biojava.nbio.core.sequence.ProteinSequence;
import org.biojava.nbio.core.sequence.Strand;
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound;
import org.biojava.nbio.core.sequence.compound.AminoAcidCompoundSet; | /*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
* Created on June 15, 2010
* Author: Mark Chapman
*/
package org.biojava.nbio.core.alignment;
public class SimpleAlignedSequenceTest {
private ProteinSequence go, lo; | // Path: biojava-core/src/main/java/org/biojava/nbio/core/sequence/compound/AminoAcidCompound.java
// public class AminoAcidCompound extends AbstractCompound implements Serializable {
//
// /**
// *
// */
// private static final long serialVersionUID = -1955116496725902319L;
// private final AminoAcidCompoundSet compoundSet;
//
//
// public AminoAcidCompound(AminoAcidCompoundSet compoundSet, String shortName,
// String longName, String description, Float molecularWeight) {
// super(shortName);
// setShortName(shortName);
// setLongName(longName);
// setDescription(description);
// setMolecularWeight(molecularWeight);
// this.compoundSet = compoundSet;
// }
//
// // TODO need to allow for modified name; that's not equality though is it?
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof AminoAcidCompound)) {
// return false;
// }
// AminoAcidCompound them = (AminoAcidCompound) obj;
// if (toString().equals(them.toString())) {
// return true;
// }
// return getLongName().equals(them.getLongName());
//
// }
//
// @Override
// public int hashCode() {
// return toString().hashCode();
// }
//
// @Override
// public boolean equalsIgnoreCase(Compound compound) {
// if (compound == null) {
// return false;
// }
// if (!(compound instanceof AminoAcidCompound)) {
// return false;
// }
// AminoAcidCompound them = (AminoAcidCompound) compound;
// if (toString().equalsIgnoreCase(them.toString())) {
// return true;
// }
// return getLongName().equalsIgnoreCase(them.getLongName());
// }
//
// public CompoundSet<AminoAcidCompound> getCompoundSet() {
// return compoundSet;
// }
// }
// Path: biojava-core/src/test/java/org/biojava/nbio/core/alignment/SimpleAlignedSequenceTest.java
import org.biojava.nbio.core.sequence.location.SimpleLocation;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.*;
import org.biojava.nbio.core.alignment.template.AlignedSequence;
import org.biojava.nbio.core.alignment.template.AlignedSequence.Step;
import org.biojava.nbio.core.exceptions.CompoundNotFoundException;
import org.biojava.nbio.core.sequence.ProteinSequence;
import org.biojava.nbio.core.sequence.Strand;
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound;
import org.biojava.nbio.core.sequence.compound.AminoAcidCompoundSet;
/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
* Created on June 15, 2010
* Author: Mark Chapman
*/
package org.biojava.nbio.core.alignment;
public class SimpleAlignedSequenceTest {
private ProteinSequence go, lo; | private AlignedSequence<ProteinSequence, AminoAcidCompound> global, local, local2; |
biojava/biojava | biojava-alignment/src/main/java/org/biojava/nbio/alignment/template/ProfileProfileAligner.java | // Path: biojava-core/src/main/java/org/biojava/nbio/core/alignment/template/ProfilePair.java
// public interface ProfilePair<S extends Sequence<C>, C extends Compound> extends Profile<S, C> {
//
// /**
// * Returns the first {@link Profile} of the pair.
// *
// * @return the first {@link Profile} of the pair
// */
// Profile<S, C> getQuery();
//
// /**
// * Returns the second {@link Profile} of the pair.
// *
// * @return the second {@link Profile} of the pair
// */
// Profile<S, C> getTarget();
//
// }
| import org.biojava.nbio.core.alignment.template.ProfilePair;
import org.biojava.nbio.core.sequence.template.Compound;
import org.biojava.nbio.core.sequence.template.Sequence; | /*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
* Created on June 7, 2010
* Author: Mark Chapman
*/
package org.biojava.nbio.alignment.template;
/**
* Defines an {@link Aligner} for a pair of {@link Profile}s.
*
* @author Mark Chapman
* @param <S> each {@link Sequence} in the pair of alignment {@link Profile}s is of type S
* @param <C> each element of an {@link AlignedSequence} is a {@link Compound} of type C
*/
public interface ProfileProfileAligner<S extends Sequence<C>, C extends Compound> extends Aligner<S, C>,
ProfileProfileScorer<S, C> {
/**
* Returns alignment profile pair.
*
* @return alignment profile pair
*/ | // Path: biojava-core/src/main/java/org/biojava/nbio/core/alignment/template/ProfilePair.java
// public interface ProfilePair<S extends Sequence<C>, C extends Compound> extends Profile<S, C> {
//
// /**
// * Returns the first {@link Profile} of the pair.
// *
// * @return the first {@link Profile} of the pair
// */
// Profile<S, C> getQuery();
//
// /**
// * Returns the second {@link Profile} of the pair.
// *
// * @return the second {@link Profile} of the pair
// */
// Profile<S, C> getTarget();
//
// }
// Path: biojava-alignment/src/main/java/org/biojava/nbio/alignment/template/ProfileProfileAligner.java
import org.biojava.nbio.core.alignment.template.ProfilePair;
import org.biojava.nbio.core.sequence.template.Compound;
import org.biojava.nbio.core.sequence.template.Sequence;
/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
* Created on June 7, 2010
* Author: Mark Chapman
*/
package org.biojava.nbio.alignment.template;
/**
* Defines an {@link Aligner} for a pair of {@link Profile}s.
*
* @author Mark Chapman
* @param <S> each {@link Sequence} in the pair of alignment {@link Profile}s is of type S
* @param <C> each element of an {@link AlignedSequence} is a {@link Compound} of type C
*/
public interface ProfileProfileAligner<S extends Sequence<C>, C extends Compound> extends Aligner<S, C>,
ProfileProfileScorer<S, C> {
/**
* Returns alignment profile pair.
*
* @return alignment profile pair
*/ | ProfilePair<S, C> getPair(); |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/UserConfiguration.java | // Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum FetchBehavior {
// /** Never fetch from the server; Throw errors for missing files */
// LOCAL_ONLY,
// /** Fetch missing files from the server. Don't check for outdated files */
// FETCH_FILES,
// /**
// * Fetch missing files from the server, also fetch if file present but older than the
// * server file.
// * This requires always querying the server for the last modified time of the file, thus
// * it adds an overhead to getting files from cache.
// */
// FETCH_IF_OUTDATED,
// /**
// * Fetch missing files from the server.
// * Also force the download of files older than {@value #LAST_REMEDIATION_DATE_STRING}.
// */
// FETCH_REMEDIATED,
// /** For every file, force downloading from the server */
// FORCE_DOWNLOAD;
//
// public static final FetchBehavior DEFAULT = FETCH_REMEDIATED;
// }
//
// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum ObsoleteBehavior {
// /** Fetch the most recent version of the PDB entry. */
// FETCH_CURRENT,
// /** Fetch the obsolete entry from the PDB archives. */
// FETCH_OBSOLETE,
// /** Throw a StructureException for obsolete entries.*/
// THROW_EXCEPTION;
//
// public static final ObsoleteBehavior DEFAULT=THROW_EXCEPTION;
// }
| import java.io.PrintWriter;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.biojava.nbio.structure.align.ce.StartupParameters;
import org.biojava.nbio.structure.io.LocalPDBDirectory.FetchBehavior;
import org.biojava.nbio.structure.io.LocalPDBDirectory.ObsoleteBehavior;
import org.biojava.nbio.core.util.PrettyXMLWriter;
import org.biojava.nbio.core.util.XMLWriter;
import org.biojava.nbio.structure.io.StructureFiletype;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException; | /*
* PDB web development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
*
* Created on Jul 8, 2009
* Created by ap3
*
*/
package org.biojava.nbio.structure.align.util;
/** A container to persist config to the file system
*
* @author Andreas Prlic
*
*/
public class UserConfiguration
{
private static final Logger logger = LoggerFactory.getLogger(UserConfiguration.class);
public static final String PDB_FORMAT = "PDB";
public static final String MMCIF_FORMAT = "mmCif";
public static final String MMTF_FORMAT = "mmtf";
public static final String BCIF_FORMAT = "bcif";
public static final String TMP_DIR = "java.io.tmpdir";
public static final String PDB_DIR = "PDB_DIR";
public static final String PDB_CACHE_DIR = "PDB_CACHE_DIR";
public static final String lineSplit = System.getProperty("file.separator");
private String pdbFilePath;
private String cacheFilePath;
| // Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum FetchBehavior {
// /** Never fetch from the server; Throw errors for missing files */
// LOCAL_ONLY,
// /** Fetch missing files from the server. Don't check for outdated files */
// FETCH_FILES,
// /**
// * Fetch missing files from the server, also fetch if file present but older than the
// * server file.
// * This requires always querying the server for the last modified time of the file, thus
// * it adds an overhead to getting files from cache.
// */
// FETCH_IF_OUTDATED,
// /**
// * Fetch missing files from the server.
// * Also force the download of files older than {@value #LAST_REMEDIATION_DATE_STRING}.
// */
// FETCH_REMEDIATED,
// /** For every file, force downloading from the server */
// FORCE_DOWNLOAD;
//
// public static final FetchBehavior DEFAULT = FETCH_REMEDIATED;
// }
//
// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum ObsoleteBehavior {
// /** Fetch the most recent version of the PDB entry. */
// FETCH_CURRENT,
// /** Fetch the obsolete entry from the PDB archives. */
// FETCH_OBSOLETE,
// /** Throw a StructureException for obsolete entries.*/
// THROW_EXCEPTION;
//
// public static final ObsoleteBehavior DEFAULT=THROW_EXCEPTION;
// }
// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/UserConfiguration.java
import java.io.PrintWriter;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.biojava.nbio.structure.align.ce.StartupParameters;
import org.biojava.nbio.structure.io.LocalPDBDirectory.FetchBehavior;
import org.biojava.nbio.structure.io.LocalPDBDirectory.ObsoleteBehavior;
import org.biojava.nbio.core.util.PrettyXMLWriter;
import org.biojava.nbio.core.util.XMLWriter;
import org.biojava.nbio.structure.io.StructureFiletype;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
/*
* PDB web development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
*
* Created on Jul 8, 2009
* Created by ap3
*
*/
package org.biojava.nbio.structure.align.util;
/** A container to persist config to the file system
*
* @author Andreas Prlic
*
*/
public class UserConfiguration
{
private static final Logger logger = LoggerFactory.getLogger(UserConfiguration.class);
public static final String PDB_FORMAT = "PDB";
public static final String MMCIF_FORMAT = "mmCif";
public static final String MMTF_FORMAT = "mmtf";
public static final String BCIF_FORMAT = "bcif";
public static final String TMP_DIR = "java.io.tmpdir";
public static final String PDB_DIR = "PDB_DIR";
public static final String PDB_CACHE_DIR = "PDB_CACHE_DIR";
public static final String lineSplit = System.getProperty("file.separator");
private String pdbFilePath;
private String cacheFilePath;
| private FetchBehavior fetchBehavior; |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/UserConfiguration.java | // Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum FetchBehavior {
// /** Never fetch from the server; Throw errors for missing files */
// LOCAL_ONLY,
// /** Fetch missing files from the server. Don't check for outdated files */
// FETCH_FILES,
// /**
// * Fetch missing files from the server, also fetch if file present but older than the
// * server file.
// * This requires always querying the server for the last modified time of the file, thus
// * it adds an overhead to getting files from cache.
// */
// FETCH_IF_OUTDATED,
// /**
// * Fetch missing files from the server.
// * Also force the download of files older than {@value #LAST_REMEDIATION_DATE_STRING}.
// */
// FETCH_REMEDIATED,
// /** For every file, force downloading from the server */
// FORCE_DOWNLOAD;
//
// public static final FetchBehavior DEFAULT = FETCH_REMEDIATED;
// }
//
// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum ObsoleteBehavior {
// /** Fetch the most recent version of the PDB entry. */
// FETCH_CURRENT,
// /** Fetch the obsolete entry from the PDB archives. */
// FETCH_OBSOLETE,
// /** Throw a StructureException for obsolete entries.*/
// THROW_EXCEPTION;
//
// public static final ObsoleteBehavior DEFAULT=THROW_EXCEPTION;
// }
| import java.io.PrintWriter;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.biojava.nbio.structure.align.ce.StartupParameters;
import org.biojava.nbio.structure.io.LocalPDBDirectory.FetchBehavior;
import org.biojava.nbio.structure.io.LocalPDBDirectory.ObsoleteBehavior;
import org.biojava.nbio.core.util.PrettyXMLWriter;
import org.biojava.nbio.core.util.XMLWriter;
import org.biojava.nbio.structure.io.StructureFiletype;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException; | /*
* PDB web development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
*
* Created on Jul 8, 2009
* Created by ap3
*
*/
package org.biojava.nbio.structure.align.util;
/** A container to persist config to the file system
*
* @author Andreas Prlic
*
*/
public class UserConfiguration
{
private static final Logger logger = LoggerFactory.getLogger(UserConfiguration.class);
public static final String PDB_FORMAT = "PDB";
public static final String MMCIF_FORMAT = "mmCif";
public static final String MMTF_FORMAT = "mmtf";
public static final String BCIF_FORMAT = "bcif";
public static final String TMP_DIR = "java.io.tmpdir";
public static final String PDB_DIR = "PDB_DIR";
public static final String PDB_CACHE_DIR = "PDB_CACHE_DIR";
public static final String lineSplit = System.getProperty("file.separator");
private String pdbFilePath;
private String cacheFilePath;
private FetchBehavior fetchBehavior; | // Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum FetchBehavior {
// /** Never fetch from the server; Throw errors for missing files */
// LOCAL_ONLY,
// /** Fetch missing files from the server. Don't check for outdated files */
// FETCH_FILES,
// /**
// * Fetch missing files from the server, also fetch if file present but older than the
// * server file.
// * This requires always querying the server for the last modified time of the file, thus
// * it adds an overhead to getting files from cache.
// */
// FETCH_IF_OUTDATED,
// /**
// * Fetch missing files from the server.
// * Also force the download of files older than {@value #LAST_REMEDIATION_DATE_STRING}.
// */
// FETCH_REMEDIATED,
// /** For every file, force downloading from the server */
// FORCE_DOWNLOAD;
//
// public static final FetchBehavior DEFAULT = FETCH_REMEDIATED;
// }
//
// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum ObsoleteBehavior {
// /** Fetch the most recent version of the PDB entry. */
// FETCH_CURRENT,
// /** Fetch the obsolete entry from the PDB archives. */
// FETCH_OBSOLETE,
// /** Throw a StructureException for obsolete entries.*/
// THROW_EXCEPTION;
//
// public static final ObsoleteBehavior DEFAULT=THROW_EXCEPTION;
// }
// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/UserConfiguration.java
import java.io.PrintWriter;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.biojava.nbio.structure.align.ce.StartupParameters;
import org.biojava.nbio.structure.io.LocalPDBDirectory.FetchBehavior;
import org.biojava.nbio.structure.io.LocalPDBDirectory.ObsoleteBehavior;
import org.biojava.nbio.core.util.PrettyXMLWriter;
import org.biojava.nbio.core.util.XMLWriter;
import org.biojava.nbio.structure.io.StructureFiletype;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
/*
* PDB web development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
*
* Created on Jul 8, 2009
* Created by ap3
*
*/
package org.biojava.nbio.structure.align.util;
/** A container to persist config to the file system
*
* @author Andreas Prlic
*
*/
public class UserConfiguration
{
private static final Logger logger = LoggerFactory.getLogger(UserConfiguration.class);
public static final String PDB_FORMAT = "PDB";
public static final String MMCIF_FORMAT = "mmCif";
public static final String MMTF_FORMAT = "mmtf";
public static final String BCIF_FORMAT = "bcif";
public static final String TMP_DIR = "java.io.tmpdir";
public static final String PDB_DIR = "PDB_DIR";
public static final String PDB_CACHE_DIR = "PDB_CACHE_DIR";
public static final String lineSplit = System.getProperty("file.separator");
private String pdbFilePath;
private String cacheFilePath;
private FetchBehavior fetchBehavior; | private ObsoleteBehavior obsoleteBehavior; |
biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/util/ChromosomeMappingTools.java | // Path: biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/twobit/TwoBitFacade.java
// public class TwoBitFacade {
//
// private TwoBitParser twoBitParser = null;
//
//
// /**
// * Reads a genome from a locally stored .2bit file.
// *
// * @param file the File to a .2bit file.
// */
// public TwoBitFacade(File file) throws Exception {
// twoBitParser = new TwoBitParser(file);
// }
//
// /**
// * Closes .2bit file twoBitParser.
// */
// public void close() throws Exception {
// if (twoBitParser != null)
// twoBitParser.close();
//
// }
//
// /**
// * Sets a chromosome for TwoBitParser.
// *
// * @param chr The chromosome name (e.g. chr21)
// */
// public void setChromosome(String chr) throws Exception {
// if ( twoBitParser == null){
//
// }
// twoBitParser.close();
// String[] names = twoBitParser.getSequenceNames();
// for(int i=0;i<names.length;i++) {
// if ( names[i].equalsIgnoreCase(chr) ) {
// twoBitParser.setCurrentSequence(names[i]);
// break;
// }
// }
// }
//
// /**
// * Extract a sequence from a chromosome, using chromosomal coordinates
// *
// * @param chromosomeName
// * @param start
// * @param end
// * @return the DNASequence from the requested coordinates.
// * @throws Exception
// */
// public String getSequence(String chromosomeName, int start, int end) throws Exception {
// twoBitParser.close();
// twoBitParser.setCurrentSequence(chromosomeName);
// return twoBitParser.loadFragment(start,end-start);
// }
// }
| import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Range;
import org.biojava.nbio.core.sequence.DNASequence;
import org.biojava.nbio.core.sequence.compound.NucleotideCompound;
import org.biojava.nbio.core.sequence.template.SequenceView;
import org.biojava.nbio.genome.parsers.genename.ChromPos;
import org.biojava.nbio.genome.parsers.genename.GeneChromosomePosition;
import org.biojava.nbio.genome.parsers.twobit.TwoBitFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | exonEnds.remove(j);
}
else {
j++;
}
}
// remove untranslated regions from exons
int nExons = exonStarts.size();
exonStarts.remove(0);
exonStarts.add(0, cdsStart);
exonEnds.remove(nExons-1);
exonEnds.add(cdsEnd);
List<Range<Integer>> cdsRegion = new ArrayList<>();
for ( int i=0; i<nExons; i++ ) {
Range<Integer> r = Range.closed(exonStarts.get(i), exonEnds.get(i));
cdsRegion.add(r);
}
return cdsRegion;
}
/**
* Extracts the DNA sequence transcribed from the input genetic coordinates.
*
* @param twoBitFacade the facade that provide an access to a 2bit file
* @param gcp The container with chromosomal positions
*
* @return the DNA sequence transcribed from the input genetic coordinates
*/ | // Path: biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/twobit/TwoBitFacade.java
// public class TwoBitFacade {
//
// private TwoBitParser twoBitParser = null;
//
//
// /**
// * Reads a genome from a locally stored .2bit file.
// *
// * @param file the File to a .2bit file.
// */
// public TwoBitFacade(File file) throws Exception {
// twoBitParser = new TwoBitParser(file);
// }
//
// /**
// * Closes .2bit file twoBitParser.
// */
// public void close() throws Exception {
// if (twoBitParser != null)
// twoBitParser.close();
//
// }
//
// /**
// * Sets a chromosome for TwoBitParser.
// *
// * @param chr The chromosome name (e.g. chr21)
// */
// public void setChromosome(String chr) throws Exception {
// if ( twoBitParser == null){
//
// }
// twoBitParser.close();
// String[] names = twoBitParser.getSequenceNames();
// for(int i=0;i<names.length;i++) {
// if ( names[i].equalsIgnoreCase(chr) ) {
// twoBitParser.setCurrentSequence(names[i]);
// break;
// }
// }
// }
//
// /**
// * Extract a sequence from a chromosome, using chromosomal coordinates
// *
// * @param chromosomeName
// * @param start
// * @param end
// * @return the DNASequence from the requested coordinates.
// * @throws Exception
// */
// public String getSequence(String chromosomeName, int start, int end) throws Exception {
// twoBitParser.close();
// twoBitParser.setCurrentSequence(chromosomeName);
// return twoBitParser.loadFragment(start,end-start);
// }
// }
// Path: biojava-genome/src/main/java/org/biojava/nbio/genome/util/ChromosomeMappingTools.java
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Range;
import org.biojava.nbio.core.sequence.DNASequence;
import org.biojava.nbio.core.sequence.compound.NucleotideCompound;
import org.biojava.nbio.core.sequence.template.SequenceView;
import org.biojava.nbio.genome.parsers.genename.ChromPos;
import org.biojava.nbio.genome.parsers.genename.GeneChromosomePosition;
import org.biojava.nbio.genome.parsers.twobit.TwoBitFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
exonEnds.remove(j);
}
else {
j++;
}
}
// remove untranslated regions from exons
int nExons = exonStarts.size();
exonStarts.remove(0);
exonStarts.add(0, cdsStart);
exonEnds.remove(nExons-1);
exonEnds.add(cdsEnd);
List<Range<Integer>> cdsRegion = new ArrayList<>();
for ( int i=0; i<nExons; i++ ) {
Range<Integer> r = Range.closed(exonStarts.get(i), exonEnds.get(i));
cdsRegion.add(r);
}
return cdsRegion;
}
/**
* Extracts the DNA sequence transcribed from the input genetic coordinates.
*
* @param twoBitFacade the facade that provide an access to a 2bit file
* @param gcp The container with chromosomal positions
*
* @return the DNA sequence transcribed from the input genetic coordinates
*/ | public static DNASequence getTranscriptDNASequence(TwoBitFacade twoBitFacade, GeneChromosomePosition gcp) throws Exception { |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/xml/MultipleAlignmentXMLParser.java | // Path: biojava-structure/src/main/java/org/biojava/nbio/structure/StructureIdentifier.java
// public interface StructureIdentifier extends Serializable {
//
// /**
// * Get the String form of this identifier.
// *
// * It is recommended that the {@link #toString()} method also return the
// * identifier, for consistency during serialization.
// * @return The String form of this identifier
// */
// String getIdentifier();
//
//
// /**
// * Loads a structure encompassing the structure identified.
// * The Structure returned should be suitable for passing as
// * the input to {@link #reduce(Structure)}.
// *
// * It is recommended that the most complete structure available be returned
// * (e.g. the full PDB) to allow processing of unselected portions where
// * appropriate.
// * @param AtomCache A potential sources of structures
// * @return A Structure containing at least the atoms identified by this,
// * or null if Structures are not applicable.
// * @throws StructureException For errors loading and parsing the structure
// * @throws IOException Errors reading the structure from disk
// */
// Structure loadStructure(AtomCache cache) throws StructureException, IOException;
//
// /**
// * Convert to a canonical SubstructureIdentifier.
// *
// * <p>This allows all domains to be converted to a standard format String.
// * @return A SubstructureIdentifier equivalent to this
// * @throws StructureException Wraps exceptions that may be thrown by individual
// * implementations. For example, a SCOP identifier may require that the
// * domain definitions be available for download.
// */
// SubstructureIdentifier toCanonical() throws StructureException;
//
// /**
// * Takes a complete structure as input and reduces it to the substructure
// * represented by this StructureIdentifier.
// *
// * <p>The returned structure may be a shallow copy of the input, with shared
// * Chains, Residues, etc.
// * @param input A full structure, e.g. as loaded from the PDB. The structure
// * ID should match that returned by getPdbId(), if applicable.
// * @return
// * @throws StructureException
// * @see StructureTools#getReducedStructure(Structure, String)
// */
// Structure reduce(Structure input) throws StructureException;
//
// }
| import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import javax.vecmath.Matrix4d;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.biojava.nbio.structure.StructureIdentifier;
import org.biojava.nbio.structure.align.client.StructureName;
import org.biojava.nbio.structure.align.multiple.Block;
import org.biojava.nbio.structure.align.multiple.BlockImpl;
import org.biojava.nbio.structure.align.multiple.BlockSet;
import org.biojava.nbio.structure.align.multiple.BlockSetImpl;
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsemble;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsembleImpl;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentImpl;
import org.biojava.nbio.structure.align.multiple.ScoresCache;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException; |
private static void parseHeader(Node node,
MultipleAlignmentEnsemble ensemble) {
NamedNodeMap atts = node.getAttributes();
String algo = atts.getNamedItem("Algorithm").getTextContent();
if (!algo.equals("null")){
ensemble.setAlgorithmName(algo);
}
String version = atts.getNamedItem("Version").getTextContent();
if (!version.equals("null")){
ensemble.setVersion(version);
}
String ioTime = atts.getNamedItem("IOTime").getTextContent();
if (!ioTime.equals("null")){
ensemble.setIoTime(new Long(ioTime));
}
String time = atts.getNamedItem("CalculationTime").getTextContent();
if (!time.equals("null")){
ensemble.setCalculationTime(new Long(time));
}
}
private static void parseStructures(Node root,
MultipleAlignmentEnsemble ensemble) {
| // Path: biojava-structure/src/main/java/org/biojava/nbio/structure/StructureIdentifier.java
// public interface StructureIdentifier extends Serializable {
//
// /**
// * Get the String form of this identifier.
// *
// * It is recommended that the {@link #toString()} method also return the
// * identifier, for consistency during serialization.
// * @return The String form of this identifier
// */
// String getIdentifier();
//
//
// /**
// * Loads a structure encompassing the structure identified.
// * The Structure returned should be suitable for passing as
// * the input to {@link #reduce(Structure)}.
// *
// * It is recommended that the most complete structure available be returned
// * (e.g. the full PDB) to allow processing of unselected portions where
// * appropriate.
// * @param AtomCache A potential sources of structures
// * @return A Structure containing at least the atoms identified by this,
// * or null if Structures are not applicable.
// * @throws StructureException For errors loading and parsing the structure
// * @throws IOException Errors reading the structure from disk
// */
// Structure loadStructure(AtomCache cache) throws StructureException, IOException;
//
// /**
// * Convert to a canonical SubstructureIdentifier.
// *
// * <p>This allows all domains to be converted to a standard format String.
// * @return A SubstructureIdentifier equivalent to this
// * @throws StructureException Wraps exceptions that may be thrown by individual
// * implementations. For example, a SCOP identifier may require that the
// * domain definitions be available for download.
// */
// SubstructureIdentifier toCanonical() throws StructureException;
//
// /**
// * Takes a complete structure as input and reduces it to the substructure
// * represented by this StructureIdentifier.
// *
// * <p>The returned structure may be a shallow copy of the input, with shared
// * Chains, Residues, etc.
// * @param input A full structure, e.g. as loaded from the PDB. The structure
// * ID should match that returned by getPdbId(), if applicable.
// * @return
// * @throws StructureException
// * @see StructureTools#getReducedStructure(Structure, String)
// */
// Structure reduce(Structure input) throws StructureException;
//
// }
// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/align/xml/MultipleAlignmentXMLParser.java
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import javax.vecmath.Matrix4d;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.biojava.nbio.structure.StructureIdentifier;
import org.biojava.nbio.structure.align.client.StructureName;
import org.biojava.nbio.structure.align.multiple.Block;
import org.biojava.nbio.structure.align.multiple.BlockImpl;
import org.biojava.nbio.structure.align.multiple.BlockSet;
import org.biojava.nbio.structure.align.multiple.BlockSetImpl;
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsemble;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsembleImpl;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentImpl;
import org.biojava.nbio.structure.align.multiple.ScoresCache;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
private static void parseHeader(Node node,
MultipleAlignmentEnsemble ensemble) {
NamedNodeMap atts = node.getAttributes();
String algo = atts.getNamedItem("Algorithm").getTextContent();
if (!algo.equals("null")){
ensemble.setAlgorithmName(algo);
}
String version = atts.getNamedItem("Version").getTextContent();
if (!version.equals("null")){
ensemble.setVersion(version);
}
String ioTime = atts.getNamedItem("IOTime").getTextContent();
if (!ioTime.equals("null")){
ensemble.setIoTime(new Long(ioTime));
}
String time = atts.getNamedItem("CalculationTime").getTextContent();
if (!time.equals("null")){
ensemble.setCalculationTime(new Long(time));
}
}
private static void parseStructures(Node root,
MultipleAlignmentEnsemble ensemble) {
| List<StructureIdentifier> names = new ArrayList<StructureIdentifier>(); |
biojava/biojava | biojava-modfinder/src/test/java/org/biojava/nbio/protmod/structure/TmpAtomCache.java | // Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum FetchBehavior {
// /** Never fetch from the server; Throw errors for missing files */
// LOCAL_ONLY,
// /** Fetch missing files from the server. Don't check for outdated files */
// FETCH_FILES,
// /**
// * Fetch missing files from the server, also fetch if file present but older than the
// * server file.
// * This requires always querying the server for the last modified time of the file, thus
// * it adds an overhead to getting files from cache.
// */
// FETCH_IF_OUTDATED,
// /**
// * Fetch missing files from the server.
// * Also force the download of files older than {@value #LAST_REMEDIATION_DATE_STRING}.
// */
// FETCH_REMEDIATED,
// /** For every file, force downloading from the server */
// FORCE_DOWNLOAD;
//
// public static final FetchBehavior DEFAULT = FETCH_REMEDIATED;
// }
| import org.biojava.nbio.structure.align.util.AtomCache;
import org.biojava.nbio.structure.io.FileParsingParameters;
import org.biojava.nbio.structure.io.LocalPDBDirectory.FetchBehavior; | /*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
* Created on May 11, 2010
* Author: Andreas Prlic
*
*/
package org.biojava.nbio.protmod.structure;
public class TmpAtomCache
{
static String tmpDir = System.getProperty("java.io.tmpdir");
public static AtomCache cache = new AtomCache(tmpDir, tmpDir);
static {
FileParsingParameters params = new FileParsingParameters();
params.setAlignSeqRes(true);
params.setParseSecStruc(false);
params.setCreateAtomBonds(true); | // Path: biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
// public static enum FetchBehavior {
// /** Never fetch from the server; Throw errors for missing files */
// LOCAL_ONLY,
// /** Fetch missing files from the server. Don't check for outdated files */
// FETCH_FILES,
// /**
// * Fetch missing files from the server, also fetch if file present but older than the
// * server file.
// * This requires always querying the server for the last modified time of the file, thus
// * it adds an overhead to getting files from cache.
// */
// FETCH_IF_OUTDATED,
// /**
// * Fetch missing files from the server.
// * Also force the download of files older than {@value #LAST_REMEDIATION_DATE_STRING}.
// */
// FETCH_REMEDIATED,
// /** For every file, force downloading from the server */
// FORCE_DOWNLOAD;
//
// public static final FetchBehavior DEFAULT = FETCH_REMEDIATED;
// }
// Path: biojava-modfinder/src/test/java/org/biojava/nbio/protmod/structure/TmpAtomCache.java
import org.biojava.nbio.structure.align.util.AtomCache;
import org.biojava.nbio.structure.io.FileParsingParameters;
import org.biojava.nbio.structure.io.LocalPDBDirectory.FetchBehavior;
/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
* Created on May 11, 2010
* Author: Andreas Prlic
*
*/
package org.biojava.nbio.protmod.structure;
public class TmpAtomCache
{
static String tmpDir = System.getProperty("java.io.tmpdir");
public static AtomCache cache = new AtomCache(tmpDir, tmpDir);
static {
FileParsingParameters params = new FileParsingParameters();
params.setAlignSeqRes(true);
params.setParseSecStruc(false);
params.setCreateAtomBonds(true); | cache.setFetchBehavior(FetchBehavior.FETCH_REMEDIATED); |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/similarity/SimilarityCalculator.java | // Path: freya/freya-annotate/src/main/java/org/freya/util/NumberUtils.java
// public class NumberUtils {
// public static double roundTwoDecimals(double d) {
// DecimalFormatSymbols decimalSymbols = new DecimalFormatSymbols(Locale.getDefault());
// decimalSymbols.setDecimalSeparator('.');
// decimalSymbols.setGroupingSeparator(' ');
// DecimalFormat twoDForm = new DecimalFormat("#.##");
// twoDForm.setGroupingUsed(false);
// twoDForm.setDecimalFormatSymbols(decimalSymbols);
// return Double.valueOf(twoDForm.format(d));
// }
// }
| import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.util.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
import uk.ac.shef.wit.simmetrics.similaritymetrics.MongeElkan; | float simBtwStrings = 0;
float soundexSim = 0;
int maxNumberOfSynonyms = 3;
// first find synonym of poc and compare to suggestion
Set<String> synonyms =
wordnetInvoker.getSynonyms(text, maxNumberOfSynonyms);
int numberOfSynonyms = 0;
float synonymSim = 0;
for (String syn : synonyms) {
float tmpSim = metrics.getSimilarity(syn, niceLabel);
synonymSim = synonymSim + tmpSim;
logger.debug("sim(" + niceLabel + ",(synonym)" + syn + ")= " + tmpSim);
numberOfSynonyms++;
}
if (numberOfSynonyms > 0) synonymSim = synonymSim / numberOfSynonyms;
// then find synonym of suggestion and compare to poc
Set<String> synonyms2 =
wordnetInvoker.getSynonyms(niceLabel, numberOfSynonyms);
int numberOfSynonyms2 = 0;
float synonymSim2 = 0;
for (String syn : synonyms2) {
float tmpSim = metrics.getSimilarity(syn, text);
synonymSim2 = synonymSim2 + tmpSim;
logger.debug("sim(" + text + ",(synonym)" + syn + ")= " + tmpSim);
numberOfSynonyms2++;
}
if (numberOfSynonyms2 > 0) synonymSim2 = synonymSim2 / numberOfSynonyms2;
simBtwStrings = metrics.getSimilarity(text, niceLabel);
soundexSim = soundex.getSimilarity(text, niceLabel);
double totalSimilarity = | // Path: freya/freya-annotate/src/main/java/org/freya/util/NumberUtils.java
// public class NumberUtils {
// public static double roundTwoDecimals(double d) {
// DecimalFormatSymbols decimalSymbols = new DecimalFormatSymbols(Locale.getDefault());
// decimalSymbols.setDecimalSeparator('.');
// decimalSymbols.setGroupingSeparator(' ');
// DecimalFormat twoDForm = new DecimalFormat("#.##");
// twoDForm.setGroupingUsed(false);
// twoDForm.setDecimalFormatSymbols(decimalSymbols);
// return Double.valueOf(twoDForm.format(d));
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/similarity/SimilarityCalculator.java
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.util.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
import uk.ac.shef.wit.simmetrics.similaritymetrics.MongeElkan;
float simBtwStrings = 0;
float soundexSim = 0;
int maxNumberOfSynonyms = 3;
// first find synonym of poc and compare to suggestion
Set<String> synonyms =
wordnetInvoker.getSynonyms(text, maxNumberOfSynonyms);
int numberOfSynonyms = 0;
float synonymSim = 0;
for (String syn : synonyms) {
float tmpSim = metrics.getSimilarity(syn, niceLabel);
synonymSim = synonymSim + tmpSim;
logger.debug("sim(" + niceLabel + ",(synonym)" + syn + ")= " + tmpSim);
numberOfSynonyms++;
}
if (numberOfSynonyms > 0) synonymSim = synonymSim / numberOfSynonyms;
// then find synonym of suggestion and compare to poc
Set<String> synonyms2 =
wordnetInvoker.getSynonyms(niceLabel, numberOfSynonyms);
int numberOfSynonyms2 = 0;
float synonymSim2 = 0;
for (String syn : synonyms2) {
float tmpSim = metrics.getSimilarity(syn, text);
synonymSim2 = synonymSim2 + tmpSim;
logger.debug("sim(" + text + ",(synonym)" + syn + ")= " + tmpSim);
numberOfSynonyms2++;
}
if (numberOfSynonyms2 > 0) synonymSim2 = synonymSim2 / numberOfSynonyms2;
simBtwStrings = metrics.getSimilarity(text, niceLabel);
soundexSim = soundex.getSimilarity(text, niceLabel);
double totalSimilarity = | NumberUtils.roundTwoDecimals(0.45 * simBtwStrings + 0.15 |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/util/OntologyElementComparator.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
| import java.util.Comparator;
import org.freya.model.Annotation;
import org.freya.model.OntologyElement;
| package org.freya.util;
public class OntologyElementComparator implements Comparator<OntologyElement> {
public int compare(OntologyElement o1, OntologyElement o2) {
| // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
// Path: freya/freya-annotate/src/main/java/org/freya/util/OntologyElementComparator.java
import java.util.Comparator;
import org.freya.model.Annotation;
import org.freya.model.OntologyElement;
package org.freya.util;
public class OntologyElementComparator implements Comparator<OntologyElement> {
public int compare(OntologyElement o1, OntologyElement o2) {
| Annotation a1 = o1.getAnnotation();
|
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/util/OntologyElementListComparator.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
| import java.util.Comparator;
import java.util.List;
import org.freya.model.Annotation;
import org.freya.model.OntologyElement;
| package org.freya.util;
public class OntologyElementListComparator implements Comparator<List<OntologyElement>> {
public int compare(List<OntologyElement> o1, List<OntologyElement> o2) {
| // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
// Path: freya/freya-annotate/src/main/java/org/freya/util/OntologyElementListComparator.java
import java.util.Comparator;
import java.util.List;
import org.freya.model.Annotation;
import org.freya.model.OntologyElement;
package org.freya.util;
public class OntologyElementListComparator implements Comparator<List<OntologyElement>> {
public int compare(List<OntologyElement> o1, List<OntologyElement> o2) {
| Annotation a1 = o1.get(0).getAnnotation();
|
danicadamljanovic/freya | freya/freya-annotate/src/test/java/org/freya/mapping/MapperTest.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/Question.java
// @XmlRootElement
// public class Question {
//
// /**
// * question type such as boolean, number, classic (all the others);
// */
//
// public String sentenceText;
// public Type type;
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// List<HasWord> tokens;
//
// Tree syntaxTree;
//
// /* this is focus */
// POC focus;
//
// List<OntologyElement> answerType;
//
// List<POC> pocs = new ArrayList<POC>();
//
//
// public List<HasWord> getTokens() {
// return tokens;
// }
//
// public void setTokens(List<HasWord> tokens) {
// this.tokens = tokens;
// }
//
//
// List<List<SemanticConcept>> semanticConcepts =
// new ArrayList<List<SemanticConcept>>();
//
// public List<OntologyElement> getAnswerType() {
// return answerType;
// }
//
// public void setAnswerType(List<OntologyElement> answerType) {
// this.answerType = answerType;
// }
//
// public POC getFocus() {
// return focus;
// }
//
// public void setFocus(POC focus) {
// this.focus = focus;
// }
//
// public Tree getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(Tree syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public List<List<SemanticConcept>> getSemanticConcepts() {
// return semanticConcepts;
// }
//
// public void setSemanticConcepts(List<List<SemanticConcept>> semanticConcepts) {
// this.semanticConcepts = semanticConcepts;
// }
//
// public List<POC> getPocs() {
// return pocs;
// }
//
// public void setPocs(List<POC> pocs) {
// this.pocs = pocs;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("sem concepts:");
// if (this.semanticConcepts != null)
// b.append(this.semanticConcepts.toString());
// b.append("pocs:");
// if (this.pocs != null) b.append(pocs.toString());
// b.append("Tree:");
// if (this.syntaxTree != null) b.append(this.syntaxTree.toString());
// return b.toString();
// }
// }
| import static org.junit.Assert.assertEquals;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Question;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | package org.freya.mapping;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class MapperTest {
private static final Log logger = LogFactory.getLog(MapperTest.class);
@Autowired Mapper mapper;
@Test
public void testMapper() throws Exception {
| // Path: freya/freya-annotate/src/main/java/org/freya/model/Question.java
// @XmlRootElement
// public class Question {
//
// /**
// * question type such as boolean, number, classic (all the others);
// */
//
// public String sentenceText;
// public Type type;
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// List<HasWord> tokens;
//
// Tree syntaxTree;
//
// /* this is focus */
// POC focus;
//
// List<OntologyElement> answerType;
//
// List<POC> pocs = new ArrayList<POC>();
//
//
// public List<HasWord> getTokens() {
// return tokens;
// }
//
// public void setTokens(List<HasWord> tokens) {
// this.tokens = tokens;
// }
//
//
// List<List<SemanticConcept>> semanticConcepts =
// new ArrayList<List<SemanticConcept>>();
//
// public List<OntologyElement> getAnswerType() {
// return answerType;
// }
//
// public void setAnswerType(List<OntologyElement> answerType) {
// this.answerType = answerType;
// }
//
// public POC getFocus() {
// return focus;
// }
//
// public void setFocus(POC focus) {
// this.focus = focus;
// }
//
// public Tree getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(Tree syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public List<List<SemanticConcept>> getSemanticConcepts() {
// return semanticConcepts;
// }
//
// public void setSemanticConcepts(List<List<SemanticConcept>> semanticConcepts) {
// this.semanticConcepts = semanticConcepts;
// }
//
// public List<POC> getPocs() {
// return pocs;
// }
//
// public void setPocs(List<POC> pocs) {
// this.pocs = pocs;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("sem concepts:");
// if (this.semanticConcepts != null)
// b.append(this.semanticConcepts.toString());
// b.append("pocs:");
// if (this.pocs != null) b.append(pocs.toString());
// b.append("Tree:");
// if (this.syntaxTree != null) b.append(this.syntaxTree.toString());
// return b.toString();
// }
// }
// Path: freya/freya-annotate/src/test/java/org/freya/mapping/MapperTest.java
import static org.junit.Assert.assertEquals;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Question;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
package org.freya.mapping;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class MapperTest {
private static final Log logger = LogFactory.getLog(MapperTest.class);
@Autowired Mapper mapper;
@Test
public void testMapper() throws Exception {
| Question q = mapper.processQuestion("List cities in california.", false, null, true); |
danicadamljanovic/freya | freya/freya-annotate/src/test/java/org/freya/mapping/FocusDemo.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/Question.java
// @XmlRootElement
// public class Question {
//
// /**
// * question type such as boolean, number, classic (all the others);
// */
//
// public String sentenceText;
// public Type type;
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// List<HasWord> tokens;
//
// Tree syntaxTree;
//
// /* this is focus */
// POC focus;
//
// List<OntologyElement> answerType;
//
// List<POC> pocs = new ArrayList<POC>();
//
//
// public List<HasWord> getTokens() {
// return tokens;
// }
//
// public void setTokens(List<HasWord> tokens) {
// this.tokens = tokens;
// }
//
//
// List<List<SemanticConcept>> semanticConcepts =
// new ArrayList<List<SemanticConcept>>();
//
// public List<OntologyElement> getAnswerType() {
// return answerType;
// }
//
// public void setAnswerType(List<OntologyElement> answerType) {
// this.answerType = answerType;
// }
//
// public POC getFocus() {
// return focus;
// }
//
// public void setFocus(POC focus) {
// this.focus = focus;
// }
//
// public Tree getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(Tree syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public List<List<SemanticConcept>> getSemanticConcepts() {
// return semanticConcepts;
// }
//
// public void setSemanticConcepts(List<List<SemanticConcept>> semanticConcepts) {
// this.semanticConcepts = semanticConcepts;
// }
//
// public List<POC> getPocs() {
// return pocs;
// }
//
// public void setPocs(List<POC> pocs) {
// this.pocs = pocs;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("sem concepts:");
// if (this.semanticConcepts != null)
// b.append(this.semanticConcepts.toString());
// b.append("pocs:");
// if (this.pocs != null) b.append(pocs.toString());
// b.append("Tree:");
// if (this.syntaxTree != null) b.append(this.syntaxTree.toString());
// return b.toString();
// }
// }
| import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Question;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | package org.freya.mapping;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class FocusDemo {
private static final Log logger = LogFactory.getLog(FocusDemo.class);
@Autowired Mapper mapper;
// @Test
public void testMapper() throws Exception {
File inFile = new File("src/test/resources/FactualQuestions.txt");
File outFile = new File("src/test/resources/FactualQuestions-Focus.csv");
//load all questions
PrintStream writer = null;
writer = new PrintStream(outFile);
try (BufferedReader br = new BufferedReader(new FileReader(inFile))) {
String line;
while ((line = br.readLine()) != null) {
// process the line. | // Path: freya/freya-annotate/src/main/java/org/freya/model/Question.java
// @XmlRootElement
// public class Question {
//
// /**
// * question type such as boolean, number, classic (all the others);
// */
//
// public String sentenceText;
// public Type type;
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// List<HasWord> tokens;
//
// Tree syntaxTree;
//
// /* this is focus */
// POC focus;
//
// List<OntologyElement> answerType;
//
// List<POC> pocs = new ArrayList<POC>();
//
//
// public List<HasWord> getTokens() {
// return tokens;
// }
//
// public void setTokens(List<HasWord> tokens) {
// this.tokens = tokens;
// }
//
//
// List<List<SemanticConcept>> semanticConcepts =
// new ArrayList<List<SemanticConcept>>();
//
// public List<OntologyElement> getAnswerType() {
// return answerType;
// }
//
// public void setAnswerType(List<OntologyElement> answerType) {
// this.answerType = answerType;
// }
//
// public POC getFocus() {
// return focus;
// }
//
// public void setFocus(POC focus) {
// this.focus = focus;
// }
//
// public Tree getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(Tree syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public List<List<SemanticConcept>> getSemanticConcepts() {
// return semanticConcepts;
// }
//
// public void setSemanticConcepts(List<List<SemanticConcept>> semanticConcepts) {
// this.semanticConcepts = semanticConcepts;
// }
//
// public List<POC> getPocs() {
// return pocs;
// }
//
// public void setPocs(List<POC> pocs) {
// this.pocs = pocs;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("sem concepts:");
// if (this.semanticConcepts != null)
// b.append(this.semanticConcepts.toString());
// b.append("pocs:");
// if (this.pocs != null) b.append(pocs.toString());
// b.append("Tree:");
// if (this.syntaxTree != null) b.append(this.syntaxTree.toString());
// return b.toString();
// }
// }
// Path: freya/freya-annotate/src/test/java/org/freya/mapping/FocusDemo.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Question;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
package org.freya.mapping;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class FocusDemo {
private static final Log logger = LogFactory.getLog(FocusDemo.class);
@Autowired Mapper mapper;
// @Test
public void testMapper() throws Exception {
File inFile = new File("src/test/resources/FactualQuestions.txt");
File outFile = new File("src/test/resources/FactualQuestions-Focus.csv");
//load all questions
PrintStream writer = null;
writer = new PrintStream(outFile);
try (BufferedReader br = new BufferedReader(new FileReader(inFile))) {
String line;
while ((line = br.readLine()) != null) {
// process the line. | Question q = mapper.processQuestion(line, false, null, true); |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/model/learning/Key.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/DatatypePropertyValueIdentifier.java
// public class DatatypePropertyValueIdentifier implements Serializable{
//
// private List<SerializableURI> instanceURIs;
// private String propertyUri;
// private String propertyValue;
//
// public List<SerializableURI> getInstanceURIs() {
// return instanceURIs;
// }
//
// public void setInstanceURIs(List<SerializableURI> instanceURIs) {
// this.instanceURIs = instanceURIs;
// }
//
// public String getPropertyUri() {
// return propertyUri;
// }
//
// public void setPropertyUri(String propertyName) {
// this.propertyUri = propertyName;
// }
//
// public String getPropertyValue() {
// return propertyValue;
// }
//
// public void setPropertyValue(String propertyValue) {
// this.propertyValue = propertyValue;
// }
//
// /**
// *
// */
// public String toString() {
// StringBuffer result = new StringBuffer("");
//
// result.append(" Datatype property identifier: ").append(
// "\nInstanceURI: ").append(this.instanceURIs.toString()).append(
// "\nProperty URI: ").append(this.propertyUri).append(
// " \nProperty value: ").append(this.propertyValue).toString();
// return result.toString();
//
// }
//
// public boolean equals(DatatypePropertyValueIdentifier anotherObject) {
// if ((this.propertyValue != null)
// && (anotherObject != null)
// && (this.propertyValue == anotherObject.getPropertyValue())
// && (this.propertyUri != null && this.propertyUri
// .equals(anotherObject.getPropertyUri()))
// && (this.instanceURIs != null && this.instanceURIs != null
// && this.instanceURIs
// .toString().equals(
// anotherObject.getInstanceURIs().toString())))
// return true;
// else
// return false;
// }
//
// }
| import org.freya.model.DatatypePropertyValueIdentifier; | package org.freya.model.learning;
//import gate.clone.ql.model.ui.DatatypePropertyValueIdentifier;
public class Key {
String text;
Object ontologyElementIdentifier;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Object getOntologyElementIdentifier() {
return ontologyElementIdentifier;
}
public void setOntologyElementIdentifier(Object ontologyElementIdentifier) {
this.ontologyElementIdentifier = ontologyElementIdentifier;
}
public String toString() {
StringBuffer s = new StringBuffer("Key:");
s.append(text); | // Path: freya/freya-annotate/src/main/java/org/freya/model/DatatypePropertyValueIdentifier.java
// public class DatatypePropertyValueIdentifier implements Serializable{
//
// private List<SerializableURI> instanceURIs;
// private String propertyUri;
// private String propertyValue;
//
// public List<SerializableURI> getInstanceURIs() {
// return instanceURIs;
// }
//
// public void setInstanceURIs(List<SerializableURI> instanceURIs) {
// this.instanceURIs = instanceURIs;
// }
//
// public String getPropertyUri() {
// return propertyUri;
// }
//
// public void setPropertyUri(String propertyName) {
// this.propertyUri = propertyName;
// }
//
// public String getPropertyValue() {
// return propertyValue;
// }
//
// public void setPropertyValue(String propertyValue) {
// this.propertyValue = propertyValue;
// }
//
// /**
// *
// */
// public String toString() {
// StringBuffer result = new StringBuffer("");
//
// result.append(" Datatype property identifier: ").append(
// "\nInstanceURI: ").append(this.instanceURIs.toString()).append(
// "\nProperty URI: ").append(this.propertyUri).append(
// " \nProperty value: ").append(this.propertyValue).toString();
// return result.toString();
//
// }
//
// public boolean equals(DatatypePropertyValueIdentifier anotherObject) {
// if ((this.propertyValue != null)
// && (anotherObject != null)
// && (this.propertyValue == anotherObject.getPropertyValue())
// && (this.propertyUri != null && this.propertyUri
// .equals(anotherObject.getPropertyUri()))
// && (this.instanceURIs != null && this.instanceURIs != null
// && this.instanceURIs
// .toString().equals(
// anotherObject.getInstanceURIs().toString())))
// return true;
// else
// return false;
// }
//
// }
// Path: freya/freya-annotate/src/main/java/org/freya/model/learning/Key.java
import org.freya.model.DatatypePropertyValueIdentifier;
package org.freya.model.learning;
//import gate.clone.ql.model.ui.DatatypePropertyValueIdentifier;
public class Key {
String text;
Object ontologyElementIdentifier;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Object getOntologyElementIdentifier() {
return ontologyElementIdentifier;
}
public void setOntologyElementIdentifier(Object ontologyElementIdentifier) {
this.ontologyElementIdentifier = ontologyElementIdentifier;
}
public String toString() {
StringBuffer s = new StringBuffer("Key:");
s.append(text); | if (ontologyElementIdentifier instanceof DatatypePropertyValueIdentifier) { |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/model/service/FreyaResponse.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/ui/Annotation.java
// @XmlRootElement
// public class Annotation {
//
// String text;
// Long startOffset;
// Long endOffset;
// Double score;
// String uri;
// String type;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffset) {
// this.endOffset = endOffset;
// }
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// @Override public String toString() {
// StringBuilder result = new StringBuilder();
// String NEW_LINE = System.getProperty("line.separator");
//
// result.append(" Annotation {" + NEW_LINE);
// result.append(" text: " + text + NEW_LINE);
// result.append(" start offset: " + startOffset + NEW_LINE);
// result.append(" end offset: " + endOffset + NEW_LINE );
// result.append(" URI: " + uri + NEW_LINE);
// result.append(" score: " + score + NEW_LINE);
// //Note that Collections and Maps also override toString
// result.append(" type: " + type + NEW_LINE);
// result.append("}");
//
// return result.toString();
// }
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/SemanticConcept.java
// @XmlRootElement
// public class SemanticConcept implements Serializable {
//
// OntologyElement ontologyElement;
// String function;
// Boolean verified = false;
// Double score;
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// public Boolean isVerified() {
// return verified;
// }
//
// public void setVerified(Boolean verified) {
// this.verified = verified;
// }
//
// public OntologyElement getOntologyElement() {
// return ontologyElement;
// }
//
// public void setOntologyElement(OntologyElement ontologyElement) {
// this.ontologyElement = ontologyElement;
// }
//
// public String getFunction() {
// return function;
// }
//
// public void setFunction(String function) {
// this.function = function;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("Ontology Elements:\n");
// if (ontologyElement != null) b.append(ontologyElement.toString());
// b.append(" Verified:").append(verified).append("\n");
// b.append(" Function:").append(function).append("\n");
// if (ontologyElement != null)
// b.append("Is ontology element already added:"
// + ontologyElement.isAlreadyAdded() + "\n");
// return b.toString();
// }
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// public boolean equals(Object theOtherConcept) {
// boolean isEqual = false;
// String function1 = this.getFunction();
// String function2 = ((SemanticConcept) theOtherConcept).getFunction();
// OntologyElement element1 = this.getOntologyElement();
// OntologyElement element2 =
// ((SemanticConcept) theOtherConcept).getOntologyElement();
// boolean functionEquals = false;
// if (function1 != null && function2 != null)
// functionEquals = function1.equals(function2);
// else if (function1 == null && function2 == null) functionEquals = true;
// boolean verifiedEquals = false;
// if (this.isVerified().booleanValue() == ((SemanticConcept) theOtherConcept)
// .isVerified().booleanValue()) verifiedEquals = true;
// if (functionEquals && element1.equals(element2))
// isEqual = true;
// // System.out
// // .print("************************************************************calling equals method..result is:"
// // + isEqual);
// return isEqual;
// }
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.freya.model.ui.Annotation;
import org.freya.model.SemanticConcept; | package org.freya.model.service;
@XmlRootElement
public class FreyaResponse {
String repositoryId;
String repositoryUrl;
String sparqlQuery;
String preciseSparql;
Object textResponse;
ArrayList clarifications;
List<List<HashMap>> table;
List<Object> refinementNodes; | // Path: freya/freya-annotate/src/main/java/org/freya/model/ui/Annotation.java
// @XmlRootElement
// public class Annotation {
//
// String text;
// Long startOffset;
// Long endOffset;
// Double score;
// String uri;
// String type;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffset) {
// this.endOffset = endOffset;
// }
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// @Override public String toString() {
// StringBuilder result = new StringBuilder();
// String NEW_LINE = System.getProperty("line.separator");
//
// result.append(" Annotation {" + NEW_LINE);
// result.append(" text: " + text + NEW_LINE);
// result.append(" start offset: " + startOffset + NEW_LINE);
// result.append(" end offset: " + endOffset + NEW_LINE );
// result.append(" URI: " + uri + NEW_LINE);
// result.append(" score: " + score + NEW_LINE);
// //Note that Collections and Maps also override toString
// result.append(" type: " + type + NEW_LINE);
// result.append("}");
//
// return result.toString();
// }
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/SemanticConcept.java
// @XmlRootElement
// public class SemanticConcept implements Serializable {
//
// OntologyElement ontologyElement;
// String function;
// Boolean verified = false;
// Double score;
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// public Boolean isVerified() {
// return verified;
// }
//
// public void setVerified(Boolean verified) {
// this.verified = verified;
// }
//
// public OntologyElement getOntologyElement() {
// return ontologyElement;
// }
//
// public void setOntologyElement(OntologyElement ontologyElement) {
// this.ontologyElement = ontologyElement;
// }
//
// public String getFunction() {
// return function;
// }
//
// public void setFunction(String function) {
// this.function = function;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("Ontology Elements:\n");
// if (ontologyElement != null) b.append(ontologyElement.toString());
// b.append(" Verified:").append(verified).append("\n");
// b.append(" Function:").append(function).append("\n");
// if (ontologyElement != null)
// b.append("Is ontology element already added:"
// + ontologyElement.isAlreadyAdded() + "\n");
// return b.toString();
// }
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// public boolean equals(Object theOtherConcept) {
// boolean isEqual = false;
// String function1 = this.getFunction();
// String function2 = ((SemanticConcept) theOtherConcept).getFunction();
// OntologyElement element1 = this.getOntologyElement();
// OntologyElement element2 =
// ((SemanticConcept) theOtherConcept).getOntologyElement();
// boolean functionEquals = false;
// if (function1 != null && function2 != null)
// functionEquals = function1.equals(function2);
// else if (function1 == null && function2 == null) functionEquals = true;
// boolean verifiedEquals = false;
// if (this.isVerified().booleanValue() == ((SemanticConcept) theOtherConcept)
// .isVerified().booleanValue()) verifiedEquals = true;
// if (functionEquals && element1.equals(element2))
// isEqual = true;
// // System.out
// // .print("************************************************************calling equals method..result is:"
// // + isEqual);
// return isEqual;
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/model/service/FreyaResponse.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.freya.model.ui.Annotation;
import org.freya.model.SemanticConcept;
package org.freya.model.service;
@XmlRootElement
public class FreyaResponse {
String repositoryId;
String repositoryUrl;
String sparqlQuery;
String preciseSparql;
Object textResponse;
ArrayList clarifications;
List<List<HashMap>> table;
List<Object> refinementNodes; | List<List<SemanticConcept>> semanticConcepts; |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/model/service/FreyaResponse.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/ui/Annotation.java
// @XmlRootElement
// public class Annotation {
//
// String text;
// Long startOffset;
// Long endOffset;
// Double score;
// String uri;
// String type;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffset) {
// this.endOffset = endOffset;
// }
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// @Override public String toString() {
// StringBuilder result = new StringBuilder();
// String NEW_LINE = System.getProperty("line.separator");
//
// result.append(" Annotation {" + NEW_LINE);
// result.append(" text: " + text + NEW_LINE);
// result.append(" start offset: " + startOffset + NEW_LINE);
// result.append(" end offset: " + endOffset + NEW_LINE );
// result.append(" URI: " + uri + NEW_LINE);
// result.append(" score: " + score + NEW_LINE);
// //Note that Collections and Maps also override toString
// result.append(" type: " + type + NEW_LINE);
// result.append("}");
//
// return result.toString();
// }
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/SemanticConcept.java
// @XmlRootElement
// public class SemanticConcept implements Serializable {
//
// OntologyElement ontologyElement;
// String function;
// Boolean verified = false;
// Double score;
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// public Boolean isVerified() {
// return verified;
// }
//
// public void setVerified(Boolean verified) {
// this.verified = verified;
// }
//
// public OntologyElement getOntologyElement() {
// return ontologyElement;
// }
//
// public void setOntologyElement(OntologyElement ontologyElement) {
// this.ontologyElement = ontologyElement;
// }
//
// public String getFunction() {
// return function;
// }
//
// public void setFunction(String function) {
// this.function = function;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("Ontology Elements:\n");
// if (ontologyElement != null) b.append(ontologyElement.toString());
// b.append(" Verified:").append(verified).append("\n");
// b.append(" Function:").append(function).append("\n");
// if (ontologyElement != null)
// b.append("Is ontology element already added:"
// + ontologyElement.isAlreadyAdded() + "\n");
// return b.toString();
// }
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// public boolean equals(Object theOtherConcept) {
// boolean isEqual = false;
// String function1 = this.getFunction();
// String function2 = ((SemanticConcept) theOtherConcept).getFunction();
// OntologyElement element1 = this.getOntologyElement();
// OntologyElement element2 =
// ((SemanticConcept) theOtherConcept).getOntologyElement();
// boolean functionEquals = false;
// if (function1 != null && function2 != null)
// functionEquals = function1.equals(function2);
// else if (function1 == null && function2 == null) functionEquals = true;
// boolean verifiedEquals = false;
// if (this.isVerified().booleanValue() == ((SemanticConcept) theOtherConcept)
// .isVerified().booleanValue()) verifiedEquals = true;
// if (functionEquals && element1.equals(element2))
// isEqual = true;
// // System.out
// // .print("************************************************************calling equals method..result is:"
// // + isEqual);
// return isEqual;
// }
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.freya.model.ui.Annotation;
import org.freya.model.SemanticConcept; | package org.freya.model.service;
@XmlRootElement
public class FreyaResponse {
String repositoryId;
String repositoryUrl;
String sparqlQuery;
String preciseSparql;
Object textResponse;
ArrayList clarifications;
List<List<HashMap>> table;
List<Object> refinementNodes;
List<List<SemanticConcept>> semanticConcepts;
ArrayList<Object> graph; | // Path: freya/freya-annotate/src/main/java/org/freya/model/ui/Annotation.java
// @XmlRootElement
// public class Annotation {
//
// String text;
// Long startOffset;
// Long endOffset;
// Double score;
// String uri;
// String type;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffset) {
// this.endOffset = endOffset;
// }
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// @Override public String toString() {
// StringBuilder result = new StringBuilder();
// String NEW_LINE = System.getProperty("line.separator");
//
// result.append(" Annotation {" + NEW_LINE);
// result.append(" text: " + text + NEW_LINE);
// result.append(" start offset: " + startOffset + NEW_LINE);
// result.append(" end offset: " + endOffset + NEW_LINE );
// result.append(" URI: " + uri + NEW_LINE);
// result.append(" score: " + score + NEW_LINE);
// //Note that Collections and Maps also override toString
// result.append(" type: " + type + NEW_LINE);
// result.append("}");
//
// return result.toString();
// }
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/SemanticConcept.java
// @XmlRootElement
// public class SemanticConcept implements Serializable {
//
// OntologyElement ontologyElement;
// String function;
// Boolean verified = false;
// Double score;
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// public Boolean isVerified() {
// return verified;
// }
//
// public void setVerified(Boolean verified) {
// this.verified = verified;
// }
//
// public OntologyElement getOntologyElement() {
// return ontologyElement;
// }
//
// public void setOntologyElement(OntologyElement ontologyElement) {
// this.ontologyElement = ontologyElement;
// }
//
// public String getFunction() {
// return function;
// }
//
// public void setFunction(String function) {
// this.function = function;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("Ontology Elements:\n");
// if (ontologyElement != null) b.append(ontologyElement.toString());
// b.append(" Verified:").append(verified).append("\n");
// b.append(" Function:").append(function).append("\n");
// if (ontologyElement != null)
// b.append("Is ontology element already added:"
// + ontologyElement.isAlreadyAdded() + "\n");
// return b.toString();
// }
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// public boolean equals(Object theOtherConcept) {
// boolean isEqual = false;
// String function1 = this.getFunction();
// String function2 = ((SemanticConcept) theOtherConcept).getFunction();
// OntologyElement element1 = this.getOntologyElement();
// OntologyElement element2 =
// ((SemanticConcept) theOtherConcept).getOntologyElement();
// boolean functionEquals = false;
// if (function1 != null && function2 != null)
// functionEquals = function1.equals(function2);
// else if (function1 == null && function2 == null) functionEquals = true;
// boolean verifiedEquals = false;
// if (this.isVerified().booleanValue() == ((SemanticConcept) theOtherConcept)
// .isVerified().booleanValue()) verifiedEquals = true;
// if (functionEquals && element1.equals(element2))
// isEqual = true;
// // System.out
// // .print("************************************************************calling equals method..result is:"
// // + isEqual);
// return isEqual;
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/model/service/FreyaResponse.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.freya.model.ui.Annotation;
import org.freya.model.SemanticConcept;
package org.freya.model.service;
@XmlRootElement
public class FreyaResponse {
String repositoryId;
String repositoryUrl;
String sparqlQuery;
String preciseSparql;
Object textResponse;
ArrayList clarifications;
List<List<HashMap>> table;
List<Object> refinementNodes;
List<List<SemanticConcept>> semanticConcepts;
ArrayList<Object> graph; | List<Annotation> annotations = new ArrayList<Annotation>(); |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/analyser/QueryCreator.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/QueryElement.java
// public class QueryElement {
//
// List<List<OntologyElement>> ontologyElements;
//
//
//
// public List<List<OntologyElement>> getOntologyElements() {
// return ontologyElements;
// }
//
// public void setOntologyElements(List<List<OntologyElement>> ontologyElements) {
// this.ontologyElements = ontologyElements;
// }
//
// List<String> uris = new ArrayList<String>();
//
// /* query in formal language */
// String queryString;
// /*
// * modifiers that could not be included into the queryString itself, as not
// * supported by formal languages or there is need to perform some
// * calculations or both; most common modifiers are instances of
// * KeyPhraseElement class
// */
// List<InterpretationElement> modifiers;
//
// /**
// * @see java.lang.Object#toString()
// */
// public String toString() {
// return new StringBuffer(this.getClass().getSimpleName().toString())
// .append("\nQuery: ").append(this.queryString)
// // .append(" Modifiers: ")
// // .append(this.modifiers.toString())
// .append("\n").toString();
// }
//
// /**
// * @return the modifiers
// */
// public List<InterpretationElement> getModifiers() {
// return modifiers;
// }
//
// /**
// * @param modifiers
// * the modifiers to set
// */
// public void setModifiers(List<InterpretationElement> modifiers) {
// this.modifiers = modifiers;
// }
//
// /**
// * @return the queryString
// */
// public String getQueryString() {
// return queryString;
// }
//
// /**
// * @param queryString
// * the queryString to set
// */
// public void setQueryString(String queryString) {
// this.queryString = queryString;
// }
//
// /**
// * @return the uris
// */
// public List<String> getUris() {
// return uris;
// }
//
// /**
// * @param uris
// * the uris to set
// */
// public void setUris(List<String> uris) {
// this.uris = uris;
// }
// }
| import org.freya.model.OntologyElement;
import org.freya.model.QueryElement;
import java.util.List;
| package org.freya.analyser;
//import gate.clone.ql.model.ui.OntologyElement;
//import gate.clone.ql.model.ui.QueryElement;
//import gate.util.GateException;
public interface QueryCreator {
/**
* This method creates query string from a given set of resources
*
* @param resources
* @return
*/
public QueryElement getQueryElementFromOntologyElements(
| // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/QueryElement.java
// public class QueryElement {
//
// List<List<OntologyElement>> ontologyElements;
//
//
//
// public List<List<OntologyElement>> getOntologyElements() {
// return ontologyElements;
// }
//
// public void setOntologyElements(List<List<OntologyElement>> ontologyElements) {
// this.ontologyElements = ontologyElements;
// }
//
// List<String> uris = new ArrayList<String>();
//
// /* query in formal language */
// String queryString;
// /*
// * modifiers that could not be included into the queryString itself, as not
// * supported by formal languages or there is need to perform some
// * calculations or both; most common modifiers are instances of
// * KeyPhraseElement class
// */
// List<InterpretationElement> modifiers;
//
// /**
// * @see java.lang.Object#toString()
// */
// public String toString() {
// return new StringBuffer(this.getClass().getSimpleName().toString())
// .append("\nQuery: ").append(this.queryString)
// // .append(" Modifiers: ")
// // .append(this.modifiers.toString())
// .append("\n").toString();
// }
//
// /**
// * @return the modifiers
// */
// public List<InterpretationElement> getModifiers() {
// return modifiers;
// }
//
// /**
// * @param modifiers
// * the modifiers to set
// */
// public void setModifiers(List<InterpretationElement> modifiers) {
// this.modifiers = modifiers;
// }
//
// /**
// * @return the queryString
// */
// public String getQueryString() {
// return queryString;
// }
//
// /**
// * @param queryString
// * the queryString to set
// */
// public void setQueryString(String queryString) {
// this.queryString = queryString;
// }
//
// /**
// * @return the uris
// */
// public List<String> getUris() {
// return uris;
// }
//
// /**
// * @param uris
// * the uris to set
// */
// public void setUris(List<String> uris) {
// this.uris = uris;
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/analyser/QueryCreator.java
import org.freya.model.OntologyElement;
import org.freya.model.QueryElement;
import java.util.List;
package org.freya.analyser;
//import gate.clone.ql.model.ui.OntologyElement;
//import gate.clone.ql.model.ui.QueryElement;
//import gate.util.GateException;
public interface QueryCreator {
/**
* This method creates query string from a given set of resources
*
* @param resources
* @return
*/
public QueryElement getQueryElementFromOntologyElements(
| List<List<OntologyElement>> els) throws Exception;
|
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/util/VoteComparator.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/Vote.java
// public class Vote {
// double vote;
//
// SemanticConcept candidate;
//
// long id;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public double getVote() {
// return vote;
// }
//
// public void setVote(double vote) {
// this.vote = vote;
// }
//
// public SemanticConcept getCandidate() {
// return candidate;
// }
//
// public void setCandidate(SemanticConcept candidate) {
// this.candidate = candidate;
// }
//
// public String toString() {
// StringBuffer s = new StringBuffer("");
// s.append("Vote id:").append(id).append(" Score:").append(vote);
// if(candidate != null)
// s.append("\nCandidate:" + candidate.toString()).append("\n");
// return s.toString();
// }
// }
| import java.util.Comparator;
import org.freya.model.Vote; | package org.freya.util;
public class VoteComparator implements Comparator {
public int compare(Object o1, Object o2){ | // Path: freya/freya-annotate/src/main/java/org/freya/model/Vote.java
// public class Vote {
// double vote;
//
// SemanticConcept candidate;
//
// long id;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public double getVote() {
// return vote;
// }
//
// public void setVote(double vote) {
// this.vote = vote;
// }
//
// public SemanticConcept getCandidate() {
// return candidate;
// }
//
// public void setCandidate(SemanticConcept candidate) {
// this.candidate = candidate;
// }
//
// public String toString() {
// StringBuffer s = new StringBuffer("");
// s.append("Vote id:").append(id).append(" Score:").append(vote);
// if(candidate != null)
// s.append("\nCandidate:" + candidate.toString()).append("\n");
// return s.toString();
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/util/VoteComparator.java
import java.util.Comparator;
import org.freya.model.Vote;
package org.freya.util;
public class VoteComparator implements Comparator {
public int compare(Object o1, Object o2){ | Vote voteOne = (Vote)o1; |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/regex/ExpressionFinder.java | // Path: freya/freya-annotate/src/main/java/org/freya/rdf/query/CATConstants.java
// public class CATConstants {
//
// public static String TYPE_INSTANCE = "instance";
//
// public static String FEATURE_INSTANCE_URI = "instanceURI";
//
// /* used to set feature names for Lookups inside OntoRootGaz */
// public static String FEATURE_URI = "URI";
// public static String FEATURE_TYPE_CLASS = "class";
//
// public static String FEATURE_PROPERTY_URI = "propertyURI";
//
// public static String FEATURE_PROPERTY_VALUE = "propertyValue";
//
// public static String FEATURE_HEURISTIC_LEVEL = "heuristic_level";
//
// public static String FEATURE_HEURISTIC_VALUE = "heuristic_value";
//
//
//
// public static String CLASS_URI = "classURI";
//
// public static String CLASS_URI_LIST = "classURIList";
//
// public static String TYPE_PROPERTY = "property";
//
// public static String TYPE_DATATYPE_PROPERTY_VALUE = "datatypePropertyValue";
//
// public static String ANNOTATION_TYPE_ONTORES = "OntoRes";
//
// public static String ANNOTATION_TYPE_ONTORESCHUNK = "OntoResChunk";
//
// /** used to set feature names for Lookups inside OntoRootGaz */
// public static String TYPE_FEATURE = "type";
//
// /**
// * Name of the common logger
// */
//
// public static String LOGGER_OUPUT_LEVEL = "2000";
//
// /** separator used during formatting of results */
// public static String NEW_LINE =System.getProperty("line.separator");// "\n";
//
// public static String REGEX_CAMEL_CASE = "[a-z][A-Z]";
//
// }
| import org.apache.oro.text.awk.AwkCompiler;
import org.apache.oro.text.awk.AwkMatcher;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.MatchResult;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternCompiler;
import org.apache.oro.text.regex.PatternMatcher;
import org.apache.oro.text.regex.PatternMatcherInput;
import org.apache.oro.text.regex.StringSubstitution;
import org.apache.oro.text.regex.Substitution;
import org.apache.oro.text.regex.Util;
import org.freya.rdf.query.CATConstants;
| // Create AwkCompiler and AwkMatcher instances.
compiler = new AwkCompiler();
matcher = new AwkMatcher();
// Attempt to compile the pattern. If the pattern is not valid,
// report the error and exit.
try {
pattern = compiler.compile(regularExpression);
} catch (MalformedPatternException e) {
System.err.println("Bad pattern.");
System.err.println(e.getMessage());
System.exit(1);
}
input = new PatternMatcherInput(inputString);
// System.out.println("\nPatternMatcherInput: " + input);
while (matcher.contains(input, pattern)) {
result = true;
}
return result;
}
/**
* Main method for testing.
*
* @param args
*/
public static final void main(String args[]) {
String inputString = "camelCaseDetection";
String inputString1 = "AI";
String resultString = findAndSeparateCamelCases(inputString1,
| // Path: freya/freya-annotate/src/main/java/org/freya/rdf/query/CATConstants.java
// public class CATConstants {
//
// public static String TYPE_INSTANCE = "instance";
//
// public static String FEATURE_INSTANCE_URI = "instanceURI";
//
// /* used to set feature names for Lookups inside OntoRootGaz */
// public static String FEATURE_URI = "URI";
// public static String FEATURE_TYPE_CLASS = "class";
//
// public static String FEATURE_PROPERTY_URI = "propertyURI";
//
// public static String FEATURE_PROPERTY_VALUE = "propertyValue";
//
// public static String FEATURE_HEURISTIC_LEVEL = "heuristic_level";
//
// public static String FEATURE_HEURISTIC_VALUE = "heuristic_value";
//
//
//
// public static String CLASS_URI = "classURI";
//
// public static String CLASS_URI_LIST = "classURIList";
//
// public static String TYPE_PROPERTY = "property";
//
// public static String TYPE_DATATYPE_PROPERTY_VALUE = "datatypePropertyValue";
//
// public static String ANNOTATION_TYPE_ONTORES = "OntoRes";
//
// public static String ANNOTATION_TYPE_ONTORESCHUNK = "OntoResChunk";
//
// /** used to set feature names for Lookups inside OntoRootGaz */
// public static String TYPE_FEATURE = "type";
//
// /**
// * Name of the common logger
// */
//
// public static String LOGGER_OUPUT_LEVEL = "2000";
//
// /** separator used during formatting of results */
// public static String NEW_LINE =System.getProperty("line.separator");// "\n";
//
// public static String REGEX_CAMEL_CASE = "[a-z][A-Z]";
//
// }
// Path: freya/freya-annotate/src/main/java/org/freya/regex/ExpressionFinder.java
import org.apache.oro.text.awk.AwkCompiler;
import org.apache.oro.text.awk.AwkMatcher;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.MatchResult;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternCompiler;
import org.apache.oro.text.regex.PatternMatcher;
import org.apache.oro.text.regex.PatternMatcherInput;
import org.apache.oro.text.regex.StringSubstitution;
import org.apache.oro.text.regex.Substitution;
import org.apache.oro.text.regex.Util;
import org.freya.rdf.query.CATConstants;
// Create AwkCompiler and AwkMatcher instances.
compiler = new AwkCompiler();
matcher = new AwkMatcher();
// Attempt to compile the pattern. If the pattern is not valid,
// report the error and exit.
try {
pattern = compiler.compile(regularExpression);
} catch (MalformedPatternException e) {
System.err.println("Bad pattern.");
System.err.println(e.getMessage());
System.exit(1);
}
input = new PatternMatcherInput(inputString);
// System.out.println("\nPatternMatcherInput: " + input);
while (matcher.contains(input, pattern)) {
result = true;
}
return result;
}
/**
* Main method for testing.
*
* @param args
*/
public static final void main(String args[]) {
String inputString = "camelCaseDetection";
String inputString1 = "AI";
String resultString = findAndSeparateCamelCases(inputString1,
| CATConstants.REGEX_CAMEL_CASE, " ");
|
danicadamljanovic/freya | freya/freya-annotate/src/test/java/org/freya/annotate/lucene/LuceneAnnotatorTest.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
| import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.runner.RunWith;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Annotation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | package org.freya.annotate.lucene;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class LuceneAnnotatorTest {
private static final Log logger = LogFactory.getLog(LuceneAnnotatorTest.class);
@Autowired LuceneAnnotator luceneAnnotator;
@Test
public void testExactMatch() throws Exception { | // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
// Path: freya/freya-annotate/src/test/java/org/freya/annotate/lucene/LuceneAnnotatorTest.java
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.runner.RunWith;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Annotation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
package org.freya.annotate.lucene;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class LuceneAnnotatorTest {
private static final Log logger = LogFactory.getLog(LuceneAnnotatorTest.class);
@Autowired LuceneAnnotator luceneAnnotator;
@Test
public void testExactMatch() throws Exception { | Annotation annotation = new Annotation(); |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/util/OntologyElementsUtil.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/SemanticConcept.java
// @XmlRootElement
// public class SemanticConcept implements Serializable {
//
// OntologyElement ontologyElement;
// String function;
// Boolean verified = false;
// Double score;
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// public Boolean isVerified() {
// return verified;
// }
//
// public void setVerified(Boolean verified) {
// this.verified = verified;
// }
//
// public OntologyElement getOntologyElement() {
// return ontologyElement;
// }
//
// public void setOntologyElement(OntologyElement ontologyElement) {
// this.ontologyElement = ontologyElement;
// }
//
// public String getFunction() {
// return function;
// }
//
// public void setFunction(String function) {
// this.function = function;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("Ontology Elements:\n");
// if (ontologyElement != null) b.append(ontologyElement.toString());
// b.append(" Verified:").append(verified).append("\n");
// b.append(" Function:").append(function).append("\n");
// if (ontologyElement != null)
// b.append("Is ontology element already added:"
// + ontologyElement.isAlreadyAdded() + "\n");
// return b.toString();
// }
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// public boolean equals(Object theOtherConcept) {
// boolean isEqual = false;
// String function1 = this.getFunction();
// String function2 = ((SemanticConcept) theOtherConcept).getFunction();
// OntologyElement element1 = this.getOntologyElement();
// OntologyElement element2 =
// ((SemanticConcept) theOtherConcept).getOntologyElement();
// boolean functionEquals = false;
// if (function1 != null && function2 != null)
// functionEquals = function1.equals(function2);
// else if (function1 == null && function2 == null) functionEquals = true;
// boolean verifiedEquals = false;
// if (this.isVerified().booleanValue() == ((SemanticConcept) theOtherConcept)
// .isVerified().booleanValue()) verifiedEquals = true;
// if (functionEquals && element1.equals(element2))
// isEqual = true;
// // System.out
// // .print("************************************************************calling equals method..result is:"
// // + isEqual);
// return isEqual;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import org.freya.model.OntologyElement;
import org.freya.model.SemanticConcept; | package org.freya.util;
public class OntologyElementsUtil {
/**
* @param list
* @return
*/
public static String beautifyListOfOntologyElements(List<OntologyElement> list) {
StringBuffer buff = new StringBuffer();
for (OntologyElement el : list) {
buff.append(el.getClass().getSimpleName()).append(":").append(el.getData());
}
if (list != null && list.size() > 0) {
buff.append("(").append(list.get(0).getAnnotation().getText()).append(",")
.append(list.get(0).getAnnotation().getStartOffset()).append(",")
.append(list.get(0).getAnnotation().getEndOffset()).append(")");
}
return buff.toString();
}
/**
* utility method takes ontology elements from semantic concepts and generates a list
*
* @param candidates
* @return
*/
public static List<OntologyElement> fromSemanticConceptsToOntologyElements( | // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/SemanticConcept.java
// @XmlRootElement
// public class SemanticConcept implements Serializable {
//
// OntologyElement ontologyElement;
// String function;
// Boolean verified = false;
// Double score;
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// public Boolean isVerified() {
// return verified;
// }
//
// public void setVerified(Boolean verified) {
// this.verified = verified;
// }
//
// public OntologyElement getOntologyElement() {
// return ontologyElement;
// }
//
// public void setOntologyElement(OntologyElement ontologyElement) {
// this.ontologyElement = ontologyElement;
// }
//
// public String getFunction() {
// return function;
// }
//
// public void setFunction(String function) {
// this.function = function;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("Ontology Elements:\n");
// if (ontologyElement != null) b.append(ontologyElement.toString());
// b.append(" Verified:").append(verified).append("\n");
// b.append(" Function:").append(function).append("\n");
// if (ontologyElement != null)
// b.append("Is ontology element already added:"
// + ontologyElement.isAlreadyAdded() + "\n");
// return b.toString();
// }
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// public boolean equals(Object theOtherConcept) {
// boolean isEqual = false;
// String function1 = this.getFunction();
// String function2 = ((SemanticConcept) theOtherConcept).getFunction();
// OntologyElement element1 = this.getOntologyElement();
// OntologyElement element2 =
// ((SemanticConcept) theOtherConcept).getOntologyElement();
// boolean functionEquals = false;
// if (function1 != null && function2 != null)
// functionEquals = function1.equals(function2);
// else if (function1 == null && function2 == null) functionEquals = true;
// boolean verifiedEquals = false;
// if (this.isVerified().booleanValue() == ((SemanticConcept) theOtherConcept)
// .isVerified().booleanValue()) verifiedEquals = true;
// if (functionEquals && element1.equals(element2))
// isEqual = true;
// // System.out
// // .print("************************************************************calling equals method..result is:"
// // + isEqual);
// return isEqual;
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/util/OntologyElementsUtil.java
import java.util.ArrayList;
import java.util.List;
import org.freya.model.OntologyElement;
import org.freya.model.SemanticConcept;
package org.freya.util;
public class OntologyElementsUtil {
/**
* @param list
* @return
*/
public static String beautifyListOfOntologyElements(List<OntologyElement> list) {
StringBuffer buff = new StringBuffer();
for (OntologyElement el : list) {
buff.append(el.getClass().getSimpleName()).append(":").append(el.getData());
}
if (list != null && list.size() > 0) {
buff.append("(").append(list.get(0).getAnnotation().getText()).append(",")
.append(list.get(0).getAnnotation().getStartOffset()).append(",")
.append(list.get(0).getAnnotation().getEndOffset()).append(")");
}
return buff.toString();
}
/**
* utility method takes ontology elements from semantic concepts and generates a list
*
* @param candidates
* @return
*/
public static List<OntologyElement> fromSemanticConceptsToOntologyElements( | List<SemanticConcept> candidates) { |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/analyser/FormalQueryMaker.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/QueryElement.java
// public class QueryElement {
//
// List<List<OntologyElement>> ontologyElements;
//
//
//
// public List<List<OntologyElement>> getOntologyElements() {
// return ontologyElements;
// }
//
// public void setOntologyElements(List<List<OntologyElement>> ontologyElements) {
// this.ontologyElements = ontologyElements;
// }
//
// List<String> uris = new ArrayList<String>();
//
// /* query in formal language */
// String queryString;
// /*
// * modifiers that could not be included into the queryString itself, as not
// * supported by formal languages or there is need to perform some
// * calculations or both; most common modifiers are instances of
// * KeyPhraseElement class
// */
// List<InterpretationElement> modifiers;
//
// /**
// * @see java.lang.Object#toString()
// */
// public String toString() {
// return new StringBuffer(this.getClass().getSimpleName().toString())
// .append("\nQuery: ").append(this.queryString)
// // .append(" Modifiers: ")
// // .append(this.modifiers.toString())
// .append("\n").toString();
// }
//
// /**
// * @return the modifiers
// */
// public List<InterpretationElement> getModifiers() {
// return modifiers;
// }
//
// /**
// * @param modifiers
// * the modifiers to set
// */
// public void setModifiers(List<InterpretationElement> modifiers) {
// this.modifiers = modifiers;
// }
//
// /**
// * @return the queryString
// */
// public String getQueryString() {
// return queryString;
// }
//
// /**
// * @param queryString
// * the queryString to set
// */
// public void setQueryString(String queryString) {
// this.queryString = queryString;
// }
//
// /**
// * @return the uris
// */
// public List<String> getUris() {
// return uris;
// }
//
// /**
// * @param uris
// * the uris to set
// */
// public void setUris(List<String> uris) {
// this.uris = uris;
// }
// }
| import java.util.List;
import org.freya.model.OntologyElement;
import org.freya.model.QueryElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
| /**
*
*/
package org.freya.analyser;
/**
* This transformer creates queries.
*
* @author danica
*
*/
@Component
public class FormalQueryMaker {
static org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
.getLog(FormalQueryMaker.class);
@Autowired private QueryCreator queryCreator;
/**
* generates sparql query
*
* @param List<OntologyElement>
* @return
* @throws GateException
*/
| // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/QueryElement.java
// public class QueryElement {
//
// List<List<OntologyElement>> ontologyElements;
//
//
//
// public List<List<OntologyElement>> getOntologyElements() {
// return ontologyElements;
// }
//
// public void setOntologyElements(List<List<OntologyElement>> ontologyElements) {
// this.ontologyElements = ontologyElements;
// }
//
// List<String> uris = new ArrayList<String>();
//
// /* query in formal language */
// String queryString;
// /*
// * modifiers that could not be included into the queryString itself, as not
// * supported by formal languages or there is need to perform some
// * calculations or both; most common modifiers are instances of
// * KeyPhraseElement class
// */
// List<InterpretationElement> modifiers;
//
// /**
// * @see java.lang.Object#toString()
// */
// public String toString() {
// return new StringBuffer(this.getClass().getSimpleName().toString())
// .append("\nQuery: ").append(this.queryString)
// // .append(" Modifiers: ")
// // .append(this.modifiers.toString())
// .append("\n").toString();
// }
//
// /**
// * @return the modifiers
// */
// public List<InterpretationElement> getModifiers() {
// return modifiers;
// }
//
// /**
// * @param modifiers
// * the modifiers to set
// */
// public void setModifiers(List<InterpretationElement> modifiers) {
// this.modifiers = modifiers;
// }
//
// /**
// * @return the queryString
// */
// public String getQueryString() {
// return queryString;
// }
//
// /**
// * @param queryString
// * the queryString to set
// */
// public void setQueryString(String queryString) {
// this.queryString = queryString;
// }
//
// /**
// * @return the uris
// */
// public List<String> getUris() {
// return uris;
// }
//
// /**
// * @param uris
// * the uris to set
// */
// public void setUris(List<String> uris) {
// this.uris = uris;
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/analyser/FormalQueryMaker.java
import java.util.List;
import org.freya.model.OntologyElement;
import org.freya.model.QueryElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
*/
package org.freya.analyser;
/**
* This transformer creates queries.
*
* @author danica
*
*/
@Component
public class FormalQueryMaker {
static org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
.getLog(FormalQueryMaker.class);
@Autowired private QueryCreator queryCreator;
/**
* generates sparql query
*
* @param List<OntologyElement>
* @return
* @throws GateException
*/
| public QueryElement transform(List<List<OntologyElement>> ontologyElementsTable)
|
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/analyser/FormalQueryMaker.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/QueryElement.java
// public class QueryElement {
//
// List<List<OntologyElement>> ontologyElements;
//
//
//
// public List<List<OntologyElement>> getOntologyElements() {
// return ontologyElements;
// }
//
// public void setOntologyElements(List<List<OntologyElement>> ontologyElements) {
// this.ontologyElements = ontologyElements;
// }
//
// List<String> uris = new ArrayList<String>();
//
// /* query in formal language */
// String queryString;
// /*
// * modifiers that could not be included into the queryString itself, as not
// * supported by formal languages or there is need to perform some
// * calculations or both; most common modifiers are instances of
// * KeyPhraseElement class
// */
// List<InterpretationElement> modifiers;
//
// /**
// * @see java.lang.Object#toString()
// */
// public String toString() {
// return new StringBuffer(this.getClass().getSimpleName().toString())
// .append("\nQuery: ").append(this.queryString)
// // .append(" Modifiers: ")
// // .append(this.modifiers.toString())
// .append("\n").toString();
// }
//
// /**
// * @return the modifiers
// */
// public List<InterpretationElement> getModifiers() {
// return modifiers;
// }
//
// /**
// * @param modifiers
// * the modifiers to set
// */
// public void setModifiers(List<InterpretationElement> modifiers) {
// this.modifiers = modifiers;
// }
//
// /**
// * @return the queryString
// */
// public String getQueryString() {
// return queryString;
// }
//
// /**
// * @param queryString
// * the queryString to set
// */
// public void setQueryString(String queryString) {
// this.queryString = queryString;
// }
//
// /**
// * @return the uris
// */
// public List<String> getUris() {
// return uris;
// }
//
// /**
// * @param uris
// * the uris to set
// */
// public void setUris(List<String> uris) {
// this.uris = uris;
// }
// }
| import java.util.List;
import org.freya.model.OntologyElement;
import org.freya.model.QueryElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
| /**
*
*/
package org.freya.analyser;
/**
* This transformer creates queries.
*
* @author danica
*
*/
@Component
public class FormalQueryMaker {
static org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
.getLog(FormalQueryMaker.class);
@Autowired private QueryCreator queryCreator;
/**
* generates sparql query
*
* @param List<OntologyElement>
* @return
* @throws GateException
*/
| // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
//
// Path: freya/freya-annotate/src/main/java/org/freya/model/QueryElement.java
// public class QueryElement {
//
// List<List<OntologyElement>> ontologyElements;
//
//
//
// public List<List<OntologyElement>> getOntologyElements() {
// return ontologyElements;
// }
//
// public void setOntologyElements(List<List<OntologyElement>> ontologyElements) {
// this.ontologyElements = ontologyElements;
// }
//
// List<String> uris = new ArrayList<String>();
//
// /* query in formal language */
// String queryString;
// /*
// * modifiers that could not be included into the queryString itself, as not
// * supported by formal languages or there is need to perform some
// * calculations or both; most common modifiers are instances of
// * KeyPhraseElement class
// */
// List<InterpretationElement> modifiers;
//
// /**
// * @see java.lang.Object#toString()
// */
// public String toString() {
// return new StringBuffer(this.getClass().getSimpleName().toString())
// .append("\nQuery: ").append(this.queryString)
// // .append(" Modifiers: ")
// // .append(this.modifiers.toString())
// .append("\n").toString();
// }
//
// /**
// * @return the modifiers
// */
// public List<InterpretationElement> getModifiers() {
// return modifiers;
// }
//
// /**
// * @param modifiers
// * the modifiers to set
// */
// public void setModifiers(List<InterpretationElement> modifiers) {
// this.modifiers = modifiers;
// }
//
// /**
// * @return the queryString
// */
// public String getQueryString() {
// return queryString;
// }
//
// /**
// * @param queryString
// * the queryString to set
// */
// public void setQueryString(String queryString) {
// this.queryString = queryString;
// }
//
// /**
// * @return the uris
// */
// public List<String> getUris() {
// return uris;
// }
//
// /**
// * @param uris
// * the uris to set
// */
// public void setUris(List<String> uris) {
// this.uris = uris;
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/analyser/FormalQueryMaker.java
import java.util.List;
import org.freya.model.OntologyElement;
import org.freya.model.QueryElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
*/
package org.freya.analyser;
/**
* This transformer creates queries.
*
* @author danica
*
*/
@Component
public class FormalQueryMaker {
static org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
.getLog(FormalQueryMaker.class);
@Autowired private QueryCreator queryCreator;
/**
* generates sparql query
*
* @param List<OntologyElement>
* @return
* @throws GateException
*/
| public QueryElement transform(List<List<OntologyElement>> ontologyElementsTable)
|
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/learning/LearningModel.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/learning/Vote.java
// public class Vote {
// // this is usually URI or DatatyepPropertyValueIdentifier
// Object identifier;
//
// volatile long id;
// volatile double score;
// volatile String function;
// public Object getIdentifier() {
// return identifier;
// }
// public void setIdentifier(Object identifier) {
// this.identifier = identifier;
// }
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public double getScore() {
// return score;
// }
// public void setScore(double score) {
// this.score = score;
// }
// public String getFunction() {
// return function;
// }
// public void setFunction(String function) {
// this.function = function;
// }
// }
| import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PostConstruct;
import org.apache.commons.io.FileUtils;
import org.freya.model.learning.Vote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
| package org.freya.learning;
// import org.apache.commons.logging.Log;
// import org.apache.commons.logging.LogFactory;
//import org.codehaus.jackson.JsonGenerationException;
//import org.codehaus.jackson.JsonParseException;
//import org.codehaus.jackson.map.JsonMappingException;
//import org.codehaus.jackson.map.ObjectMapper;
//import org.codehaus.jackson.type.TypeReference;
/**
* this class is initialising the learning model from file; on start up it feeds it into the memory and then it saves it
* at certain periods of time
*
* @author danica
*
*/
@Component
public class LearningModel {
private static final Logger logger = LoggerFactory.getLogger(LearningModel.class);
| // Path: freya/freya-annotate/src/main/java/org/freya/model/learning/Vote.java
// public class Vote {
// // this is usually URI or DatatyepPropertyValueIdentifier
// Object identifier;
//
// volatile long id;
// volatile double score;
// volatile String function;
// public Object getIdentifier() {
// return identifier;
// }
// public void setIdentifier(Object identifier) {
// this.identifier = identifier;
// }
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public double getScore() {
// return score;
// }
// public void setScore(double score) {
// this.score = score;
// }
// public String getFunction() {
// return function;
// }
// public void setFunction(String function) {
// this.function = function;
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/learning/LearningModel.java
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PostConstruct;
import org.apache.commons.io.FileUtils;
import org.freya.model.learning.Vote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
package org.freya.learning;
// import org.apache.commons.logging.Log;
// import org.apache.commons.logging.LogFactory;
//import org.codehaus.jackson.JsonGenerationException;
//import org.codehaus.jackson.JsonParseException;
//import org.codehaus.jackson.map.JsonMappingException;
//import org.codehaus.jackson.map.ObjectMapper;
//import org.codehaus.jackson.type.TypeReference;
/**
* this class is initialising the learning model from file; on start up it feeds it into the memory and then it saves it
* at certain periods of time
*
* @author danica
*
*/
@Component
public class LearningModel {
private static final Logger logger = LoggerFactory.getLogger(LearningModel.class);
| Map<String, List<Vote>> votesMap = new ConcurrentHashMap<String, List<Vote>>();
|
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/util/ProfilerUtil.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/SemanticConcept.java
// @XmlRootElement
// public class SemanticConcept implements Serializable {
//
// OntologyElement ontologyElement;
// String function;
// Boolean verified = false;
// Double score;
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// public Boolean isVerified() {
// return verified;
// }
//
// public void setVerified(Boolean verified) {
// this.verified = verified;
// }
//
// public OntologyElement getOntologyElement() {
// return ontologyElement;
// }
//
// public void setOntologyElement(OntologyElement ontologyElement) {
// this.ontologyElement = ontologyElement;
// }
//
// public String getFunction() {
// return function;
// }
//
// public void setFunction(String function) {
// this.function = function;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("Ontology Elements:\n");
// if (ontologyElement != null) b.append(ontologyElement.toString());
// b.append(" Verified:").append(verified).append("\n");
// b.append(" Function:").append(function).append("\n");
// if (ontologyElement != null)
// b.append("Is ontology element already added:"
// + ontologyElement.isAlreadyAdded() + "\n");
// return b.toString();
// }
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// public boolean equals(Object theOtherConcept) {
// boolean isEqual = false;
// String function1 = this.getFunction();
// String function2 = ((SemanticConcept) theOtherConcept).getFunction();
// OntologyElement element1 = this.getOntologyElement();
// OntologyElement element2 =
// ((SemanticConcept) theOtherConcept).getOntologyElement();
// boolean functionEquals = false;
// if (function1 != null && function2 != null)
// functionEquals = function1.equals(function2);
// else if (function1 == null && function2 == null) functionEquals = true;
// boolean verifiedEquals = false;
// if (this.isVerified().booleanValue() == ((SemanticConcept) theOtherConcept)
// .isVerified().booleanValue()) verifiedEquals = true;
// if (functionEquals && element1.equals(element2))
// isEqual = true;
// // System.out
// // .print("************************************************************calling equals method..result is:"
// // + isEqual);
// return isEqual;
// }
// }
| import java.util.List;
import org.freya.model.SemanticConcept; | package org.freya.util;
public class ProfilerUtil {
public static String profileString(String sessionId, String query, long runTime, String[] voteIds){
StringBuilder sb = new StringBuilder();
sb.append("SESSION ID: ");
sb.append(sessionId);
sb.append("; QUERY: ");
sb.append(query);
if (voteIds!=null){
sb.append("; VOTE ID: ");
for (String id:voteIds){
sb.append(id).append(" ");
}
}
sb.append("; TIME: ");
sb.append(runTime);
return sb.toString();
}
| // Path: freya/freya-annotate/src/main/java/org/freya/model/SemanticConcept.java
// @XmlRootElement
// public class SemanticConcept implements Serializable {
//
// OntologyElement ontologyElement;
// String function;
// Boolean verified = false;
// Double score;
//
// public Double getScore() {
// return score;
// }
//
// public void setScore(Double score) {
// this.score = score;
// }
//
// public Boolean isVerified() {
// return verified;
// }
//
// public void setVerified(Boolean verified) {
// this.verified = verified;
// }
//
// public OntologyElement getOntologyElement() {
// return ontologyElement;
// }
//
// public void setOntologyElement(OntologyElement ontologyElement) {
// this.ontologyElement = ontologyElement;
// }
//
// public String getFunction() {
// return function;
// }
//
// public void setFunction(String function) {
// this.function = function;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("Ontology Elements:\n");
// if (ontologyElement != null) b.append(ontologyElement.toString());
// b.append(" Verified:").append(verified).append("\n");
// b.append(" Function:").append(function).append("\n");
// if (ontologyElement != null)
// b.append("Is ontology element already added:"
// + ontologyElement.isAlreadyAdded() + "\n");
// return b.toString();
// }
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// public boolean equals(Object theOtherConcept) {
// boolean isEqual = false;
// String function1 = this.getFunction();
// String function2 = ((SemanticConcept) theOtherConcept).getFunction();
// OntologyElement element1 = this.getOntologyElement();
// OntologyElement element2 =
// ((SemanticConcept) theOtherConcept).getOntologyElement();
// boolean functionEquals = false;
// if (function1 != null && function2 != null)
// functionEquals = function1.equals(function2);
// else if (function1 == null && function2 == null) functionEquals = true;
// boolean verifiedEquals = false;
// if (this.isVerified().booleanValue() == ((SemanticConcept) theOtherConcept)
// .isVerified().booleanValue()) verifiedEquals = true;
// if (functionEquals && element1.equals(element2))
// isEqual = true;
// // System.out
// // .print("************************************************************calling equals method..result is:"
// // + isEqual);
// return isEqual;
// }
// }
// Path: freya/freya-annotate/src/main/java/org/freya/util/ProfilerUtil.java
import java.util.List;
import org.freya.model.SemanticConcept;
package org.freya.util;
public class ProfilerUtil {
public static String profileString(String sessionId, String query, long runTime, String[] voteIds){
StringBuilder sb = new StringBuilder();
sb.append("SESSION ID: ");
sb.append(sessionId);
sb.append("; QUERY: ");
sb.append(query);
if (voteIds!=null){
sb.append("; VOTE ID: ");
for (String id:voteIds){
sb.append(id).append(" ");
}
}
sb.append("; TIME: ");
sb.append(runTime);
return sb.toString();
}
| public static String profileSelection(long runTime, String sessionId, String query, List<SemanticConcept> candidates, Integer[] ranks){ |
danicadamljanovic/freya | freya/freya-annotate/src/test/java/org/freya/annotate/lucene/RenameAnnotationsTest.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Annotation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | package org.freya.annotate.lucene;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class RenameAnnotationsTest {
private static final Log logger = LogFactory.getLog(RenameAnnotationsTest.class);
@Autowired RenameAnnotations rename;
@Test
public void testRenameAnnotations() throws Exception { | // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
// Path: freya/freya-annotate/src/test/java/org/freya/annotate/lucene/RenameAnnotationsTest.java
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Annotation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
package org.freya.annotate.lucene;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class RenameAnnotationsTest {
private static final Log logger = LogFactory.getLog(RenameAnnotationsTest.class);
@Autowired RenameAnnotations rename;
@Test
public void testRenameAnnotations() throws Exception { | List<Annotation> annotations = new ArrayList<Annotation>(); |
danicadamljanovic/freya | freya/freya-annotate/src/main/java/org/freya/similarity/WordnetInvoker.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
| import static java.net.URLDecoder.decode;
import static java.util.Arrays.asList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.OntologyElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import edu.smu.tspell.wordnet.NounSynset;
import edu.smu.tspell.wordnet.Synset;
import edu.smu.tspell.wordnet.SynsetType;
import edu.smu.tspell.wordnet.VerbSynset;
import edu.smu.tspell.wordnet.WordNetDatabase;
| while (j < 2) {
NounSynset nounSynset;
NounSynset[] hyponyms;
Synset[] synsets = database.getSynsets(a[j], SynsetType.NOUN);
System.out.println("*********************************************");
for (int i = 0; i < synsets.length; i++) {
nounSynset = (NounSynset) (synsets[i]);
hyponyms = nounSynset.getHyponyms();
System.err.println(nounSynset.getWordForms()[0] + ": "
+ nounSynset.getDefinition() + ") has "
+ hyponyms.length + " hyponyms:");
for (NounSynset hyponym : hyponyms) {
System.out.println(hyponym.getWordForms()[0]);
}
}
j++;
}
System.out.println("*********************************************");
}
/**
* @param text
* @param suggestions
* @return
*/
| // Path: freya/freya-annotate/src/main/java/org/freya/model/OntologyElement.java
// public interface OntologyElement extends Serializable {
//
// public String getFunction();
//
// public void setFunction(String function);
//
// public boolean isAlreadyAdded();
//
// public void setAlreadyAdded(boolean alreadyAdded);
//
// public Annotation getAnnotation();
//
// public void setAnnotation(Annotation annotation);
//
// public String getVariable();
//
// public void setVariable(String key);
//
// public boolean isMainSubject();
//
// public void setMainSubject(boolean value);
//
// public List<String> getResults();
//
// public void setResults(List<String> results);
//
// public Object getData();
//
// public void setData(Object data);
//
// public void setScore(Score score);
//
// public Score getScore();
//
// public boolean isAnswer();
//
// public void setAnswer(boolean isAnswer);
//
// public boolean equals(Object o);
//
// }
// Path: freya/freya-annotate/src/main/java/org/freya/similarity/WordnetInvoker.java
import static java.net.URLDecoder.decode;
import static java.util.Arrays.asList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.OntologyElement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import edu.smu.tspell.wordnet.NounSynset;
import edu.smu.tspell.wordnet.Synset;
import edu.smu.tspell.wordnet.SynsetType;
import edu.smu.tspell.wordnet.VerbSynset;
import edu.smu.tspell.wordnet.WordNetDatabase;
while (j < 2) {
NounSynset nounSynset;
NounSynset[] hyponyms;
Synset[] synsets = database.getSynsets(a[j], SynsetType.NOUN);
System.out.println("*********************************************");
for (int i = 0; i < synsets.length; i++) {
nounSynset = (NounSynset) (synsets[i]);
hyponyms = nounSynset.getHyponyms();
System.err.println(nounSynset.getWordForms()[0] + ": "
+ nounSynset.getDefinition() + ") has "
+ hyponyms.length + " hyponyms:");
for (NounSynset hyponym : hyponyms) {
System.out.println(hyponym.getWordForms()[0]);
}
}
j++;
}
System.out.println("*********************************************");
}
/**
* @param text
* @param suggestions
* @return
*/
| public float getSynonymWeight(String text, List<OntologyElement> suggestions) {
|
danicadamljanovic/freya | freya/freya-annotate/src/test/java/org/freya/annotate/solr/SolrAnnotatorTest.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import org.freya.model.Annotation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List; | package org.freya.annotate.solr;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class SolrAnnotatorTest {
private static final Logger log = LoggerFactory.getLogger(SolrAnnotator.class);
@Autowired
private SolrAnnotator solrAnnotator;
@Test
public void testExactMatch() throws Exception { | // Path: freya/freya-annotate/src/main/java/org/freya/model/Annotation.java
// public class Annotation implements Serializable {
//
// String text;
// HashMap features;
// Long startOffset;
// Long endOffset;
//
// public HashMap getFeatures() {
// return features;
// }
//
// public void setFeatures(HashMap features) {
// this.features = features;
// }
//
// List<Tree> syntaxTree;
//
// public List<Tree> getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(List<Tree> syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getStartOffset() {
// return startOffset;
// }
//
// public void setStartOffset(Long startOffset) {
// this.startOffset = startOffset;
// }
//
// public Long getEndOffset() {
// return endOffset;
// }
//
// public void setEndOffset(Long endOffSet) {
// this.endOffset = endOffSet;
// }
//
// public String toString() {
// StringBuffer buffer = new StringBuffer("");
// buffer.append(" Annotation: StartOffset:" + startOffset);
// buffer.append(" End offset:" + endOffset);
// buffer.append(" String:" + text);
// buffer.append(" Syntax tree:" + syntaxTree);
// if (features != null)
// buffer.append(" Features:" + features.toString());
// return buffer.toString();
// }
//
// public boolean equals(Object anotherObject) {
// if (this == anotherObject)
// return true;
// if (!(anotherObject instanceof Annotation))
// return false;
// if (this.startOffset == null && this.endOffset == null
// && ((Annotation) anotherObject).startOffset != null
// && ((Annotation) anotherObject).endOffset != null)
// return true;
// if ((anotherObject != null)
// && (this.startOffset.longValue() == ((Annotation) anotherObject)
// .getStartOffset().longValue())
// && (this.endOffset.longValue() == ((Annotation) anotherObject)
// .getEndOffset().longValue())
// && (this.features.equals(((Annotation) anotherObject).features)
// ))
//
// return true;
// else
// return false;
// }
//
// /**
// *
// * @param aAnnot
// * @return
// */
// public boolean overlaps(Annotation aAnnot) {
// if (aAnnot == null) return false;
// if (aAnnot.getStartOffset() == null ||
// aAnnot.getEndOffset() == null) return false;
//
// if (aAnnot.getEndOffset().longValue() <= this.getStartOffset().longValue())
// return false;
//
// if (aAnnot.getStartOffset().longValue() >= this.getEndOffset().longValue())
// return false;
//
// return true;
// }// overlaps
//
//
// public Object clone() {
// Object deepCopy = null;
// ByteArrayOutputStream byteArrOs = new ByteArrayOutputStream();
// ObjectOutputStream objOs;
// try {
// objOs = new ObjectOutputStream(byteArrOs);
// objOs.writeObject(this);
// ByteArrayInputStream byteArrIs =
// new ByteArrayInputStream(byteArrOs.toByteArray());
// ObjectInputStream objIs = new ObjectInputStream(byteArrIs);
// deepCopy = objIs.readObject();
// return deepCopy;
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// return deepCopy;
// }
//
// }
// Path: freya/freya-annotate/src/test/java/org/freya/annotate/solr/SolrAnnotatorTest.java
import static org.junit.Assert.assertEquals;
import org.freya.model.Annotation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;
package org.freya.annotate.solr;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class SolrAnnotatorTest {
private static final Logger log = LoggerFactory.getLogger(SolrAnnotator.class);
@Autowired
private SolrAnnotator solrAnnotator;
@Test
public void testExactMatch() throws Exception { | Annotation annotation = new Annotation(); |
danicadamljanovic/freya | freya/freya-annotate/src/test/java/org/freya/service/FreyaServiceTest.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/service/FreyaResponse.java
// @XmlRootElement
// public class FreyaResponse {
//
// String repositoryId;
// String repositoryUrl;
// String sparqlQuery;
// String preciseSparql;
// Object textResponse;
// ArrayList clarifications;
// List<List<HashMap>> table;
// List<Object> refinementNodes;
// List<List<SemanticConcept>> semanticConcepts;
// ArrayList<Object> graph;
// List<Annotation> annotations = new ArrayList<Annotation>();
//
// public String getPreciseSparql() {
// return preciseSparql;
// }
//
// public void setPreciseSparql(String preciseSparql) {
// this.preciseSparql = preciseSparql;
// }
// public List<Object> getRefinementNodes() {
// return refinementNodes;
// }
//
// public void setRefinementNodes(List<Object> refinementNodes) {
// this.refinementNodes = refinementNodes;
// }
//
// public ArrayList getClarifications() {
// return clarifications;
// }
//
// public void setClarifications(ArrayList clarifications) {
// this.clarifications = clarifications;
// }
//
// public List<List<HashMap>> getTable() {
// return table;
// }
//
// public void setTable(List<List<HashMap>> table) {
// this.table = table;
// }
//
// public ArrayList<Object> getGraph() {
// return graph;
// }
//
// public void setGraph(ArrayList<Object> graph) {
// this.graph = graph;
// }
//
// public List<Annotation> getAnnotations() {
// return annotations;
// }
//
// public void setAnnotations(List<Annotation> annotations) {
// this.annotations = annotations;
// }
//
// public List<List<SemanticConcept>> getSemanticConcepts() {
// return semanticConcepts;
// }
//
// public void setSemanticConcepts(List<List<SemanticConcept>> semanticConcepts) {
// this.semanticConcepts = semanticConcepts;
// }
//
// public Object getTextResponse() {
// return textResponse;
// }
//
// public void setTextResponse(Object textResponse) {
// this.textResponse = textResponse;
// }
//
// public String getRepositoryId() {
// return repositoryId;
// }
//
// public void setRepositoryId(String repositoryId) {
// this.repositoryId = repositoryId;
// }
//
// public String getRepositoryUrl() {
// return repositoryUrl;
// }
//
// public void setRepositoryUrl(String repositoryUrl) {
// this.repositoryUrl = repositoryUrl;
// }
//
// public String getSparqlQuery() {
// return sparqlQuery;
// }
//
// public void setSparqlQuery(String sparqlQuery) {
// this.sparqlQuery = sparqlQuery;
// }
// }
| import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import java.net.URI;
import java.util.Map;
import org.freya.model.service.FreyaResponse;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.servlet.DispatcherServlet;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps; | package org.freya.service;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:META-INF/spring/freya-applicationContext.xml" })
@Configurable
public class FreyaServiceTest {
private static final Logger log = LoggerFactory.getLogger(FreyaServiceTest.class);
ObjectMapper objectMapper = new ObjectMapper();
private static ApplicationContext applicationContext;
@BeforeClass
public static void setUpUnitTest() throws Exception {
applicationContext = new MockWebAppContext("src/main/webapp", "freya");
}
@Test
public void getSparql() throws Exception {
Map<String, String> parameters = Maps.newHashMap();
parameters.put("query", "City california.");
| // Path: freya/freya-annotate/src/main/java/org/freya/model/service/FreyaResponse.java
// @XmlRootElement
// public class FreyaResponse {
//
// String repositoryId;
// String repositoryUrl;
// String sparqlQuery;
// String preciseSparql;
// Object textResponse;
// ArrayList clarifications;
// List<List<HashMap>> table;
// List<Object> refinementNodes;
// List<List<SemanticConcept>> semanticConcepts;
// ArrayList<Object> graph;
// List<Annotation> annotations = new ArrayList<Annotation>();
//
// public String getPreciseSparql() {
// return preciseSparql;
// }
//
// public void setPreciseSparql(String preciseSparql) {
// this.preciseSparql = preciseSparql;
// }
// public List<Object> getRefinementNodes() {
// return refinementNodes;
// }
//
// public void setRefinementNodes(List<Object> refinementNodes) {
// this.refinementNodes = refinementNodes;
// }
//
// public ArrayList getClarifications() {
// return clarifications;
// }
//
// public void setClarifications(ArrayList clarifications) {
// this.clarifications = clarifications;
// }
//
// public List<List<HashMap>> getTable() {
// return table;
// }
//
// public void setTable(List<List<HashMap>> table) {
// this.table = table;
// }
//
// public ArrayList<Object> getGraph() {
// return graph;
// }
//
// public void setGraph(ArrayList<Object> graph) {
// this.graph = graph;
// }
//
// public List<Annotation> getAnnotations() {
// return annotations;
// }
//
// public void setAnnotations(List<Annotation> annotations) {
// this.annotations = annotations;
// }
//
// public List<List<SemanticConcept>> getSemanticConcepts() {
// return semanticConcepts;
// }
//
// public void setSemanticConcepts(List<List<SemanticConcept>> semanticConcepts) {
// this.semanticConcepts = semanticConcepts;
// }
//
// public Object getTextResponse() {
// return textResponse;
// }
//
// public void setTextResponse(Object textResponse) {
// this.textResponse = textResponse;
// }
//
// public String getRepositoryId() {
// return repositoryId;
// }
//
// public void setRepositoryId(String repositoryId) {
// this.repositoryId = repositoryId;
// }
//
// public String getRepositoryUrl() {
// return repositoryUrl;
// }
//
// public void setRepositoryUrl(String repositoryUrl) {
// this.repositoryUrl = repositoryUrl;
// }
//
// public String getSparqlQuery() {
// return sparqlQuery;
// }
//
// public void setSparqlQuery(String sparqlQuery) {
// this.sparqlQuery = sparqlQuery;
// }
// }
// Path: freya/freya-annotate/src/test/java/org/freya/service/FreyaServiceTest.java
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import java.net.URI;
import java.util.Map;
import org.freya.model.service.FreyaResponse;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.servlet.DispatcherServlet;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps;
package org.freya.service;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:META-INF/spring/freya-applicationContext.xml" })
@Configurable
public class FreyaServiceTest {
private static final Logger log = LoggerFactory.getLogger(FreyaServiceTest.class);
ObjectMapper objectMapper = new ObjectMapper();
private static ApplicationContext applicationContext;
@BeforeClass
public static void setUpUnitTest() throws Exception {
applicationContext = new MockWebAppContext("src/main/webapp", "freya");
}
@Test
public void getSparql() throws Exception {
Map<String, String> parameters = Maps.newHashMap();
parameters.put("query", "City california.");
| FreyaResponse expected = new FreyaResponse(); |
danicadamljanovic/freya | freya/freya-annotate/src/test/java/org/freya/parser/stanford/SimpleStanfordParserTest.java | // Path: freya/freya-annotate/src/main/java/org/freya/model/Question.java
// @XmlRootElement
// public class Question {
//
// /**
// * question type such as boolean, number, classic (all the others);
// */
//
// public String sentenceText;
// public Type type;
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// List<HasWord> tokens;
//
// Tree syntaxTree;
//
// /* this is focus */
// POC focus;
//
// List<OntologyElement> answerType;
//
// List<POC> pocs = new ArrayList<POC>();
//
//
// public List<HasWord> getTokens() {
// return tokens;
// }
//
// public void setTokens(List<HasWord> tokens) {
// this.tokens = tokens;
// }
//
//
// List<List<SemanticConcept>> semanticConcepts =
// new ArrayList<List<SemanticConcept>>();
//
// public List<OntologyElement> getAnswerType() {
// return answerType;
// }
//
// public void setAnswerType(List<OntologyElement> answerType) {
// this.answerType = answerType;
// }
//
// public POC getFocus() {
// return focus;
// }
//
// public void setFocus(POC focus) {
// this.focus = focus;
// }
//
// public Tree getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(Tree syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public List<List<SemanticConcept>> getSemanticConcepts() {
// return semanticConcepts;
// }
//
// public void setSemanticConcepts(List<List<SemanticConcept>> semanticConcepts) {
// this.semanticConcepts = semanticConcepts;
// }
//
// public List<POC> getPocs() {
// return pocs;
// }
//
// public void setPocs(List<POC> pocs) {
// this.pocs = pocs;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("sem concepts:");
// if (this.semanticConcepts != null)
// b.append(this.semanticConcepts.toString());
// b.append("pocs:");
// if (this.pocs != null) b.append(pocs.toString());
// b.append("Tree:");
// if (this.syntaxTree != null) b.append(this.syntaxTree.toString());
// return b.toString();
// }
// }
| import static org.junit.Assert.assertEquals;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Question;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | package org.freya.parser.stanford;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class SimpleStanfordParserTest {
private static final Log logger = LogFactory.getLog(SimpleStanfordParserTest.class);
@Autowired SimpleStanfordParser simpleStanfordParser;
@Test
public void testSimpleStanfordParser() throws Exception {
| // Path: freya/freya-annotate/src/main/java/org/freya/model/Question.java
// @XmlRootElement
// public class Question {
//
// /**
// * question type such as boolean, number, classic (all the others);
// */
//
// public String sentenceText;
// public Type type;
//
// public Type getType() {
// return type;
// }
//
// public void setType(Type type) {
// this.type = type;
// }
//
// List<HasWord> tokens;
//
// Tree syntaxTree;
//
// /* this is focus */
// POC focus;
//
// List<OntologyElement> answerType;
//
// List<POC> pocs = new ArrayList<POC>();
//
//
// public List<HasWord> getTokens() {
// return tokens;
// }
//
// public void setTokens(List<HasWord> tokens) {
// this.tokens = tokens;
// }
//
//
// List<List<SemanticConcept>> semanticConcepts =
// new ArrayList<List<SemanticConcept>>();
//
// public List<OntologyElement> getAnswerType() {
// return answerType;
// }
//
// public void setAnswerType(List<OntologyElement> answerType) {
// this.answerType = answerType;
// }
//
// public POC getFocus() {
// return focus;
// }
//
// public void setFocus(POC focus) {
// this.focus = focus;
// }
//
// public Tree getSyntaxTree() {
// return syntaxTree;
// }
//
// public void setSyntaxTree(Tree syntaxTree) {
// this.syntaxTree = syntaxTree;
// }
//
// public List<List<SemanticConcept>> getSemanticConcepts() {
// return semanticConcepts;
// }
//
// public void setSemanticConcepts(List<List<SemanticConcept>> semanticConcepts) {
// this.semanticConcepts = semanticConcepts;
// }
//
// public List<POC> getPocs() {
// return pocs;
// }
//
// public void setPocs(List<POC> pocs) {
// this.pocs = pocs;
// }
//
// public String toString() {
// StringBuffer b = new StringBuffer("");
// b.append("sem concepts:");
// if (this.semanticConcepts != null)
// b.append(this.semanticConcepts.toString());
// b.append("pocs:");
// if (this.pocs != null) b.append(pocs.toString());
// b.append("Tree:");
// if (this.syntaxTree != null) b.append(this.syntaxTree.toString());
// return b.toString();
// }
// }
// Path: freya/freya-annotate/src/test/java/org/freya/parser/stanford/SimpleStanfordParserTest.java
import static org.junit.Assert.assertEquals;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.freya.model.Question;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
package org.freya.parser.stanford;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:META-INF/spring/freya-applicationContext.xml"})
@Configurable
public class SimpleStanfordParserTest {
private static final Log logger = LogFactory.getLog(SimpleStanfordParserTest.class);
@Autowired SimpleStanfordParser simpleStanfordParser;
@Test
public void testSimpleStanfordParser() throws Exception {
| Question q = simpleStanfordParser.parseQuestion("List cities in california."); |
asascience-open/ncSOS | src/main/java/com/asascience/ncsos/outputformatter/ds/IoosNetwork10Formatter.java | // Path: src/main/java/com/asascience/ncsos/util/XMLDomUtils.java
// public class XMLDomUtils {
//
//
// public static Document loadFile(InputStream filestream) {
// Document doc = null;
// try {
// // Build the document with SAX and Xerces, with validation
// SAXBuilder builder = new SAXBuilder(false);
// // Create the XML document and return
// doc = builder.build(filestream);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return doc;
// }
//
// public static Document loadFile(String filepath) {
// Document doc = null;
// try {
// // Build the document with SAX and Xerces, no validation
// SAXBuilder builder = new SAXBuilder();
// // Create the JSON document and return
// doc = builder.build(new File(filepath));
// } catch (Exception e) {
// e.printStackTrace();
// }
// return doc;
// }
//
// public static Document getTemplateDom(InputStream templateFileLocation) {
// return XMLDomUtils.loadFile(templateFileLocation);
// }
//
// private static Element getElementBaseOnContainerAndNode(Document doc,
// String container,
// String node) {
// Element fstNode = doc.getRootElement();
// if (!fstNode.getName().equals(container)) {
// fstNode = fstNode.getChild(container);
// }
// return fstNode.getChild(node);
// }
//
// public static Document addObservationElement(Document doc,
// String obsListName,
// Namespace obsListNamespace,
// String obsName,
// Namespace obsNamespace) {
// Element obsOfferEl = doc.getRootElement().getChild(obsListName, obsListNamespace);
// obsOfferEl.addContent(new Element(obsName, obsNamespace));
// return doc;
// }
//
// public static Document addNode(Document doc,
// String obs,
// Namespace obsNamespace,
// String nodeName,
// Namespace nodeNamespace,
// int stationNumber) {
// List<Element> obsOfferingList = doc.getRootElement().getChildren(obs, obsNamespace);
// Element obsOfferEl = obsOfferingList.get(stationNumber);
// Element obsOfferingNode = new Element(nodeName, nodeNamespace);
// obsOfferEl.addContent(obsOfferingNode);
// return doc;
// }
//
//
// public static Document addNode(Document doc,
// String parentNodeName, Namespace parentNs,
// String nodeNameToInsert, Namespace insertNodeNs,
// String nodeNameToInsertBefore, Namespace insertBeforeNodeNs) {
// Element parentEl = doc.getRootElement().getChild(parentNodeName, parentNs);
// Element existingEl = parentEl.getChild(nodeNameToInsertBefore, insertBeforeNodeNs);
// Element newNode = new Element(nodeNameToInsert, insertNodeNs);
// parentEl.addContent(parentEl.indexOf(existingEl) - 1, newNode);
// return doc;
// }
//
// public static Document addNode(Document doc, String Obs,
// Namespace obsNamespace,
// String nodeName,
// Namespace nodeNamespace,
// String value,
// int stationNumber) {
// Element obsOfferEl = (Element)doc.getRootElement().getChildren(Obs, obsNamespace).get(stationNumber);
// Element obsOfferingNode = new Element(nodeName, nodeNamespace);
// obsOfferingNode.setText(value);
// obsOfferEl.addContent(obsOfferingNode);
// return doc;
// }
//
// public static Document setNodeAttribute(Document doc,
// String nodeName,
// Namespace nodeNamespace,
// String attributeName,
// Namespace attributeNamespace,
// String attributeValue) {
// Element el = doc.getRootElement().getChild(nodeName, nodeNamespace);
// el.setAttribute(attributeName, attributeValue, attributeNamespace);
// return doc;
// }
//
// public static Element getNestedChild(Element base, String tagname) {
// if (base.getName().equals(tagname)) {
// return base;
// } else {
// for (Element e : (List<Element>)base.getChildren()) {
// Element x = XMLDomUtils.getNestedChild(e, tagname);
// if (x instanceof Element) {
// return x;
// }
// }
// }
// return null;
// }
//
// public static Element getNestedChild(Element base, String tagname, Namespace namespace) {
// if (base.getName().equals(tagname) && base.getNamespace().equals(namespace)) {
// return base;
// } else {
// for (Element e : (List<Element>)base.getChildren()) {
// Element x = XMLDomUtils.getNestedChild(e, tagname, namespace);
// if (x instanceof Element) {
// return x;
// }
// }
// }
// return null;
// }
//
// }
| import com.asascience.ncsos.util.XMLDomUtils;
import org.jdom.Element;
import java.util.List; | package com.asascience.ncsos.outputformatter.ds;
public class IoosNetwork10Formatter extends IoosPlatform10Formatter {
public static final String CF_CONVENTIONS = "http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html#discrete-sampling-geometries";
public IoosNetwork10Formatter() {
super();
}
public void addSmlComponent(String componentName) {
// add a new component to the ComponentList
/*
* <sml:component name='componentName'>
* <sml:System>
* <sml:identification>
* <sml:IdentifierList />
* </sml:identification>
* <sml:validTime />
* <sml:location />
* <sml:outputs>
* <sml:OutputList />
* </sml:outputs>
* </sml:System>
* </sml:component>
*/ | // Path: src/main/java/com/asascience/ncsos/util/XMLDomUtils.java
// public class XMLDomUtils {
//
//
// public static Document loadFile(InputStream filestream) {
// Document doc = null;
// try {
// // Build the document with SAX and Xerces, with validation
// SAXBuilder builder = new SAXBuilder(false);
// // Create the XML document and return
// doc = builder.build(filestream);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return doc;
// }
//
// public static Document loadFile(String filepath) {
// Document doc = null;
// try {
// // Build the document with SAX and Xerces, no validation
// SAXBuilder builder = new SAXBuilder();
// // Create the JSON document and return
// doc = builder.build(new File(filepath));
// } catch (Exception e) {
// e.printStackTrace();
// }
// return doc;
// }
//
// public static Document getTemplateDom(InputStream templateFileLocation) {
// return XMLDomUtils.loadFile(templateFileLocation);
// }
//
// private static Element getElementBaseOnContainerAndNode(Document doc,
// String container,
// String node) {
// Element fstNode = doc.getRootElement();
// if (!fstNode.getName().equals(container)) {
// fstNode = fstNode.getChild(container);
// }
// return fstNode.getChild(node);
// }
//
// public static Document addObservationElement(Document doc,
// String obsListName,
// Namespace obsListNamespace,
// String obsName,
// Namespace obsNamespace) {
// Element obsOfferEl = doc.getRootElement().getChild(obsListName, obsListNamespace);
// obsOfferEl.addContent(new Element(obsName, obsNamespace));
// return doc;
// }
//
// public static Document addNode(Document doc,
// String obs,
// Namespace obsNamespace,
// String nodeName,
// Namespace nodeNamespace,
// int stationNumber) {
// List<Element> obsOfferingList = doc.getRootElement().getChildren(obs, obsNamespace);
// Element obsOfferEl = obsOfferingList.get(stationNumber);
// Element obsOfferingNode = new Element(nodeName, nodeNamespace);
// obsOfferEl.addContent(obsOfferingNode);
// return doc;
// }
//
//
// public static Document addNode(Document doc,
// String parentNodeName, Namespace parentNs,
// String nodeNameToInsert, Namespace insertNodeNs,
// String nodeNameToInsertBefore, Namespace insertBeforeNodeNs) {
// Element parentEl = doc.getRootElement().getChild(parentNodeName, parentNs);
// Element existingEl = parentEl.getChild(nodeNameToInsertBefore, insertBeforeNodeNs);
// Element newNode = new Element(nodeNameToInsert, insertNodeNs);
// parentEl.addContent(parentEl.indexOf(existingEl) - 1, newNode);
// return doc;
// }
//
// public static Document addNode(Document doc, String Obs,
// Namespace obsNamespace,
// String nodeName,
// Namespace nodeNamespace,
// String value,
// int stationNumber) {
// Element obsOfferEl = (Element)doc.getRootElement().getChildren(Obs, obsNamespace).get(stationNumber);
// Element obsOfferingNode = new Element(nodeName, nodeNamespace);
// obsOfferingNode.setText(value);
// obsOfferEl.addContent(obsOfferingNode);
// return doc;
// }
//
// public static Document setNodeAttribute(Document doc,
// String nodeName,
// Namespace nodeNamespace,
// String attributeName,
// Namespace attributeNamespace,
// String attributeValue) {
// Element el = doc.getRootElement().getChild(nodeName, nodeNamespace);
// el.setAttribute(attributeName, attributeValue, attributeNamespace);
// return doc;
// }
//
// public static Element getNestedChild(Element base, String tagname) {
// if (base.getName().equals(tagname)) {
// return base;
// } else {
// for (Element e : (List<Element>)base.getChildren()) {
// Element x = XMLDomUtils.getNestedChild(e, tagname);
// if (x instanceof Element) {
// return x;
// }
// }
// }
// return null;
// }
//
// public static Element getNestedChild(Element base, String tagname, Namespace namespace) {
// if (base.getName().equals(tagname) && base.getNamespace().equals(namespace)) {
// return base;
// } else {
// for (Element e : (List<Element>)base.getChildren()) {
// Element x = XMLDomUtils.getNestedChild(e, tagname, namespace);
// if (x instanceof Element) {
// return x;
// }
// }
// }
// return null;
// }
//
// }
// Path: src/main/java/com/asascience/ncsos/outputformatter/ds/IoosNetwork10Formatter.java
import com.asascience.ncsos.util.XMLDomUtils;
import org.jdom.Element;
import java.util.List;
package com.asascience.ncsos.outputformatter.ds;
public class IoosNetwork10Formatter extends IoosPlatform10Formatter {
public static final String CF_CONVENTIONS = "http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html#discrete-sampling-geometries";
public IoosNetwork10Formatter() {
super();
}
public void addSmlComponent(String componentName) {
// add a new component to the ComponentList
/*
* <sml:component name='componentName'>
* <sml:System>
* <sml:identification>
* <sml:IdentifierList />
* </sml:identification>
* <sml:validTime />
* <sml:location />
* <sml:outputs>
* <sml:OutputList />
* </sml:outputs>
* </sml:System>
* </sml:component>
*/ | Element parent = XMLDomUtils.getNestedChild(this.getRoot(), COMPONENT_LIST, SML_NS); |
asascience-open/ncSOS | src/main/java/com/asascience/ncsos/outputformatter/CachedFileFormatter.java | // Path: src/main/java/com/asascience/ncsos/util/XMLDomUtils.java
// public class XMLDomUtils {
//
//
// public static Document loadFile(InputStream filestream) {
// Document doc = null;
// try {
// // Build the document with SAX and Xerces, with validation
// SAXBuilder builder = new SAXBuilder(false);
// // Create the XML document and return
// doc = builder.build(filestream);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return doc;
// }
//
// public static Document loadFile(String filepath) {
// Document doc = null;
// try {
// // Build the document with SAX and Xerces, no validation
// SAXBuilder builder = new SAXBuilder();
// // Create the JSON document and return
// doc = builder.build(new File(filepath));
// } catch (Exception e) {
// e.printStackTrace();
// }
// return doc;
// }
//
// public static Document getTemplateDom(InputStream templateFileLocation) {
// return XMLDomUtils.loadFile(templateFileLocation);
// }
//
// private static Element getElementBaseOnContainerAndNode(Document doc,
// String container,
// String node) {
// Element fstNode = doc.getRootElement();
// if (!fstNode.getName().equals(container)) {
// fstNode = fstNode.getChild(container);
// }
// return fstNode.getChild(node);
// }
//
// public static Document addObservationElement(Document doc,
// String obsListName,
// Namespace obsListNamespace,
// String obsName,
// Namespace obsNamespace) {
// Element obsOfferEl = doc.getRootElement().getChild(obsListName, obsListNamespace);
// obsOfferEl.addContent(new Element(obsName, obsNamespace));
// return doc;
// }
//
// public static Document addNode(Document doc,
// String obs,
// Namespace obsNamespace,
// String nodeName,
// Namespace nodeNamespace,
// int stationNumber) {
// List<Element> obsOfferingList = doc.getRootElement().getChildren(obs, obsNamespace);
// Element obsOfferEl = obsOfferingList.get(stationNumber);
// Element obsOfferingNode = new Element(nodeName, nodeNamespace);
// obsOfferEl.addContent(obsOfferingNode);
// return doc;
// }
//
//
// public static Document addNode(Document doc,
// String parentNodeName, Namespace parentNs,
// String nodeNameToInsert, Namespace insertNodeNs,
// String nodeNameToInsertBefore, Namespace insertBeforeNodeNs) {
// Element parentEl = doc.getRootElement().getChild(parentNodeName, parentNs);
// Element existingEl = parentEl.getChild(nodeNameToInsertBefore, insertBeforeNodeNs);
// Element newNode = new Element(nodeNameToInsert, insertNodeNs);
// parentEl.addContent(parentEl.indexOf(existingEl) - 1, newNode);
// return doc;
// }
//
// public static Document addNode(Document doc, String Obs,
// Namespace obsNamespace,
// String nodeName,
// Namespace nodeNamespace,
// String value,
// int stationNumber) {
// Element obsOfferEl = (Element)doc.getRootElement().getChildren(Obs, obsNamespace).get(stationNumber);
// Element obsOfferingNode = new Element(nodeName, nodeNamespace);
// obsOfferingNode.setText(value);
// obsOfferEl.addContent(obsOfferingNode);
// return doc;
// }
//
// public static Document setNodeAttribute(Document doc,
// String nodeName,
// Namespace nodeNamespace,
// String attributeName,
// Namespace attributeNamespace,
// String attributeValue) {
// Element el = doc.getRootElement().getChild(nodeName, nodeNamespace);
// el.setAttribute(attributeName, attributeValue, attributeNamespace);
// return doc;
// }
//
// public static Element getNestedChild(Element base, String tagname) {
// if (base.getName().equals(tagname)) {
// return base;
// } else {
// for (Element e : (List<Element>)base.getChildren()) {
// Element x = XMLDomUtils.getNestedChild(e, tagname);
// if (x instanceof Element) {
// return x;
// }
// }
// }
// return null;
// }
//
// public static Element getNestedChild(Element base, String tagname, Namespace namespace) {
// if (base.getName().equals(tagname) && base.getNamespace().equals(namespace)) {
// return base;
// } else {
// for (Element e : (List<Element>)base.getChildren()) {
// Element x = XMLDomUtils.getNestedChild(e, tagname, namespace);
// if (x instanceof Element) {
// return x;
// }
// }
// }
// return null;
// }
//
// }
| import com.asascience.ncsos.util.XMLDomUtils;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.util.BitSet; | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.asascience.ncsos.outputformatter;
/**
*
* @author SCowan
*/
public class CachedFileFormatter extends XmlOutputFormatter {
private Document document;
private String errorString;
private boolean exceptionFlag;
private enum Sections {
OPERATIONSMETADATA, SERVICEIDENTIFICATION, SERVICEPROVIDER, CONTENTS
}
private static final int SECTION_COUNT = 4;
private BitSet requestedSections;
private String TEMPLATE;
private String fileToRead;
private final static String capabilitiesElement = "Capabilities";
public CachedFileFormatter(File fileToRead) {
this.fileToRead = fileToRead.getAbsolutePath(); | // Path: src/main/java/com/asascience/ncsos/util/XMLDomUtils.java
// public class XMLDomUtils {
//
//
// public static Document loadFile(InputStream filestream) {
// Document doc = null;
// try {
// // Build the document with SAX and Xerces, with validation
// SAXBuilder builder = new SAXBuilder(false);
// // Create the XML document and return
// doc = builder.build(filestream);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return doc;
// }
//
// public static Document loadFile(String filepath) {
// Document doc = null;
// try {
// // Build the document with SAX and Xerces, no validation
// SAXBuilder builder = new SAXBuilder();
// // Create the JSON document and return
// doc = builder.build(new File(filepath));
// } catch (Exception e) {
// e.printStackTrace();
// }
// return doc;
// }
//
// public static Document getTemplateDom(InputStream templateFileLocation) {
// return XMLDomUtils.loadFile(templateFileLocation);
// }
//
// private static Element getElementBaseOnContainerAndNode(Document doc,
// String container,
// String node) {
// Element fstNode = doc.getRootElement();
// if (!fstNode.getName().equals(container)) {
// fstNode = fstNode.getChild(container);
// }
// return fstNode.getChild(node);
// }
//
// public static Document addObservationElement(Document doc,
// String obsListName,
// Namespace obsListNamespace,
// String obsName,
// Namespace obsNamespace) {
// Element obsOfferEl = doc.getRootElement().getChild(obsListName, obsListNamespace);
// obsOfferEl.addContent(new Element(obsName, obsNamespace));
// return doc;
// }
//
// public static Document addNode(Document doc,
// String obs,
// Namespace obsNamespace,
// String nodeName,
// Namespace nodeNamespace,
// int stationNumber) {
// List<Element> obsOfferingList = doc.getRootElement().getChildren(obs, obsNamespace);
// Element obsOfferEl = obsOfferingList.get(stationNumber);
// Element obsOfferingNode = new Element(nodeName, nodeNamespace);
// obsOfferEl.addContent(obsOfferingNode);
// return doc;
// }
//
//
// public static Document addNode(Document doc,
// String parentNodeName, Namespace parentNs,
// String nodeNameToInsert, Namespace insertNodeNs,
// String nodeNameToInsertBefore, Namespace insertBeforeNodeNs) {
// Element parentEl = doc.getRootElement().getChild(parentNodeName, parentNs);
// Element existingEl = parentEl.getChild(nodeNameToInsertBefore, insertBeforeNodeNs);
// Element newNode = new Element(nodeNameToInsert, insertNodeNs);
// parentEl.addContent(parentEl.indexOf(existingEl) - 1, newNode);
// return doc;
// }
//
// public static Document addNode(Document doc, String Obs,
// Namespace obsNamespace,
// String nodeName,
// Namespace nodeNamespace,
// String value,
// int stationNumber) {
// Element obsOfferEl = (Element)doc.getRootElement().getChildren(Obs, obsNamespace).get(stationNumber);
// Element obsOfferingNode = new Element(nodeName, nodeNamespace);
// obsOfferingNode.setText(value);
// obsOfferEl.addContent(obsOfferingNode);
// return doc;
// }
//
// public static Document setNodeAttribute(Document doc,
// String nodeName,
// Namespace nodeNamespace,
// String attributeName,
// Namespace attributeNamespace,
// String attributeValue) {
// Element el = doc.getRootElement().getChild(nodeName, nodeNamespace);
// el.setAttribute(attributeName, attributeValue, attributeNamespace);
// return doc;
// }
//
// public static Element getNestedChild(Element base, String tagname) {
// if (base.getName().equals(tagname)) {
// return base;
// } else {
// for (Element e : (List<Element>)base.getChildren()) {
// Element x = XMLDomUtils.getNestedChild(e, tagname);
// if (x instanceof Element) {
// return x;
// }
// }
// }
// return null;
// }
//
// public static Element getNestedChild(Element base, String tagname, Namespace namespace) {
// if (base.getName().equals(tagname) && base.getNamespace().equals(namespace)) {
// return base;
// } else {
// for (Element e : (List<Element>)base.getChildren()) {
// Element x = XMLDomUtils.getNestedChild(e, tagname, namespace);
// if (x instanceof Element) {
// return x;
// }
// }
// }
// return null;
// }
//
// }
// Path: src/main/java/com/asascience/ncsos/outputformatter/CachedFileFormatter.java
import com.asascience.ncsos.util.XMLDomUtils;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.util.BitSet;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.asascience.ncsos.outputformatter;
/**
*
* @author SCowan
*/
public class CachedFileFormatter extends XmlOutputFormatter {
private Document document;
private String errorString;
private boolean exceptionFlag;
private enum Sections {
OPERATIONSMETADATA, SERVICEIDENTIFICATION, SERVICEPROVIDER, CONTENTS
}
private static final int SECTION_COUNT = 4;
private BitSet requestedSections;
private String TEMPLATE;
private String fileToRead;
private final static String capabilitiesElement = "Capabilities";
public CachedFileFormatter(File fileToRead) {
this.fileToRead = fileToRead.getAbsolutePath(); | this.document = XMLDomUtils.loadFile(getClass().getClassLoader().getResourceAsStream(this.fileToRead)); |
asascience-open/ncSOS | src/test/java/com/asascience/ncsos/GOBaseGridTest.java | // Path: src/main/java/com/asascience/ncsos/util/VocabDefinitions.java
// public final class VocabDefinitions {
//
// private static final String CF_PARAMETERS = "resources/cf_parameters.txt";
// private static HashSet<String> cfSet;
// private static HashSet<String> ioosDefs;
// private static org.slf4j.Logger _log = org.slf4j.LoggerFactory.getLogger(VocabDefinitions.class);
// private static final String CF_HREF = "http://mmisw.org/ont/cf/parameter/";
// private VocabDefinitions() {}
//
// /**
// * Determines the necessary term for the parameter.
// * @param param the name of the parameter to look for, expected lowercase w/ "_"
// * @return if in standard vocabulary specified then <standard_voacbulary><standard_name>
// * else if CF table: http://mmissw.org/ont/cf/parameter/param else http://mmisw.org/ont/ioos/parameter/param
// */
// public static String GetDefinitionForParameter(String standardName, String standardNameVocab, Boolean cfConv) {
// String paramHref = "http://mmisw.org/ont/ioos/parameter/" + standardName;
// boolean validUrl = false;
//
//
// if (standardNameVocab != null){
// try{
// URL vocabUrl = new URL(standardNameVocab);
// validUrl = true;
// }
// catch(MalformedURLException e){}
// }
//
// if(validUrl){
// paramHref = standardNameVocab + standardName;
// }
// else {
// boolean isCf = false;
// if (cfConv != null && cfConv == true){
// isCf = true;
// }
// else {
// if (cfSet == null)
// CreateCFSet();
//
// if (cfSet.contains(standardName))
// isCf = true;
// }
// if(isCf)
// paramHref = CF_HREF + standardName;
// }
//
// return paramHref ;
// }
//
// public static String GetIoosDefinition(String def) {
// if (ioosDefs == null)
// CreateIoosDefs();
//
// if (ioosDefs.contains(def.toLowerCase()))
// return "http://mmisw.org/ont/ioos/definition/" + def;
//
// return def;
// }
//
// private static void CreateCFSet() {
// try {
// InputStream fin = VocabDefinitions.class.getClassLoader().getResourceAsStream(CF_PARAMETERS);
// InputStreamReader freader = new InputStreamReader(fin);
// // FileReader fin = new FileReader(CF_PARAMETERS);
// cfSet = new HashSet<String>();
// StringBuilder builder = new StringBuilder();
// char[] buffer = new char[1];
// while(freader.read(buffer) > 0) {
// if (buffer[0] == ';') {
// cfSet.add(builder.toString());
// builder.setLength(0);
// } else {
// builder.append(buffer[0]);
// }
// }
// } catch (Exception ex) {
// _log.error(ex.toString());
// }
// }
//
// private static void CreateIoosDefs() {
// // short list of definitions at http://mmisw.org/ont/ioos/definition
// ioosDefs = new HashSet<String>();
// // longName
// ioosDefs.add("longname"); ioosDefs.add("long_name"); ioosDefs.add("long name");
// // networkId
// ioosDefs.add("networkid"); ioosDefs.add("network_id"); ioosDefs.add("network id");
// // operator
// ioosDefs.add("operator");
// // operatorSector
// ioosDefs.add("operatorsector"); ioosDefs.add("operator_sector"); ioosDefs.add("operator sector");
// // parentNetwork
// ioosDefs.add("parentnetwork"); ioosDefs.add("parent_network"); ioosDefs.add("parent network");
// // platformType
// ioosDefs.add("platformtype"); ioosDefs.add("platform_type"); ioosDefs.add("platform type");
// // publisher
// ioosDefs.add("publisher");
// // qualityControlDescription
// ioosDefs.add("qualitycontroldescription"); ioosDefs.add("quality_control_description"); ioosDefs.add("quality control description");
// // sensorID
// ioosDefs.add("sensorid"); ioosDefs.add("sensor_id"); ioosDefs.add("sensor id");
// // shortName
// ioosDefs.add("shortname"); ioosDefs.add("short_name"); ioosDefs.add("short name");
// // sponsor
// ioosDefs.add("sponsor");
// // stationID
// ioosDefs.add("stationid"); ioosDefs.add("station_id"); ioosDefs.add("station id");
// // wmoID
// ioosDefs.add("wmoid"); ioosDefs.add("wmo_id"); ioosDefs.add("wmo id");
// }
//
// }
| import junit.framework.Assert;
import org.jdom.Element;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.asascience.ncsos.util.VocabDefinitions;
import java.io.File;
import java.net.URLEncoder;
import java.util.*; | kvp.put("version", "1.0.0");
kvp.put("service", "SOS");
}
// Create the parameters for the test constructor
@Parameters
public static Collection<Object[]> testCases() throws Exception {
setUpClass();
// Ignore GRID datasets
int grids = 0;
for (Element e : new ArrayList<Element>(fileElements)) {
if (!e.getAttributeValue("feature").toLowerCase().equals("grid")) {
fileElements.remove(e);
} else {
for (Element s : (List<Element>) e.getChildren("sensor")) {
grids = grids + s.getChildren("values").size();
}
}
}
Object[][] data = new Object[grids*3][7];
int curIndex = 0;
for (Element e : fileElements) {
String authority = e.getAttributeValue("authority","ncsos");
String networkOffering = "urn:ioos:network:" + authority + ":all";
for (Element s : (List<Element>) e.getChildren("sensor")) {
| // Path: src/main/java/com/asascience/ncsos/util/VocabDefinitions.java
// public final class VocabDefinitions {
//
// private static final String CF_PARAMETERS = "resources/cf_parameters.txt";
// private static HashSet<String> cfSet;
// private static HashSet<String> ioosDefs;
// private static org.slf4j.Logger _log = org.slf4j.LoggerFactory.getLogger(VocabDefinitions.class);
// private static final String CF_HREF = "http://mmisw.org/ont/cf/parameter/";
// private VocabDefinitions() {}
//
// /**
// * Determines the necessary term for the parameter.
// * @param param the name of the parameter to look for, expected lowercase w/ "_"
// * @return if in standard vocabulary specified then <standard_voacbulary><standard_name>
// * else if CF table: http://mmissw.org/ont/cf/parameter/param else http://mmisw.org/ont/ioos/parameter/param
// */
// public static String GetDefinitionForParameter(String standardName, String standardNameVocab, Boolean cfConv) {
// String paramHref = "http://mmisw.org/ont/ioos/parameter/" + standardName;
// boolean validUrl = false;
//
//
// if (standardNameVocab != null){
// try{
// URL vocabUrl = new URL(standardNameVocab);
// validUrl = true;
// }
// catch(MalformedURLException e){}
// }
//
// if(validUrl){
// paramHref = standardNameVocab + standardName;
// }
// else {
// boolean isCf = false;
// if (cfConv != null && cfConv == true){
// isCf = true;
// }
// else {
// if (cfSet == null)
// CreateCFSet();
//
// if (cfSet.contains(standardName))
// isCf = true;
// }
// if(isCf)
// paramHref = CF_HREF + standardName;
// }
//
// return paramHref ;
// }
//
// public static String GetIoosDefinition(String def) {
// if (ioosDefs == null)
// CreateIoosDefs();
//
// if (ioosDefs.contains(def.toLowerCase()))
// return "http://mmisw.org/ont/ioos/definition/" + def;
//
// return def;
// }
//
// private static void CreateCFSet() {
// try {
// InputStream fin = VocabDefinitions.class.getClassLoader().getResourceAsStream(CF_PARAMETERS);
// InputStreamReader freader = new InputStreamReader(fin);
// // FileReader fin = new FileReader(CF_PARAMETERS);
// cfSet = new HashSet<String>();
// StringBuilder builder = new StringBuilder();
// char[] buffer = new char[1];
// while(freader.read(buffer) > 0) {
// if (buffer[0] == ';') {
// cfSet.add(builder.toString());
// builder.setLength(0);
// } else {
// builder.append(buffer[0]);
// }
// }
// } catch (Exception ex) {
// _log.error(ex.toString());
// }
// }
//
// private static void CreateIoosDefs() {
// // short list of definitions at http://mmisw.org/ont/ioos/definition
// ioosDefs = new HashSet<String>();
// // longName
// ioosDefs.add("longname"); ioosDefs.add("long_name"); ioosDefs.add("long name");
// // networkId
// ioosDefs.add("networkid"); ioosDefs.add("network_id"); ioosDefs.add("network id");
// // operator
// ioosDefs.add("operator");
// // operatorSector
// ioosDefs.add("operatorsector"); ioosDefs.add("operator_sector"); ioosDefs.add("operator sector");
// // parentNetwork
// ioosDefs.add("parentnetwork"); ioosDefs.add("parent_network"); ioosDefs.add("parent network");
// // platformType
// ioosDefs.add("platformtype"); ioosDefs.add("platform_type"); ioosDefs.add("platform type");
// // publisher
// ioosDefs.add("publisher");
// // qualityControlDescription
// ioosDefs.add("qualitycontroldescription"); ioosDefs.add("quality_control_description"); ioosDefs.add("quality control description");
// // sensorID
// ioosDefs.add("sensorid"); ioosDefs.add("sensor_id"); ioosDefs.add("sensor id");
// // shortName
// ioosDefs.add("shortname"); ioosDefs.add("short_name"); ioosDefs.add("short name");
// // sponsor
// ioosDefs.add("sponsor");
// // stationID
// ioosDefs.add("stationid"); ioosDefs.add("station_id"); ioosDefs.add("station id");
// // wmoID
// ioosDefs.add("wmoid"); ioosDefs.add("wmo_id"); ioosDefs.add("wmo id");
// }
//
// }
// Path: src/test/java/com/asascience/ncsos/GOBaseGridTest.java
import junit.framework.Assert;
import org.jdom.Element;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.asascience.ncsos.util.VocabDefinitions;
import java.io.File;
import java.net.URLEncoder;
import java.util.*;
kvp.put("version", "1.0.0");
kvp.put("service", "SOS");
}
// Create the parameters for the test constructor
@Parameters
public static Collection<Object[]> testCases() throws Exception {
setUpClass();
// Ignore GRID datasets
int grids = 0;
for (Element e : new ArrayList<Element>(fileElements)) {
if (!e.getAttributeValue("feature").toLowerCase().equals("grid")) {
fileElements.remove(e);
} else {
for (Element s : (List<Element>) e.getChildren("sensor")) {
grids = grids + s.getChildren("values").size();
}
}
}
Object[][] data = new Object[grids*3][7];
int curIndex = 0;
for (Element e : fileElements) {
String authority = e.getAttributeValue("authority","ncsos");
String networkOffering = "urn:ioos:network:" + authority + ":all";
for (Element s : (List<Element>) e.getChildren("sensor")) {
| String standard = VocabDefinitions.GetDefinitionForParameter( |
ndebeiss/svg3d | jsunit/java/src/net/jsunit/JsUnitServer.java | // Path: jsunit/java/src/net/jsunit/servlet/TestRunnerServlet.java
// public class TestRunnerServlet extends JsUnitServlet {
//
// protected synchronized void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Utility.log("TestRunnerServlet: Received request to run standalone test...");
// StandaloneTest test = createTest();
// TestResult result = TestRunner.run(test);
// writeResponse(response, result);
// Utility.log("TestRunnerServlet: ...Done");
// }
//
// protected void writeResponse(HttpServletResponse response, TestResult result) throws IOException {
// response.setContentType("text/xml");
// OutputStream out = response.getOutputStream();
// String resultString = result.wasSuccessful() ? "success" : "failure";
// out.write(("<result>" + resultString + "</result>").getBytes());
// out.close();
// }
//
// protected StandaloneTest createTest() {
// StandaloneTest standaloneTest = new StandaloneTest("testStandaloneRun");
// standaloneTest.setServer(server);
// return standaloneTest;
// }
// }
| import net.jsunit.servlet.JsUnitServlet;
import net.jsunit.servlet.ResultAcceptorServlet;
import net.jsunit.servlet.ResultDisplayerServlet;
import net.jsunit.servlet.TestRunnerServlet;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpServer;
import org.mortbay.http.handler.ResourceHandler;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.start.Monitor;
import org.mortbay.util.MultiException;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; | configuration.configure(this);
initialized = true;
} catch (ConfigurationException ce) {
System.err.println("Server initialization failed because property \"" + ce.getPropertyInError() + "\" has an invalid value of \"" + ce.getInvalidValue() + "\"");
throw ce;
}
}
public void start() throws MultiException {
if (!initialized) {
System.err.println("Cannot start server: not initialized");
return;
}
try {
setUpHttpServer();
} catch (IOException e) {
e.printStackTrace();
return;
}
super.start();
Utility.log(asString());
}
private void setUpHttpServer() throws IOException {
addListener(":" + port);
HttpContext context = getContext("/jsunit");
ServletHandler handler;
handler = new ServletHandler();
handler.addServlet("JsUnitResultAcceptor", "/acceptor", ResultAcceptorServlet.class.getName());
handler.addServlet("JsUnitResultDisplayer", "/displayer", ResultDisplayerServlet.class.getName()); | // Path: jsunit/java/src/net/jsunit/servlet/TestRunnerServlet.java
// public class TestRunnerServlet extends JsUnitServlet {
//
// protected synchronized void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Utility.log("TestRunnerServlet: Received request to run standalone test...");
// StandaloneTest test = createTest();
// TestResult result = TestRunner.run(test);
// writeResponse(response, result);
// Utility.log("TestRunnerServlet: ...Done");
// }
//
// protected void writeResponse(HttpServletResponse response, TestResult result) throws IOException {
// response.setContentType("text/xml");
// OutputStream out = response.getOutputStream();
// String resultString = result.wasSuccessful() ? "success" : "failure";
// out.write(("<result>" + resultString + "</result>").getBytes());
// out.close();
// }
//
// protected StandaloneTest createTest() {
// StandaloneTest standaloneTest = new StandaloneTest("testStandaloneRun");
// standaloneTest.setServer(server);
// return standaloneTest;
// }
// }
// Path: jsunit/java/src/net/jsunit/JsUnitServer.java
import net.jsunit.servlet.JsUnitServlet;
import net.jsunit.servlet.ResultAcceptorServlet;
import net.jsunit.servlet.ResultDisplayerServlet;
import net.jsunit.servlet.TestRunnerServlet;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpServer;
import org.mortbay.http.handler.ResourceHandler;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.start.Monitor;
import org.mortbay.util.MultiException;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
configuration.configure(this);
initialized = true;
} catch (ConfigurationException ce) {
System.err.println("Server initialization failed because property \"" + ce.getPropertyInError() + "\" has an invalid value of \"" + ce.getInvalidValue() + "\"");
throw ce;
}
}
public void start() throws MultiException {
if (!initialized) {
System.err.println("Cannot start server: not initialized");
return;
}
try {
setUpHttpServer();
} catch (IOException e) {
e.printStackTrace();
return;
}
super.start();
Utility.log(asString());
}
private void setUpHttpServer() throws IOException {
addListener(":" + port);
HttpContext context = getContext("/jsunit");
ServletHandler handler;
handler = new ServletHandler();
handler.addServlet("JsUnitResultAcceptor", "/acceptor", ResultAcceptorServlet.class.getName());
handler.addServlet("JsUnitResultDisplayer", "/displayer", ResultDisplayerServlet.class.getName()); | handler.addServlet("JsUnitTestRunner", "/runner", TestRunnerServlet.class.getName()); |
ndebeiss/svg3d | jsunit/java/src/net/jsunit/test/TestCaseResultTest.java | // Path: jsunit/java/src/net/jsunit/TestCaseResult.java
// public class TestCaseResult {
// public static final String DELIMITER = "|", ERROR_INDICATOR = "E", FAILURE_INDICATOR = "F";
// private String name;
// private double time;
// private String failure, error;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getError() {
// return error;
// }
//
// public void setError(String error) {
// this.error = error;
// }
//
// public String getFailure() {
// return failure;
// }
//
// public void setFailure(String failure) {
// this.failure = failure;
// }
//
// public double getTime() {
// return time;
// }
//
// public void setTime(double time) {
// this.time = time;
// }
//
// public boolean hadError() {
// return error != null;
// }
//
// public boolean hadFailure() {
// return failure != null;
// }
//
// public boolean hadSuccess() {
// return !hadError() && !hadFailure();
// }
//
// public static TestCaseResult fromString(String string) {
// TestCaseResult result = new TestCaseResult();
// StringTokenizer toker = new StringTokenizer(string, DELIMITER);
// try {
// result.setName(toker.nextToken());
// result.setTime(Double.parseDouble(toker.nextToken()));
// String successString = toker.nextToken();
// if (successString.equals(ERROR_INDICATOR))
// result.setError(toker.nextToken());
// else if (successString.equals(FAILURE_INDICATOR))
// result.setFailure(toker.nextToken());
// } catch (java.util.NoSuchElementException ex) {
// result.setError("Incomplete test result: '" + string + "'.");
// }
// return result;
// }
//
// public static TestCaseResult fromXmlElement(Element testCaseElement) {
// return new TestCaseResultBuilder().build(testCaseElement);
// }
//
// public String writeXmlFragment() {
// return new TestCaseResultWriter(this).writeXmlFragment();
// }
//
// public String writeProblemSummary() {
// return new TestCaseResultWriter(this).writeProblemSummary();
// }
// }
| import junit.framework.TestCase;
import net.jsunit.TestCaseResult;
import net.jsunit.TestCaseResultWriter;
import org.jdom.Element; | package net.jsunit.test;
/**
* @author Edward Hieatt, [email protected]
*/
public class TestCaseResultTest extends TestCase {
public TestCaseResultTest(String name) {
super(name);
}
public void testBuildSuccessfulResultFromString() { | // Path: jsunit/java/src/net/jsunit/TestCaseResult.java
// public class TestCaseResult {
// public static final String DELIMITER = "|", ERROR_INDICATOR = "E", FAILURE_INDICATOR = "F";
// private String name;
// private double time;
// private String failure, error;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getError() {
// return error;
// }
//
// public void setError(String error) {
// this.error = error;
// }
//
// public String getFailure() {
// return failure;
// }
//
// public void setFailure(String failure) {
// this.failure = failure;
// }
//
// public double getTime() {
// return time;
// }
//
// public void setTime(double time) {
// this.time = time;
// }
//
// public boolean hadError() {
// return error != null;
// }
//
// public boolean hadFailure() {
// return failure != null;
// }
//
// public boolean hadSuccess() {
// return !hadError() && !hadFailure();
// }
//
// public static TestCaseResult fromString(String string) {
// TestCaseResult result = new TestCaseResult();
// StringTokenizer toker = new StringTokenizer(string, DELIMITER);
// try {
// result.setName(toker.nextToken());
// result.setTime(Double.parseDouble(toker.nextToken()));
// String successString = toker.nextToken();
// if (successString.equals(ERROR_INDICATOR))
// result.setError(toker.nextToken());
// else if (successString.equals(FAILURE_INDICATOR))
// result.setFailure(toker.nextToken());
// } catch (java.util.NoSuchElementException ex) {
// result.setError("Incomplete test result: '" + string + "'.");
// }
// return result;
// }
//
// public static TestCaseResult fromXmlElement(Element testCaseElement) {
// return new TestCaseResultBuilder().build(testCaseElement);
// }
//
// public String writeXmlFragment() {
// return new TestCaseResultWriter(this).writeXmlFragment();
// }
//
// public String writeProblemSummary() {
// return new TestCaseResultWriter(this).writeProblemSummary();
// }
// }
// Path: jsunit/java/src/net/jsunit/test/TestCaseResultTest.java
import junit.framework.TestCase;
import net.jsunit.TestCaseResult;
import net.jsunit.TestCaseResultWriter;
import org.jdom.Element;
package net.jsunit.test;
/**
* @author Edward Hieatt, [email protected]
*/
public class TestCaseResultTest extends TestCase {
public TestCaseResultTest(String name) {
super(name);
}
public void testBuildSuccessfulResultFromString() { | TestCaseResult result = TestCaseResult.fromString("file:///dummy/path/dummyPage.html:testFoo|1.3|S||"); |
ndebeiss/svg3d | jsunit/java/src/net/jsunit/servlet/TestRunnerServlet.java | // Path: jsunit/java/src/net/jsunit/Utility.java
// public class Utility {
// private static boolean logToStandardOut = true;
//
// public static boolean isEmpty(String s) {
// return s == null || s.trim().equals("");
// }
//
// public static void writeFile(String contents, String fileName) {
// writeFile(contents, new File(".", fileName));
// }
//
// public static void writeFile(String contents, File file) {
// try {
// if (file.exists())
// file.delete();
// BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
// out.write(contents.getBytes());
// out.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public static List listFromCommaDelimitedString(String string) {
// List result = new ArrayList();
// if (isEmpty(string))
// return result;
// StringTokenizer toker = new StringTokenizer(string, ",");
// while (toker.hasMoreTokens())
// result.add(toker.nextToken());
// return result;
// }
//
// public static void log(String message, boolean includeDate) {
// if (logToStandardOut) {
// StringBuffer buffer = new StringBuffer();
// if (includeDate) {
// buffer.append(new Date());
// buffer.append(": ");
// }
// buffer.append(message);
// System.out.println(buffer.toString());
// }
// }
//
// public static void log(String message) {
// log(message, true);
// }
//
// public static void setLogToStandardOut(boolean b) {
// logToStandardOut = b;
// }
//
// public static List listWith(Object object1, Object object2) {
// return Arrays.asList(new Object[]{object1, object2});
// }
//
// public static void deleteFile(String fileName) {
// File file = new File(".", fileName);
// file.delete();
// }
//
// public static void deleteDirectory(String directoryName) {
// File file = new File(directoryName);
// file.delete();
// }
// }
| import junit.framework.TestResult;
import junit.textui.TestRunner;
import net.jsunit.StandaloneTest;
import net.jsunit.Utility;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream; | package net.jsunit.servlet;
/**
* @author Edward Hieatt, [email protected]
*/
public class TestRunnerServlet extends JsUnitServlet {
protected synchronized void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | // Path: jsunit/java/src/net/jsunit/Utility.java
// public class Utility {
// private static boolean logToStandardOut = true;
//
// public static boolean isEmpty(String s) {
// return s == null || s.trim().equals("");
// }
//
// public static void writeFile(String contents, String fileName) {
// writeFile(contents, new File(".", fileName));
// }
//
// public static void writeFile(String contents, File file) {
// try {
// if (file.exists())
// file.delete();
// BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
// out.write(contents.getBytes());
// out.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public static List listFromCommaDelimitedString(String string) {
// List result = new ArrayList();
// if (isEmpty(string))
// return result;
// StringTokenizer toker = new StringTokenizer(string, ",");
// while (toker.hasMoreTokens())
// result.add(toker.nextToken());
// return result;
// }
//
// public static void log(String message, boolean includeDate) {
// if (logToStandardOut) {
// StringBuffer buffer = new StringBuffer();
// if (includeDate) {
// buffer.append(new Date());
// buffer.append(": ");
// }
// buffer.append(message);
// System.out.println(buffer.toString());
// }
// }
//
// public static void log(String message) {
// log(message, true);
// }
//
// public static void setLogToStandardOut(boolean b) {
// logToStandardOut = b;
// }
//
// public static List listWith(Object object1, Object object2) {
// return Arrays.asList(new Object[]{object1, object2});
// }
//
// public static void deleteFile(String fileName) {
// File file = new File(".", fileName);
// file.delete();
// }
//
// public static void deleteDirectory(String directoryName) {
// File file = new File(directoryName);
// file.delete();
// }
// }
// Path: jsunit/java/src/net/jsunit/servlet/TestRunnerServlet.java
import junit.framework.TestResult;
import junit.textui.TestRunner;
import net.jsunit.StandaloneTest;
import net.jsunit.Utility;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
package net.jsunit.servlet;
/**
* @author Edward Hieatt, [email protected]
*/
public class TestRunnerServlet extends JsUnitServlet {
protected synchronized void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | Utility.log("TestRunnerServlet: Received request to run standalone test..."); |
larusba/doc2graph | neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderTypeArrayKeyTest.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
| import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.FormattedLogProvider;
import org.neo4j.logging.Log;
import java.io.File;
import java.util.Set;
import java.util.stream.StreamSupport;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.Direction; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* @author Omar Rampado
*
*/
public class DocumentRelationBuilderTypeArrayKeyTest {
private static GraphDatabaseService db;
private static Log log;
private Transaction tx;
private DocumentRelationBuilderTypeArrayKey docrel; | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
// Path: neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderTypeArrayKeyTest.java
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.FormattedLogProvider;
import org.neo4j.logging.Log;
import java.io.File;
import java.util.Set;
import java.util.stream.StreamSupport;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.Direction;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* @author Omar Rampado
*
*/
public class DocumentRelationBuilderTypeArrayKeyTest {
private static GraphDatabaseService db;
private static Log log;
private Transaction tx;
private DocumentRelationBuilderTypeArrayKey docrel; | private DocumentRelationContext context; |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderHasTypeArrayKey.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
| import org.neo4j.graphdb.Node;
import org.neo4j.helpers.json.document.context.DocumentRelationContext; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build relationship with name "HAS_"+the type of destination node
* ES: HAS_TRACKS
* @author Omar Rampado
*/
public class DocumentRelationBuilderHasTypeArrayKey extends DocumentRelationBuilderTypeArrayKey {
@Override | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderHasTypeArrayKey.java
import org.neo4j.graphdb.Node;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build relationship with name "HAS_"+the type of destination node
* ES: HAS_TRACKS
* @author Omar Rampado
*/
public class DocumentRelationBuilderHasTypeArrayKey extends DocumentRelationBuilderTypeArrayKey {
@Override | protected String buildRelationName(Node parent, Node child, DocumentRelationContext context) { |
larusba/doc2graph | neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderPairTest.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
| import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.helpers.json.document.DocumentId; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
public class DocumentIdBuilderPairTest {
DocumentIdBuilderPair builder;
@Before
public void setUp() throws Exception {
this.builder = new DocumentIdBuilderPair();
Map<String, String> conf = new HashMap<>();
conf.put("builder_id_pair_key1", "attribute");
conf.put("builder_id_pair_key2", "name");
this.builder.init(conf);
}
@Test
public void testBuildId() {
Map<String, Object> map = new HashMap<>();
map.put("attribute", 12);
map.put("name", "artist"); | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
// Path: neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderPairTest.java
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.helpers.json.document.DocumentId;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
public class DocumentIdBuilderPairTest {
DocumentIdBuilderPair builder;
@Before
public void setUp() throws Exception {
this.builder = new DocumentIdBuilderPair();
Map<String, String> conf = new HashMap<>();
conf.put("builder_id_pair_key1", "attribute");
conf.put("builder_id_pair_key2", "name");
this.builder.init(conf);
}
@Test
public void testBuildId() {
Map<String, Object> map = new HashMap<>();
map.put("attribute", 12);
map.put("name", "artist"); | DocumentId buildId = builder.buildId(map); |
larusba/doc2graph | neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderByKeyTest.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
| import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.FormattedLogProvider;
import org.neo4j.logging.Log;
import java.io.File;
import java.util.Set;
import java.util.stream.StreamSupport;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.Direction; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* @author Omar Rampado
*
*/
public class DocumentRelationBuilderByKeyTest {
private static GraphDatabaseService db;
private static Log log;
private Transaction tx;
private DocumentRelationBuilderByKey docrel; | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
// Path: neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderByKeyTest.java
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.FormattedLogProvider;
import org.neo4j.logging.Log;
import java.io.File;
import java.util.Set;
import java.util.stream.StreamSupport;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.Direction;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* @author Omar Rampado
*
*/
public class DocumentRelationBuilderByKeyTest {
private static GraphDatabaseService db;
private static Log log;
private Transaction tx;
private DocumentRelationBuilderByKey docrel; | private DocumentRelationContext context; |
larusba/doc2graph | neo4j-json/src/test/java/org/neo4j/helpers/json/JsonHelperDefaultTest.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/config/JsonHelperConfiguration.java
// public abstract class JsonHelperConfiguration {
//
// /**
// * Create a new execution context setting db and log.
// * @param db
// * @param log
// * @return
// */
// protected abstract DocumentGrapherExecutionContext buildContext(GraphDatabaseService db, Log log);
//
// private static JsonHelperConfiguration instance;
//
// /**
// * Get current configuration manager
// * @return
// */
// public static DocumentGrapherExecutionContext newContext(GraphDatabaseService db, Log log)
// {
//
// if(instance == null)
// {
// Node configurationNode = db.findNode(Label.label("JSON_CONFIG"), "configuration", "byNode");
// if(configurationNode == null)
// {
// log.info("Load default configuration: "+JsonHelperConfigurationDefault.class);
// instance = new JsonHelperConfigurationDefault();
// }else
// {
// log.info("Load configuration from node: "+JsonHelperConfigurationByNode.class);
// instance = new JsonHelperConfigurationByNode(configurationNode);
// }
// }
//
// return instance.buildContext(db, log);
// }
//
// public static void reset()
// {
// instance = null;
// }
// }
| import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Record;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.StatementResult;
import org.neo4j.driver.v1.Values;
import org.neo4j.harness.junit.Neo4jRule;
import org.neo4j.helpers.json.config.JsonHelperConfiguration;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.driver.v1.Config;
import org.neo4j.driver.v1.Driver; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json;
/**
* Test with default configuration
* @author Omar Rampado
*
*/
public class JsonHelperDefaultTest {
private static final String CALL_UPSERT = "CALL json.upsert({key},{json})";
private static final String CALL_DELETE = "CALL json.delete({key})";
// This rule starts a Neo4j instance for us
@ClassRule
public static Neo4jRule neo4j = new Neo4jRule().withProcedure(JsonHelper.class);
private static Driver driver;
private Session session;
@BeforeClass
public static void init() { | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/config/JsonHelperConfiguration.java
// public abstract class JsonHelperConfiguration {
//
// /**
// * Create a new execution context setting db and log.
// * @param db
// * @param log
// * @return
// */
// protected abstract DocumentGrapherExecutionContext buildContext(GraphDatabaseService db, Log log);
//
// private static JsonHelperConfiguration instance;
//
// /**
// * Get current configuration manager
// * @return
// */
// public static DocumentGrapherExecutionContext newContext(GraphDatabaseService db, Log log)
// {
//
// if(instance == null)
// {
// Node configurationNode = db.findNode(Label.label("JSON_CONFIG"), "configuration", "byNode");
// if(configurationNode == null)
// {
// log.info("Load default configuration: "+JsonHelperConfigurationDefault.class);
// instance = new JsonHelperConfigurationDefault();
// }else
// {
// log.info("Load configuration from node: "+JsonHelperConfigurationByNode.class);
// instance = new JsonHelperConfigurationByNode(configurationNode);
// }
// }
//
// return instance.buildContext(db, log);
// }
//
// public static void reset()
// {
// instance = null;
// }
// }
// Path: neo4j-json/src/test/java/org/neo4j/helpers/json/JsonHelperDefaultTest.java
import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Record;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.StatementResult;
import org.neo4j.driver.v1.Values;
import org.neo4j.harness.junit.Neo4jRule;
import org.neo4j.helpers.json.config.JsonHelperConfiguration;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.driver.v1.Config;
import org.neo4j.driver.v1.Driver;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json;
/**
* Test with default configuration
* @author Omar Rampado
*
*/
public class JsonHelperDefaultTest {
private static final String CALL_UPSERT = "CALL json.upsert({key},{json})";
private static final String CALL_DELETE = "CALL json.delete({key})";
// This rule starts a Neo4j instance for us
@ClassRule
public static Neo4jRule neo4j = new Neo4jRule().withProcedure(JsonHelper.class);
private static Driver driver;
private Session session;
@BeforeClass
public static void init() { | JsonHelperConfiguration.reset(); |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdId.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/utils/IdValueTypeSafe.java
// public class IdValueTypeSafe {
//
// private Object value;
//
// /**
// * Wrap the real value
// * @param value
// */
// public IdValueTypeSafe(Object value) {
// if(value == null)
// {
// throw new IllegalArgumentException("value cannot be null");
// }
// this.value = value;
// }
//
// /**
// * return a filter value according with type of real value
// * @return
// */
// public String toCypher(){
// if(isString())
// {
// return "'"+toString().replaceAll("'", "\\\\'")+"'";
// }
// return toString();
// }
//
// public boolean isString(){
// return (value instanceof String);
// }
//
// public boolean isNumber(){
// return !isString();
// }
//
// /**
// * get the original value
// * @return
// */
// public Object getValue(){
// return this.value;
// }
//
// @Override
// public String toString() {
// return value.toString();
// }
//
// }
| import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.utils.IdValueTypeSafe;
import java.util.HashMap;
import java.util.Map; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* DocumentId composed of single "id"
* @author Omar Rampado
*
*/
public class DocumentIdId implements DocumentId {
public static final String ID = "id";
| // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/utils/IdValueTypeSafe.java
// public class IdValueTypeSafe {
//
// private Object value;
//
// /**
// * Wrap the real value
// * @param value
// */
// public IdValueTypeSafe(Object value) {
// if(value == null)
// {
// throw new IllegalArgumentException("value cannot be null");
// }
// this.value = value;
// }
//
// /**
// * return a filter value according with type of real value
// * @return
// */
// public String toCypher(){
// if(isString())
// {
// return "'"+toString().replaceAll("'", "\\\\'")+"'";
// }
// return toString();
// }
//
// public boolean isString(){
// return (value instanceof String);
// }
//
// public boolean isNumber(){
// return !isString();
// }
//
// /**
// * get the original value
// * @return
// */
// public Object getValue(){
// return this.value;
// }
//
// @Override
// public String toString() {
// return value.toString();
// }
//
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdId.java
import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.utils.IdValueTypeSafe;
import java.util.HashMap;
import java.util.Map;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* DocumentId composed of single "id"
* @author Omar Rampado
*
*/
public class DocumentIdId implements DocumentId {
public static final String ID = "id";
| private IdValueTypeSafe id; |
larusba/doc2graph | neo4j-json/src/test/java/org/neo4j/helpers/json/JsonHelperCustomTest.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/config/JsonHelperConfiguration.java
// public abstract class JsonHelperConfiguration {
//
// /**
// * Create a new execution context setting db and log.
// * @param db
// * @param log
// * @return
// */
// protected abstract DocumentGrapherExecutionContext buildContext(GraphDatabaseService db, Log log);
//
// private static JsonHelperConfiguration instance;
//
// /**
// * Get current configuration manager
// * @return
// */
// public static DocumentGrapherExecutionContext newContext(GraphDatabaseService db, Log log)
// {
//
// if(instance == null)
// {
// Node configurationNode = db.findNode(Label.label("JSON_CONFIG"), "configuration", "byNode");
// if(configurationNode == null)
// {
// log.info("Load default configuration: "+JsonHelperConfigurationDefault.class);
// instance = new JsonHelperConfigurationDefault();
// }else
// {
// log.info("Load configuration from node: "+JsonHelperConfigurationByNode.class);
// instance = new JsonHelperConfigurationByNode(configurationNode);
// }
// }
//
// return instance.buildContext(db, log);
// }
//
// public static void reset()
// {
// instance = null;
// }
// }
| import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Record;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.StatementResult;
import org.neo4j.driver.v1.Values;
import org.neo4j.harness.junit.Neo4jRule;
import org.neo4j.helpers.json.config.JsonHelperConfiguration;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.driver.v1.Config; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json;
/**
* Test with default configuration
* @author Omar Rampado
*
*/
public class JsonHelperCustomTest {
private static final String CALL_UPSERT = "CALL json.upsert({key},{json})";
private static final String CALL_DELETE = "CALL json.delete({key})";
// This rule starts a Neo4j instance for us
@ClassRule
public static Neo4jRule neo4j = new Neo4jRule().withProcedure(JsonHelper.class);
private static Driver driver;
private Session session;
@BeforeClass
public static void init() { | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/config/JsonHelperConfiguration.java
// public abstract class JsonHelperConfiguration {
//
// /**
// * Create a new execution context setting db and log.
// * @param db
// * @param log
// * @return
// */
// protected abstract DocumentGrapherExecutionContext buildContext(GraphDatabaseService db, Log log);
//
// private static JsonHelperConfiguration instance;
//
// /**
// * Get current configuration manager
// * @return
// */
// public static DocumentGrapherExecutionContext newContext(GraphDatabaseService db, Log log)
// {
//
// if(instance == null)
// {
// Node configurationNode = db.findNode(Label.label("JSON_CONFIG"), "configuration", "byNode");
// if(configurationNode == null)
// {
// log.info("Load default configuration: "+JsonHelperConfigurationDefault.class);
// instance = new JsonHelperConfigurationDefault();
// }else
// {
// log.info("Load configuration from node: "+JsonHelperConfigurationByNode.class);
// instance = new JsonHelperConfigurationByNode(configurationNode);
// }
// }
//
// return instance.buildContext(db, log);
// }
//
// public static void reset()
// {
// instance = null;
// }
// }
// Path: neo4j-json/src/test/java/org/neo4j/helpers/json/JsonHelperCustomTest.java
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Record;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.StatementResult;
import org.neo4j.driver.v1.Values;
import org.neo4j.harness.junit.Neo4jRule;
import org.neo4j.helpers.json.config.JsonHelperConfiguration;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.driver.v1.Config;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json;
/**
* Test with default configuration
* @author Omar Rampado
*
*/
public class JsonHelperCustomTest {
private static final String CALL_UPSERT = "CALL json.upsert({key},{json})";
private static final String CALL_DELETE = "CALL json.delete({key})";
// This rule starts a Neo4j instance for us
@ClassRule
public static Neo4jRule neo4j = new Neo4jRule().withProcedure(JsonHelper.class);
private static Driver driver;
private Session session;
@BeforeClass
public static void init() { | JsonHelperConfiguration.reset(); |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdTypeId.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/utils/IdValueTypeSafe.java
// public class IdValueTypeSafe {
//
// private Object value;
//
// /**
// * Wrap the real value
// * @param value
// */
// public IdValueTypeSafe(Object value) {
// if(value == null)
// {
// throw new IllegalArgumentException("value cannot be null");
// }
// this.value = value;
// }
//
// /**
// * return a filter value according with type of real value
// * @return
// */
// public String toCypher(){
// if(isString())
// {
// return "'"+toString().replaceAll("'", "\\\\'")+"'";
// }
// return toString();
// }
//
// public boolean isString(){
// return (value instanceof String);
// }
//
// public boolean isNumber(){
// return !isString();
// }
//
// /**
// * get the original value
// * @return
// */
// public Object getValue(){
// return this.value;
// }
//
// @Override
// public String toString() {
// return value.toString();
// }
//
// }
| import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.utils.IdValueTypeSafe;
import java.util.HashMap;
import java.util.Map; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* DocumentId composed of "type" and "id"
* @author Omar Rampado
*
*/
public class DocumentIdTypeId implements DocumentId {
public static final String ID = "id";
public static final String TYPE = "type";
| // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/utils/IdValueTypeSafe.java
// public class IdValueTypeSafe {
//
// private Object value;
//
// /**
// * Wrap the real value
// * @param value
// */
// public IdValueTypeSafe(Object value) {
// if(value == null)
// {
// throw new IllegalArgumentException("value cannot be null");
// }
// this.value = value;
// }
//
// /**
// * return a filter value according with type of real value
// * @return
// */
// public String toCypher(){
// if(isString())
// {
// return "'"+toString().replaceAll("'", "\\\\'")+"'";
// }
// return toString();
// }
//
// public boolean isString(){
// return (value instanceof String);
// }
//
// public boolean isNumber(){
// return !isString();
// }
//
// /**
// * get the original value
// * @return
// */
// public Object getValue(){
// return this.value;
// }
//
// @Override
// public String toString() {
// return value.toString();
// }
//
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdTypeId.java
import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.utils.IdValueTypeSafe;
import java.util.HashMap;
import java.util.Map;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* DocumentId composed of "type" and "id"
* @author Omar Rampado
*
*/
public class DocumentIdTypeId implements DocumentId {
public static final String ID = "id";
public static final String TYPE = "type";
| private IdValueTypeSafe id; |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderPair.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
| import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import java.util.Map;
import org.apache.commons.lang3.Validate; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build {@link DocumentIdPair}
* @author Omar Rampado
*
*/
public class DocumentIdBuilderPair implements DocumentIdBuilder {
private String key1;
private String key2;
/*
* (non-Javadoc)
*
* @see
* org.neo4j.helpers.json.document.DocumentIdBuilder#buildId(java.util.Map)
*/
@Override | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderPair.java
import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import java.util.Map;
import org.apache.commons.lang3.Validate;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build {@link DocumentIdPair}
* @author Omar Rampado
*
*/
public class DocumentIdBuilderPair implements DocumentIdBuilder {
private String key1;
private String key2;
/*
* (non-Javadoc)
*
* @see
* org.neo4j.helpers.json.document.DocumentIdBuilder#buildId(java.util.Map)
*/
@Override | public DocumentId buildId(Map<String,Object> obj) { |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderId.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
| import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import java.util.Map;
import org.apache.commons.lang3.Validate; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build {@link DocumentIdId}
* @author Omar Rampado
*
*/
public class DocumentIdBuilderId implements DocumentIdBuilder {
/*
* (non-Javadoc)
*
* @see
* org.neo4j.helpers.json.document.DocumentIdBuilder#buildId(java.util.Map)
*/
@Override | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderId.java
import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import java.util.Map;
import org.apache.commons.lang3.Validate;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build {@link DocumentIdId}
* @author Omar Rampado
*
*/
public class DocumentIdBuilderId implements DocumentIdBuilder {
/*
* (non-Javadoc)
*
* @see
* org.neo4j.helpers.json.document.DocumentIdBuilder#buildId(java.util.Map)
*/
@Override | public DocumentId buildId(Map<String,Object> obj) { |
larusba/doc2graph | neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderTypeIdTest.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
| import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.helpers.json.document.DocumentId; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
public class DocumentIdBuilderTypeIdTest {
DocumentIdBuilderTypeId builder;
@Before
public void setUp() throws Exception {
this.builder = new DocumentIdBuilderTypeId();
}
@Test
public void testBuildId() {
Map<String, Object> map = new HashMap<>();
map.put("id", 12);
map.put("type", "artist"); | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
// Path: neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderTypeIdTest.java
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.helpers.json.document.DocumentId;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
public class DocumentIdBuilderTypeIdTest {
DocumentIdBuilderTypeId builder;
@Before
public void setUp() throws Exception {
this.builder = new DocumentIdBuilderTypeId();
}
@Test
public void testBuildId() {
Map<String, Object> map = new HashMap<>();
map.put("id", 12);
map.put("type", "artist"); | DocumentId buildId = builder.buildId(map); |
larusba/doc2graph | couchbase-neo4j-connector/src/main/java/com/couchbase/client/neo4j/connector/impl/BoltNeo4jConnector.java | // Path: couchbase-neo4j-connector/src/main/java/com/couchbase/client/neo4j/conf/Neo4jSyncConfManager.java
// public interface Neo4jSyncConfManager {
//
// /**
// * couchbase.hostname
// * @return
// */
// String getCouchbaseHostname();
//
// /**
// * couchbase.bucket
// * @return
// */
// String getCouchbaseBucket();
//
// /**
// * neo4j.hostname
// * @return
// */
// String getNeo4jHostname();
//
// /**
// * neo4j.username
// * @return
// */
// String getNeo4jUsername();
//
// /**
// * neo4j.password
// * @return
// */
// String getNeo4jPassword();
// }
//
// Path: couchbase-neo4j-connector/src/main/java/com/couchbase/client/neo4j/connector/Neo4jConnector.java
// public interface Neo4jConnector {
//
// /**
// * Update the graph with new information
// * @param key
// * @param json
// * @return
// */
// String onMutation(String key, String json);
//
// /**
// * Remove the document from graph
// * @param key
// * @return
// */
// String onDelete(String key);
// }
| import org.neo4j.driver.v1.AuthTokens;
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.Values;
import com.couchbase.client.core.logging.CouchbaseLogger;
import com.couchbase.client.core.logging.CouchbaseLoggerFactory;
import com.couchbase.client.neo4j.conf.Neo4jSyncConfManager;
import com.couchbase.client.neo4j.connector.Neo4jConnector; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.couchbase.client.neo4j.connector.impl;
/**
* Call Neo4j procedures using Bolt protocol
* @author Omar Rampado
*
*/
public class BoltNeo4jConnector implements Neo4jConnector {
private static final CouchbaseLogger log = CouchbaseLoggerFactory.getInstance(BoltNeo4jConnector.class);
//TODO convert in threadlocal???
private Session session;
/**
*
*/
public BoltNeo4jConnector() {
}
| // Path: couchbase-neo4j-connector/src/main/java/com/couchbase/client/neo4j/conf/Neo4jSyncConfManager.java
// public interface Neo4jSyncConfManager {
//
// /**
// * couchbase.hostname
// * @return
// */
// String getCouchbaseHostname();
//
// /**
// * couchbase.bucket
// * @return
// */
// String getCouchbaseBucket();
//
// /**
// * neo4j.hostname
// * @return
// */
// String getNeo4jHostname();
//
// /**
// * neo4j.username
// * @return
// */
// String getNeo4jUsername();
//
// /**
// * neo4j.password
// * @return
// */
// String getNeo4jPassword();
// }
//
// Path: couchbase-neo4j-connector/src/main/java/com/couchbase/client/neo4j/connector/Neo4jConnector.java
// public interface Neo4jConnector {
//
// /**
// * Update the graph with new information
// * @param key
// * @param json
// * @return
// */
// String onMutation(String key, String json);
//
// /**
// * Remove the document from graph
// * @param key
// * @return
// */
// String onDelete(String key);
// }
// Path: couchbase-neo4j-connector/src/main/java/com/couchbase/client/neo4j/connector/impl/BoltNeo4jConnector.java
import org.neo4j.driver.v1.AuthTokens;
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.Values;
import com.couchbase.client.core.logging.CouchbaseLogger;
import com.couchbase.client.core.logging.CouchbaseLoggerFactory;
import com.couchbase.client.neo4j.conf.Neo4jSyncConfManager;
import com.couchbase.client.neo4j.connector.Neo4jConnector;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.couchbase.client.neo4j.connector.impl;
/**
* Call Neo4j procedures using Bolt protocol
* @author Omar Rampado
*
*/
public class BoltNeo4jConnector implements Neo4jConnector {
private static final CouchbaseLogger log = CouchbaseLoggerFactory.getInstance(BoltNeo4jConnector.class);
//TODO convert in threadlocal???
private Session session;
/**
*
*/
public BoltNeo4jConnector() {
}
| public void init(Neo4jSyncConfManager configuration) |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderByKey.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
| import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Result;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.Log;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.StringUtils;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build relationship using document key as label
* @author Omar Rampado
*
*/
public class DocumentRelationBuilderByKey implements DocumentRelationBuilder {
private GraphDatabaseService db;
private Log log;
/**
* @param db the db to set
*/
public void setDb(GraphDatabaseService db) {
this.db = db;
}
/**
* @param log the log to set
*/
public void setLog(Log log) {
this.log = log;
}
/* (non-Javadoc)
* @see org.neo4j.helpers.json.document.DocumentRelationBuilder#buildRelation(org.neo4j.graphdb.Node, org.neo4j.graphdb.Node, org.neo4j.helpers.json.document.DocumentRelationContext)
*/
@Override | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderByKey.java
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Result;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.Log;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.StringUtils;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build relationship using document key as label
* @author Omar Rampado
*
*/
public class DocumentRelationBuilderByKey implements DocumentRelationBuilder {
private GraphDatabaseService db;
private Log log;
/**
* @param db the db to set
*/
public void setDb(GraphDatabaseService db) {
this.db = db;
}
/**
* @param log the log to set
*/
public void setLog(Log log) {
this.log = log;
}
/* (non-Javadoc)
* @see org.neo4j.helpers.json.document.DocumentRelationBuilder#buildRelation(org.neo4j.graphdb.Node, org.neo4j.graphdb.Node, org.neo4j.helpers.json.document.DocumentRelationContext)
*/
@Override | public Relationship buildRelation(Node parent, Node child, DocumentRelationContext context) { |
larusba/doc2graph | neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderIdTest.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
| import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.helpers.json.document.DocumentId; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
public class DocumentIdBuilderIdTest {
DocumentIdBuilderId builder;
@Before
public void setUp() throws Exception {
this.builder = new DocumentIdBuilderId();
}
@Test
public void testBuildId() {
Map<String, Object> map = new HashMap<>();
map.put("id", 12);
map.put("type", "artist"); | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
// Path: neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderIdTest.java
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.helpers.json.document.DocumentId;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
public class DocumentIdBuilderIdTest {
DocumentIdBuilderId builder;
@Before
public void setUp() throws Exception {
this.builder = new DocumentIdBuilderId();
}
@Test
public void testBuildId() {
Map<String, Object> map = new HashMap<>();
map.put("id", 12);
map.put("type", "artist"); | DocumentId buildId = builder.buildId(map); |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderTypeArrayKey.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
| import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Result;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.Log;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.ArrayUtils;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build relationship with name parent.type_child.type with docKeys array
* ES: artist_origin
* @author Omar Rampado
*
*/
public class DocumentRelationBuilderTypeArrayKey implements DocumentRelationBuilder {
private static final String DOC_KEYS = "docKeys";
private GraphDatabaseService db;
private Log log;
/**
* @param db the db to set
*/
public void setDb(GraphDatabaseService db) {
this.db = db;
}
/**
* @param log the log to set
*/
public void setLog(Log log) {
this.log = log;
}
/**
* Compose the type of the relationship
* @param parent
* @param child
* @param context
* @return
*/ | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderTypeArrayKey.java
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Result;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.Log;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.ArrayUtils;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build relationship with name parent.type_child.type with docKeys array
* ES: artist_origin
* @author Omar Rampado
*
*/
public class DocumentRelationBuilderTypeArrayKey implements DocumentRelationBuilder {
private static final String DOC_KEYS = "docKeys";
private GraphDatabaseService db;
private Log log;
/**
* @param db the db to set
*/
public void setDb(GraphDatabaseService db) {
this.db = db;
}
/**
* @param log the log to set
*/
public void setLog(Log log) {
this.log = log;
}
/**
* Compose the type of the relationship
* @param parent
* @param child
* @param context
* @return
*/ | protected String buildRelationName(Node parent, Node child, DocumentRelationContext context){ |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdPair.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/utils/IdValueTypeSafe.java
// public class IdValueTypeSafe {
//
// private Object value;
//
// /**
// * Wrap the real value
// * @param value
// */
// public IdValueTypeSafe(Object value) {
// if(value == null)
// {
// throw new IllegalArgumentException("value cannot be null");
// }
// this.value = value;
// }
//
// /**
// * return a filter value according with type of real value
// * @return
// */
// public String toCypher(){
// if(isString())
// {
// return "'"+toString().replaceAll("'", "\\\\'")+"'";
// }
// return toString();
// }
//
// public boolean isString(){
// return (value instanceof String);
// }
//
// public boolean isNumber(){
// return !isString();
// }
//
// /**
// * get the original value
// * @return
// */
// public Object getValue(){
// return this.value;
// }
//
// @Override
// public String toString() {
// return value.toString();
// }
//
// }
| import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.utils.IdValueTypeSafe;
import java.util.HashMap;
import java.util.Map; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* DocumentId composed by a pair of values, customizable
* @author Omar Rampado
*
*/
public class DocumentIdPair implements DocumentId {
private String key1;
private String key2; | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/utils/IdValueTypeSafe.java
// public class IdValueTypeSafe {
//
// private Object value;
//
// /**
// * Wrap the real value
// * @param value
// */
// public IdValueTypeSafe(Object value) {
// if(value == null)
// {
// throw new IllegalArgumentException("value cannot be null");
// }
// this.value = value;
// }
//
// /**
// * return a filter value according with type of real value
// * @return
// */
// public String toCypher(){
// if(isString())
// {
// return "'"+toString().replaceAll("'", "\\\\'")+"'";
// }
// return toString();
// }
//
// public boolean isString(){
// return (value instanceof String);
// }
//
// public boolean isNumber(){
// return !isString();
// }
//
// /**
// * get the original value
// * @return
// */
// public Object getValue(){
// return this.value;
// }
//
// @Override
// public String toString() {
// return value.toString();
// }
//
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdPair.java
import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.utils.IdValueTypeSafe;
import java.util.HashMap;
import java.util.Map;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* DocumentId composed by a pair of values, customizable
* @author Omar Rampado
*
*/
public class DocumentIdPair implements DocumentId {
private String key1;
private String key2; | private IdValueTypeSafe v1; |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentGrapherExecutionContext.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentLabelBuilder.java
// public interface DocumentLabelBuilder {
//
// /**
// * Choose label for the root object in map
// * @param obj
// * @return
// */
// Label buildLabel(Map<String, Object> obj);
//
// /**
// * Set default label if cannot be assigned at runtime
// * @param defaultLabel
// */
// void setDefaultLabel(String defaultLabel);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
| import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import org.neo4j.helpers.json.document.DocumentLabelBuilder;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.logging.Log; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.context;
/**
* Configuration of DocumentGrapher dependency
*
* @author Omar Rampado
*
*/
public class DocumentGrapherExecutionContext {
private GraphDatabaseService db;
private Log log; | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentLabelBuilder.java
// public interface DocumentLabelBuilder {
//
// /**
// * Choose label for the root object in map
// * @param obj
// * @return
// */
// Label buildLabel(Map<String, Object> obj);
//
// /**
// * Set default label if cannot be assigned at runtime
// * @param defaultLabel
// */
// void setDefaultLabel(String defaultLabel);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentGrapherExecutionContext.java
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import org.neo4j.helpers.json.document.DocumentLabelBuilder;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.logging.Log;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.context;
/**
* Configuration of DocumentGrapher dependency
*
* @author Omar Rampado
*
*/
public class DocumentGrapherExecutionContext {
private GraphDatabaseService db;
private Log log; | private DocumentIdBuilder documentIdBuilder; |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentGrapherExecutionContext.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentLabelBuilder.java
// public interface DocumentLabelBuilder {
//
// /**
// * Choose label for the root object in map
// * @param obj
// * @return
// */
// Label buildLabel(Map<String, Object> obj);
//
// /**
// * Set default label if cannot be assigned at runtime
// * @param defaultLabel
// */
// void setDefaultLabel(String defaultLabel);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
| import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import org.neo4j.helpers.json.document.DocumentLabelBuilder;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.logging.Log; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.context;
/**
* Configuration of DocumentGrapher dependency
*
* @author Omar Rampado
*
*/
public class DocumentGrapherExecutionContext {
private GraphDatabaseService db;
private Log log;
private DocumentIdBuilder documentIdBuilder; | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentLabelBuilder.java
// public interface DocumentLabelBuilder {
//
// /**
// * Choose label for the root object in map
// * @param obj
// * @return
// */
// Label buildLabel(Map<String, Object> obj);
//
// /**
// * Set default label if cannot be assigned at runtime
// * @param defaultLabel
// */
// void setDefaultLabel(String defaultLabel);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentGrapherExecutionContext.java
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import org.neo4j.helpers.json.document.DocumentLabelBuilder;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.logging.Log;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.context;
/**
* Configuration of DocumentGrapher dependency
*
* @author Omar Rampado
*
*/
public class DocumentGrapherExecutionContext {
private GraphDatabaseService db;
private Log log;
private DocumentIdBuilder documentIdBuilder; | private DocumentRelationBuilder documentRelationBuilder; |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentGrapherExecutionContext.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentLabelBuilder.java
// public interface DocumentLabelBuilder {
//
// /**
// * Choose label for the root object in map
// * @param obj
// * @return
// */
// Label buildLabel(Map<String, Object> obj);
//
// /**
// * Set default label if cannot be assigned at runtime
// * @param defaultLabel
// */
// void setDefaultLabel(String defaultLabel);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
| import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import org.neo4j.helpers.json.document.DocumentLabelBuilder;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.logging.Log; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.context;
/**
* Configuration of DocumentGrapher dependency
*
* @author Omar Rampado
*
*/
public class DocumentGrapherExecutionContext {
private GraphDatabaseService db;
private Log log;
private DocumentIdBuilder documentIdBuilder;
private DocumentRelationBuilder documentRelationBuilder; | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentLabelBuilder.java
// public interface DocumentLabelBuilder {
//
// /**
// * Choose label for the root object in map
// * @param obj
// * @return
// */
// Label buildLabel(Map<String, Object> obj);
//
// /**
// * Set default label if cannot be assigned at runtime
// * @param defaultLabel
// */
// void setDefaultLabel(String defaultLabel);
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
//
// /**
// * Create or update relationship between parent and child node
// * @param parent
// * @param child
// * @param context
// * @return
// */
// Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
//
// /**
// * Remove all relationships regarding document context
// * @param context
// * @return the 'orphan' nodes
// */
// Set<Node> deleteRelations(DocumentRelationContext context);
//
// void setDb(GraphDatabaseService db);
//
// void setLog(Log log);
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentGrapherExecutionContext.java
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import org.neo4j.helpers.json.document.DocumentLabelBuilder;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.logging.Log;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.context;
/**
* Configuration of DocumentGrapher dependency
*
* @author Omar Rampado
*
*/
public class DocumentGrapherExecutionContext {
private GraphDatabaseService db;
private Log log;
private DocumentIdBuilder documentIdBuilder;
private DocumentRelationBuilder documentRelationBuilder; | private DocumentLabelBuilder documentLabelBuilder; |
larusba/doc2graph | neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderTypeId.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
| import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import java.util.Map;
import org.apache.commons.lang3.Validate; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build {@link DocumentIdTypeId}
* @author Omar Rampado
*
*/
public class DocumentIdBuilderTypeId implements DocumentIdBuilder {
/*
* (non-Javadoc)
*
* @see
* org.neo4j.helpers.json.document.DocumentIdBuilder#buildId(java.util.Map)
*/
@Override | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentId.java
// public interface DocumentId {
//
// /**
// * Key is the attribute's name
// * Value is the attribute's value
// * that compose the identify
// * @return
// */
// Map<String, String> getFields();
//
// /**
// * Buil a cypher filter condition
// * ES: filed1: 'aaa', field2: 'bbb'
// * @return
// */
// String toCypherFilter();
//
// /**
// * Equals and hashCode must be implemented
// */
// }
//
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentIdBuilder.java
// public interface DocumentIdBuilder {
//
// /**
// * Build documentId from map (extract from json)
// * documentId refers to root document (first level)
// * @param obj
// * @return
// */
// DocumentId buildId(Map<String,Object> obj);
//
// /**
// * Configure the builder with parameters
// * @param configuration
// */
// void init(Map<String, String> configuration);
// }
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentIdBuilderTypeId.java
import org.neo4j.helpers.json.document.DocumentId;
import org.neo4j.helpers.json.document.DocumentIdBuilder;
import java.util.Map;
import org.apache.commons.lang3.Validate;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* Build {@link DocumentIdTypeId}
* @author Omar Rampado
*
*/
public class DocumentIdBuilderTypeId implements DocumentIdBuilder {
/*
* (non-Javadoc)
*
* @see
* org.neo4j.helpers.json.document.DocumentIdBuilder#buildId(java.util.Map)
*/
@Override | public DocumentId buildId(Map<String,Object> obj) { |
larusba/doc2graph | neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderHasTypeArrayKeyTest.java | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
| import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.FormattedLogProvider;
import org.neo4j.logging.Log;
import java.io.File;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship; | /**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* @author Omar Rampado
*/
public class DocumentRelationBuilderHasTypeArrayKeyTest {
private static GraphDatabaseService db;
private static Log log;
private Transaction tx;
private DocumentRelationBuilderHasTypeArrayKey docrel; | // Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
//
// private String documentKey;
//
// /**
// * @return the documentKey
// */
// public String getDocumentKey() {
// return documentKey;
// }
//
// /**
// * @param documentKey
// * the documentKey to set
// */
// public void setDocumentKey(String documentKey) {
// this.documentKey = documentKey;
// }
//
// }
// Path: neo4j-json/src/test/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderHasTypeArrayKeyTest.java
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.FormattedLogProvider;
import org.neo4j.logging.Log;
import java.io.File;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
/**
* Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.helpers.json.document.impl;
/**
* @author Omar Rampado
*/
public class DocumentRelationBuilderHasTypeArrayKeyTest {
private static GraphDatabaseService db;
private static Log log;
private Transaction tx;
private DocumentRelationBuilderHasTypeArrayKey docrel; | private DocumentRelationContext context; |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/ExtensionsFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/xml/ExtensionsXmlFormat.java
// public class ExtensionsXmlFormat extends XmlFormat<List<String>> {
//
// @Override
// public void write(List<String> extensions, XmlWriter writer) {
// writer.startElement("extensionPackages");
// for (String packageName : extensions) {
// writer.putElement("package", packageName);
// }
// writer.endElement();
// }
//
// @Override
// public List<String> read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// ArrayList<String> extensions = new ArrayList<String>();
// reader.enterElement("extensionPackages");
// while (reader.hasNextElement()) {
// extensions.add(reader.getStringElement("package"));
// }
// reader.leaveElement();
// return extensions;
// }
//
// }
| import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Extensions;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.xml.ExtensionsXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class ExtensionsFormat extends FileTreeFormat<List<String>> {
private static String baseFilename = "Extension Packages";
private static String filename = baseFilename + ".xml";
@Override | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/xml/ExtensionsXmlFormat.java
// public class ExtensionsXmlFormat extends XmlFormat<List<String>> {
//
// @Override
// public void write(List<String> extensions, XmlWriter writer) {
// writer.startElement("extensionPackages");
// for (String packageName : extensions) {
// writer.putElement("package", packageName);
// }
// writer.endElement();
// }
//
// @Override
// public List<String> read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// ArrayList<String> extensions = new ArrayList<String>();
// reader.enterElement("extensionPackages");
// while (reader.hasNextElement()) {
// extensions.add(reader.getStringElement("package"));
// }
// reader.leaveElement();
// return extensions;
// }
//
// }
// Path: src/com/ganggarrison/gmdec/files/ExtensionsFormat.java
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Extensions;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.xml.ExtensionsXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class ExtensionsFormat extends FileTreeFormat<List<String>> {
private static String baseFilename = "Extension Packages";
private static String filename = baseFilename + ".xml";
@Override | public List<String> read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/ExtensionsFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/xml/ExtensionsXmlFormat.java
// public class ExtensionsXmlFormat extends XmlFormat<List<String>> {
//
// @Override
// public void write(List<String> extensions, XmlWriter writer) {
// writer.startElement("extensionPackages");
// for (String packageName : extensions) {
// writer.putElement("package", packageName);
// }
// writer.endElement();
// }
//
// @Override
// public List<String> read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// ArrayList<String> extensions = new ArrayList<String>();
// reader.enterElement("extensionPackages");
// while (reader.hasNextElement()) {
// extensions.add(reader.getStringElement("package"));
// }
// reader.leaveElement();
// return extensions;
// }
//
// }
| import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Extensions;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.xml.ExtensionsXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class ExtensionsFormat extends FileTreeFormat<List<String>> {
private static String baseFilename = "Extension Packages";
private static String filename = baseFilename + ".xml";
@Override | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/xml/ExtensionsXmlFormat.java
// public class ExtensionsXmlFormat extends XmlFormat<List<String>> {
//
// @Override
// public void write(List<String> extensions, XmlWriter writer) {
// writer.startElement("extensionPackages");
// for (String packageName : extensions) {
// writer.putElement("package", packageName);
// }
// writer.endElement();
// }
//
// @Override
// public List<String> read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// ArrayList<String> extensions = new ArrayList<String>();
// reader.enterElement("extensionPackages");
// while (reader.hasNextElement()) {
// extensions.add(reader.getStringElement("package"));
// }
// reader.leaveElement();
// return extensions;
// }
//
// }
// Path: src/com/ganggarrison/gmdec/files/ExtensionsFormat.java
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Extensions;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.xml.ExtensionsXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class ExtensionsFormat extends FileTreeFormat<List<String>> {
private static String baseFilename = "Extension Packages";
private static String filename = baseFilename + ".xml";
@Override | public List<String> read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/ExtensionsFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/xml/ExtensionsXmlFormat.java
// public class ExtensionsXmlFormat extends XmlFormat<List<String>> {
//
// @Override
// public void write(List<String> extensions, XmlWriter writer) {
// writer.startElement("extensionPackages");
// for (String packageName : extensions) {
// writer.putElement("package", packageName);
// }
// writer.endElement();
// }
//
// @Override
// public List<String> read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// ArrayList<String> extensions = new ArrayList<String>();
// reader.enterElement("extensionPackages");
// while (reader.hasNextElement()) {
// extensions.add(reader.getStringElement("package"));
// }
// reader.leaveElement();
// return extensions;
// }
//
// }
| import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Extensions;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.xml.ExtensionsXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class ExtensionsFormat extends FileTreeFormat<List<String>> {
private static String baseFilename = "Extension Packages";
private static String filename = baseFilename + ".xml";
@Override
public List<String> read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
throws IOException { | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/xml/ExtensionsXmlFormat.java
// public class ExtensionsXmlFormat extends XmlFormat<List<String>> {
//
// @Override
// public void write(List<String> extensions, XmlWriter writer) {
// writer.startElement("extensionPackages");
// for (String packageName : extensions) {
// writer.putElement("package", packageName);
// }
// writer.endElement();
// }
//
// @Override
// public List<String> read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// ArrayList<String> extensions = new ArrayList<String>();
// reader.enterElement("extensionPackages");
// while (reader.hasNextElement()) {
// extensions.add(reader.getStringElement("package"));
// }
// reader.leaveElement();
// return extensions;
// }
//
// }
// Path: src/com/ganggarrison/gmdec/files/ExtensionsFormat.java
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Extensions;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.xml.ExtensionsXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class ExtensionsFormat extends FileTreeFormat<List<String>> {
private static String baseFilename = "Extension Packages";
private static String filename = baseFilename + ".xml";
@Override
public List<String> read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
throws IOException { | return new ExtensionsXmlFormat().read(new File(path, filename), drcn); |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/ExtensionsFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/xml/ExtensionsXmlFormat.java
// public class ExtensionsXmlFormat extends XmlFormat<List<String>> {
//
// @Override
// public void write(List<String> extensions, XmlWriter writer) {
// writer.startElement("extensionPackages");
// for (String packageName : extensions) {
// writer.putElement("package", packageName);
// }
// writer.endElement();
// }
//
// @Override
// public List<String> read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// ArrayList<String> extensions = new ArrayList<String>();
// reader.enterElement("extensionPackages");
// while (reader.hasNextElement()) {
// extensions.add(reader.getStringElement("package"));
// }
// reader.leaveElement();
// return extensions;
// }
//
// }
| import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Extensions;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.xml.ExtensionsXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class ExtensionsFormat extends FileTreeFormat<List<String>> {
private static String baseFilename = "Extension Packages";
private static String filename = baseFilename + ".xml";
@Override
public List<String> read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
throws IOException {
return new ExtensionsXmlFormat().read(new File(path, filename), drcn);
}
@Override
public void addResToTree(List<String> resource, ResNode parent) {
parent.addChild("Extension Packages", ResNode.STATUS_SECONDARY, Extensions.class);
}
@Override
public ResourceTreeEntry createResourceTreeEntry(List<String> resource) { | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/xml/ExtensionsXmlFormat.java
// public class ExtensionsXmlFormat extends XmlFormat<List<String>> {
//
// @Override
// public void write(List<String> extensions, XmlWriter writer) {
// writer.startElement("extensionPackages");
// for (String packageName : extensions) {
// writer.putElement("package", packageName);
// }
// writer.endElement();
// }
//
// @Override
// public List<String> read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// ArrayList<String> extensions = new ArrayList<String>();
// reader.enterElement("extensionPackages");
// while (reader.hasNextElement()) {
// extensions.add(reader.getStringElement("package"));
// }
// reader.leaveElement();
// return extensions;
// }
//
// }
// Path: src/com/ganggarrison/gmdec/files/ExtensionsFormat.java
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Extensions;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.xml.ExtensionsXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class ExtensionsFormat extends FileTreeFormat<List<String>> {
private static String baseFilename = "Extension Packages";
private static String filename = baseFilename + ".xml";
@Override
public List<String> read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
throws IOException {
return new ExtensionsXmlFormat().read(new File(path, filename), drcn);
}
@Override
public void addResToTree(List<String> resource, ResNode parent) {
parent.addChild("Extension Packages", ResNode.STATUS_SECONDARY, Extensions.class);
}
@Override
public ResourceTreeEntry createResourceTreeEntry(List<String> resource) { | return new ResourceTreeEntry(baseFilename, baseFilename, Type.RESOURCE); |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/FontFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/FontXmlFormat.java
// public class FontXmlFormat extends XmlFormat<Font> {
//
// @Override
// public void write(Font font, XmlWriter writer) {
// writer.startElement("font");
// {
// writeIdAttribute(font, writer);
// writer.putElement("fontName", font.get(PFont.FONT_NAME));
// writer.putElement("bold", font.get(PFont.BOLD));
// writer.putElement("italic", font.get(PFont.ITALIC));
// writer.putElement("rangeMin", font.get(PFont.RANGE_MIN));
// writer.putElement("rangeMax", font.get(PFont.RANGE_MAX));
// writer.putElement("size", font.get(PFont.SIZE));
// if (GmkSplitter.targetVersion >= 810) {
// writer.putElement("charset", font.get(PFont.CHARSET));
// writer.putElement("antialias", font.get(PFont.ANTIALIAS));
// }
// }
// writer.endElement();
// }
//
// @Override
// public Font read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Font font = new Font();
// reader.enterElement("font");
// {
// readIdAttribute(font, reader);
// font.put(PFont.FONT_NAME, reader.getStringElement("fontName"));
// font.put(PFont.BOLD, reader.getBoolElement("bold"));
// font.put(PFont.ITALIC, reader.getBoolElement("italic"));
// font.put(PFont.RANGE_MIN, reader.getIntElement("rangeMin"));
// font.put(PFont.RANGE_MAX, reader.getIntElement("rangeMax"));
// font.put(PFont.SIZE, reader.getIntElement("size"));
// if (reader.hasNextElement()) {
// font.put(PFont.CHARSET, reader.getIntElement("charset"));
// font.put(PFont.ANTIALIAS, reader.getIntElement("antialias"));
// if (GmkSplitter.targetVersion < 810) {
// GmkSplitter.issueVersionWarning("Font/Charset and Antialias");
// }
// }
// }
// reader.leaveElement();
// return font;
// }
// }
| import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Font;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.FontXmlFormat;
| /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class FontFormat extends ResourceFormat<Font> {
@Override
| // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/FontXmlFormat.java
// public class FontXmlFormat extends XmlFormat<Font> {
//
// @Override
// public void write(Font font, XmlWriter writer) {
// writer.startElement("font");
// {
// writeIdAttribute(font, writer);
// writer.putElement("fontName", font.get(PFont.FONT_NAME));
// writer.putElement("bold", font.get(PFont.BOLD));
// writer.putElement("italic", font.get(PFont.ITALIC));
// writer.putElement("rangeMin", font.get(PFont.RANGE_MIN));
// writer.putElement("rangeMax", font.get(PFont.RANGE_MAX));
// writer.putElement("size", font.get(PFont.SIZE));
// if (GmkSplitter.targetVersion >= 810) {
// writer.putElement("charset", font.get(PFont.CHARSET));
// writer.putElement("antialias", font.get(PFont.ANTIALIAS));
// }
// }
// writer.endElement();
// }
//
// @Override
// public Font read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Font font = new Font();
// reader.enterElement("font");
// {
// readIdAttribute(font, reader);
// font.put(PFont.FONT_NAME, reader.getStringElement("fontName"));
// font.put(PFont.BOLD, reader.getBoolElement("bold"));
// font.put(PFont.ITALIC, reader.getBoolElement("italic"));
// font.put(PFont.RANGE_MIN, reader.getIntElement("rangeMin"));
// font.put(PFont.RANGE_MAX, reader.getIntElement("rangeMax"));
// font.put(PFont.SIZE, reader.getIntElement("size"));
// if (reader.hasNextElement()) {
// font.put(PFont.CHARSET, reader.getIntElement("charset"));
// font.put(PFont.ANTIALIAS, reader.getIntElement("antialias"));
// if (GmkSplitter.targetVersion < 810) {
// GmkSplitter.issueVersionWarning("Font/Charset and Antialias");
// }
// }
// }
// reader.leaveElement();
// return font;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/FontFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Font;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.FontXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class FontFormat extends ResourceFormat<Font> {
@Override
| public Font read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException {
|
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/FontFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/FontXmlFormat.java
// public class FontXmlFormat extends XmlFormat<Font> {
//
// @Override
// public void write(Font font, XmlWriter writer) {
// writer.startElement("font");
// {
// writeIdAttribute(font, writer);
// writer.putElement("fontName", font.get(PFont.FONT_NAME));
// writer.putElement("bold", font.get(PFont.BOLD));
// writer.putElement("italic", font.get(PFont.ITALIC));
// writer.putElement("rangeMin", font.get(PFont.RANGE_MIN));
// writer.putElement("rangeMax", font.get(PFont.RANGE_MAX));
// writer.putElement("size", font.get(PFont.SIZE));
// if (GmkSplitter.targetVersion >= 810) {
// writer.putElement("charset", font.get(PFont.CHARSET));
// writer.putElement("antialias", font.get(PFont.ANTIALIAS));
// }
// }
// writer.endElement();
// }
//
// @Override
// public Font read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Font font = new Font();
// reader.enterElement("font");
// {
// readIdAttribute(font, reader);
// font.put(PFont.FONT_NAME, reader.getStringElement("fontName"));
// font.put(PFont.BOLD, reader.getBoolElement("bold"));
// font.put(PFont.ITALIC, reader.getBoolElement("italic"));
// font.put(PFont.RANGE_MIN, reader.getIntElement("rangeMin"));
// font.put(PFont.RANGE_MAX, reader.getIntElement("rangeMax"));
// font.put(PFont.SIZE, reader.getIntElement("size"));
// if (reader.hasNextElement()) {
// font.put(PFont.CHARSET, reader.getIntElement("charset"));
// font.put(PFont.ANTIALIAS, reader.getIntElement("antialias"));
// if (GmkSplitter.targetVersion < 810) {
// GmkSplitter.issueVersionWarning("Font/Charset and Antialias");
// }
// }
// }
// reader.leaveElement();
// return font;
// }
// }
| import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Font;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.FontXmlFormat;
| /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class FontFormat extends ResourceFormat<Font> {
@Override
| // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/FontXmlFormat.java
// public class FontXmlFormat extends XmlFormat<Font> {
//
// @Override
// public void write(Font font, XmlWriter writer) {
// writer.startElement("font");
// {
// writeIdAttribute(font, writer);
// writer.putElement("fontName", font.get(PFont.FONT_NAME));
// writer.putElement("bold", font.get(PFont.BOLD));
// writer.putElement("italic", font.get(PFont.ITALIC));
// writer.putElement("rangeMin", font.get(PFont.RANGE_MIN));
// writer.putElement("rangeMax", font.get(PFont.RANGE_MAX));
// writer.putElement("size", font.get(PFont.SIZE));
// if (GmkSplitter.targetVersion >= 810) {
// writer.putElement("charset", font.get(PFont.CHARSET));
// writer.putElement("antialias", font.get(PFont.ANTIALIAS));
// }
// }
// writer.endElement();
// }
//
// @Override
// public Font read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Font font = new Font();
// reader.enterElement("font");
// {
// readIdAttribute(font, reader);
// font.put(PFont.FONT_NAME, reader.getStringElement("fontName"));
// font.put(PFont.BOLD, reader.getBoolElement("bold"));
// font.put(PFont.ITALIC, reader.getBoolElement("italic"));
// font.put(PFont.RANGE_MIN, reader.getIntElement("rangeMin"));
// font.put(PFont.RANGE_MAX, reader.getIntElement("rangeMax"));
// font.put(PFont.SIZE, reader.getIntElement("size"));
// if (reader.hasNextElement()) {
// font.put(PFont.CHARSET, reader.getIntElement("charset"));
// font.put(PFont.ANTIALIAS, reader.getIntElement("antialias"));
// if (GmkSplitter.targetVersion < 810) {
// GmkSplitter.issueVersionWarning("Font/Charset and Antialias");
// }
// }
// }
// reader.leaveElement();
// return font;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/FontFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Font;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.FontXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class FontFormat extends ResourceFormat<Font> {
@Override
| public Font read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException {
|
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/FontFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/FontXmlFormat.java
// public class FontXmlFormat extends XmlFormat<Font> {
//
// @Override
// public void write(Font font, XmlWriter writer) {
// writer.startElement("font");
// {
// writeIdAttribute(font, writer);
// writer.putElement("fontName", font.get(PFont.FONT_NAME));
// writer.putElement("bold", font.get(PFont.BOLD));
// writer.putElement("italic", font.get(PFont.ITALIC));
// writer.putElement("rangeMin", font.get(PFont.RANGE_MIN));
// writer.putElement("rangeMax", font.get(PFont.RANGE_MAX));
// writer.putElement("size", font.get(PFont.SIZE));
// if (GmkSplitter.targetVersion >= 810) {
// writer.putElement("charset", font.get(PFont.CHARSET));
// writer.putElement("antialias", font.get(PFont.ANTIALIAS));
// }
// }
// writer.endElement();
// }
//
// @Override
// public Font read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Font font = new Font();
// reader.enterElement("font");
// {
// readIdAttribute(font, reader);
// font.put(PFont.FONT_NAME, reader.getStringElement("fontName"));
// font.put(PFont.BOLD, reader.getBoolElement("bold"));
// font.put(PFont.ITALIC, reader.getBoolElement("italic"));
// font.put(PFont.RANGE_MIN, reader.getIntElement("rangeMin"));
// font.put(PFont.RANGE_MAX, reader.getIntElement("rangeMax"));
// font.put(PFont.SIZE, reader.getIntElement("size"));
// if (reader.hasNextElement()) {
// font.put(PFont.CHARSET, reader.getIntElement("charset"));
// font.put(PFont.ANTIALIAS, reader.getIntElement("antialias"));
// if (GmkSplitter.targetVersion < 810) {
// GmkSplitter.issueVersionWarning("Font/Charset and Antialias");
// }
// }
// }
// reader.leaveElement();
// return font;
// }
// }
| import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Font;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.FontXmlFormat;
| /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class FontFormat extends ResourceFormat<Font> {
@Override
public Font read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException {
| // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/FontXmlFormat.java
// public class FontXmlFormat extends XmlFormat<Font> {
//
// @Override
// public void write(Font font, XmlWriter writer) {
// writer.startElement("font");
// {
// writeIdAttribute(font, writer);
// writer.putElement("fontName", font.get(PFont.FONT_NAME));
// writer.putElement("bold", font.get(PFont.BOLD));
// writer.putElement("italic", font.get(PFont.ITALIC));
// writer.putElement("rangeMin", font.get(PFont.RANGE_MIN));
// writer.putElement("rangeMax", font.get(PFont.RANGE_MAX));
// writer.putElement("size", font.get(PFont.SIZE));
// if (GmkSplitter.targetVersion >= 810) {
// writer.putElement("charset", font.get(PFont.CHARSET));
// writer.putElement("antialias", font.get(PFont.ANTIALIAS));
// }
// }
// writer.endElement();
// }
//
// @Override
// public Font read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Font font = new Font();
// reader.enterElement("font");
// {
// readIdAttribute(font, reader);
// font.put(PFont.FONT_NAME, reader.getStringElement("fontName"));
// font.put(PFont.BOLD, reader.getBoolElement("bold"));
// font.put(PFont.ITALIC, reader.getBoolElement("italic"));
// font.put(PFont.RANGE_MIN, reader.getIntElement("rangeMin"));
// font.put(PFont.RANGE_MAX, reader.getIntElement("rangeMax"));
// font.put(PFont.SIZE, reader.getIntElement("size"));
// if (reader.hasNextElement()) {
// font.put(PFont.CHARSET, reader.getIntElement("charset"));
// font.put(PFont.ANTIALIAS, reader.getIntElement("antialias"));
// if (GmkSplitter.targetVersion < 810) {
// GmkSplitter.issueVersionWarning("Font/Charset and Antialias");
// }
// }
// }
// reader.leaveElement();
// return font;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/FontFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Font;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.FontXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class FontFormat extends ResourceFormat<Font> {
@Override
public Font read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException {
| Font font = new FontXmlFormat().read(getXmlFile(path, entry), drcn);
|
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/ResourceFormat.java | // Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/dupes/OrderPreservingDupeRemoval.java
// public class OrderPreservingDupeRemoval {
// public static <Item> void perform(ItemAccessor<Item> accessor) {
// int changed = 0;
//
// List<Item> items = accessor.getItems();
// List<Item> invalidIdItems = new ArrayList<Item>();
// TreeMultiMap<Integer, Item> itemsById = new TreeMultiMap<Integer, Item>();
//
// for (Item item : items) {
// Integer id = accessor.getId(item);
// if (id == null) {
// invalidIdItems.add(item);
// } else {
// itemsById.add(id, item);
// }
// }
//
// int nextFreeItemId = accessor.getFirstValidId();
// for (Map.Entry<Integer, List<Item>> entry : itemsById) {
// for (Item item : entry.getValue()) {
// int id = entry.getKey();
// if (id >= nextFreeItemId) {
// nextFreeItemId = id + 1;
// } else {
// accessor.setId(item, nextFreeItemId++);
// changed++;
// }
// }
// }
//
// for (Item item : invalidIdItems) {
// accessor.setId(item, nextFreeItemId++);
// }
//
// accessor.setMaxId(nextFreeItemId - 1);
//
// if (changed > 0) {
// System.err.println("INFO: " + changed + " duplicate " + accessor.getItemName() + " IDs have been changed.");
// }
// if (invalidIdItems.size() > 0 && accessor.informAboutNewIds()) {
// System.err.println("INFO: " + invalidIdItems.size() + " new " + accessor.getItemName()
// + " IDs have been assigned.");
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/dupes/ResourceAccessor.java
// public class ResourceAccessor<T extends InstantiableResource<T, ?>> implements ItemAccessor<T> {
// private List<T> resources;
//
// public ResourceAccessor(List<T> resources) {
// this.resources = resources;
// }
//
// @Override
// public List<T> getItems() {
// return Collections.unmodifiableList(resources);
// }
//
// @Override
// public Integer getId(T item) {
// int id = item.getId();
// return id >= 0 ? id : null;
// }
//
// @Override
// public void setId(T item, int id) {
// item.setId(id);
// }
//
// @Override
// public int getFirstValidId() {
// return 0;
// }
//
// @Override
// public void setMaxId(int id) {
// // The resource lists calculate that automatically.
// }
//
// @Override
// public String getItemName() {
// if (resources.isEmpty()) {
// return "Resource";
// } else {
// return resources.get(0).getClass().getSimpleName();
// }
// }
//
// @Override
// public boolean informAboutNewIds() {
// if (resources.isEmpty()) {
// return false;
// } else {
// if (resources.get(0) instanceof GmObject) {
// return GmkSplitter.preserveIds == IdPreservation.ALL || GmkSplitter.preserveIds == IdPreservation.OBJECTS;
// } else {
// return GmkSplitter.preserveIds == IdPreservation.ALL;
// }
// }
// }
// }
| import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.file.ResourceList;
import org.lateralgm.resources.InstantiableResource;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.dupes.OrderPreservingDupeRemoval;
import com.ganggarrison.gmdec.dupes.ResourceAccessor; | package com.ganggarrison.gmdec.files;
public abstract class ResourceFormat<T extends InstantiableResource<T, ?>> extends FileTreeFormat<T> {
@Override
public void addResToTree(T resource, ResNode parent) {
ResNode child = new ResNode(resource.getName(),
ResNode.STATUS_SECONDARY, resource.getClass(), resource.reference);
parent.add(child);
}
@Override
public void addAllResourcesToGmFile(List<T> resources, GmFile gmf) {
if (resources.isEmpty()) {
return;
}
@SuppressWarnings("unchecked")
Class<T> kind = (Class<T>) resources.get(0).getClass();
checkDuplicateNames(resources, kind);
// Take care of dupes and unassigned IDs | // Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/dupes/OrderPreservingDupeRemoval.java
// public class OrderPreservingDupeRemoval {
// public static <Item> void perform(ItemAccessor<Item> accessor) {
// int changed = 0;
//
// List<Item> items = accessor.getItems();
// List<Item> invalidIdItems = new ArrayList<Item>();
// TreeMultiMap<Integer, Item> itemsById = new TreeMultiMap<Integer, Item>();
//
// for (Item item : items) {
// Integer id = accessor.getId(item);
// if (id == null) {
// invalidIdItems.add(item);
// } else {
// itemsById.add(id, item);
// }
// }
//
// int nextFreeItemId = accessor.getFirstValidId();
// for (Map.Entry<Integer, List<Item>> entry : itemsById) {
// for (Item item : entry.getValue()) {
// int id = entry.getKey();
// if (id >= nextFreeItemId) {
// nextFreeItemId = id + 1;
// } else {
// accessor.setId(item, nextFreeItemId++);
// changed++;
// }
// }
// }
//
// for (Item item : invalidIdItems) {
// accessor.setId(item, nextFreeItemId++);
// }
//
// accessor.setMaxId(nextFreeItemId - 1);
//
// if (changed > 0) {
// System.err.println("INFO: " + changed + " duplicate " + accessor.getItemName() + " IDs have been changed.");
// }
// if (invalidIdItems.size() > 0 && accessor.informAboutNewIds()) {
// System.err.println("INFO: " + invalidIdItems.size() + " new " + accessor.getItemName()
// + " IDs have been assigned.");
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/dupes/ResourceAccessor.java
// public class ResourceAccessor<T extends InstantiableResource<T, ?>> implements ItemAccessor<T> {
// private List<T> resources;
//
// public ResourceAccessor(List<T> resources) {
// this.resources = resources;
// }
//
// @Override
// public List<T> getItems() {
// return Collections.unmodifiableList(resources);
// }
//
// @Override
// public Integer getId(T item) {
// int id = item.getId();
// return id >= 0 ? id : null;
// }
//
// @Override
// public void setId(T item, int id) {
// item.setId(id);
// }
//
// @Override
// public int getFirstValidId() {
// return 0;
// }
//
// @Override
// public void setMaxId(int id) {
// // The resource lists calculate that automatically.
// }
//
// @Override
// public String getItemName() {
// if (resources.isEmpty()) {
// return "Resource";
// } else {
// return resources.get(0).getClass().getSimpleName();
// }
// }
//
// @Override
// public boolean informAboutNewIds() {
// if (resources.isEmpty()) {
// return false;
// } else {
// if (resources.get(0) instanceof GmObject) {
// return GmkSplitter.preserveIds == IdPreservation.ALL || GmkSplitter.preserveIds == IdPreservation.OBJECTS;
// } else {
// return GmkSplitter.preserveIds == IdPreservation.ALL;
// }
// }
// }
// }
// Path: src/com/ganggarrison/gmdec/files/ResourceFormat.java
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.file.ResourceList;
import org.lateralgm.resources.InstantiableResource;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.dupes.OrderPreservingDupeRemoval;
import com.ganggarrison.gmdec.dupes.ResourceAccessor;
package com.ganggarrison.gmdec.files;
public abstract class ResourceFormat<T extends InstantiableResource<T, ?>> extends FileTreeFormat<T> {
@Override
public void addResToTree(T resource, ResNode parent) {
ResNode child = new ResNode(resource.getName(),
ResNode.STATUS_SECONDARY, resource.getClass(), resource.reference);
parent.add(child);
}
@Override
public void addAllResourcesToGmFile(List<T> resources, GmFile gmf) {
if (resources.isEmpty()) {
return;
}
@SuppressWarnings("unchecked")
Class<T> kind = (Class<T>) resources.get(0).getClass();
checkDuplicateNames(resources, kind);
// Take care of dupes and unassigned IDs | ResourceAccessor<T> accessor = new ResourceAccessor<T>(resources); |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/ResourceFormat.java | // Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/dupes/OrderPreservingDupeRemoval.java
// public class OrderPreservingDupeRemoval {
// public static <Item> void perform(ItemAccessor<Item> accessor) {
// int changed = 0;
//
// List<Item> items = accessor.getItems();
// List<Item> invalidIdItems = new ArrayList<Item>();
// TreeMultiMap<Integer, Item> itemsById = new TreeMultiMap<Integer, Item>();
//
// for (Item item : items) {
// Integer id = accessor.getId(item);
// if (id == null) {
// invalidIdItems.add(item);
// } else {
// itemsById.add(id, item);
// }
// }
//
// int nextFreeItemId = accessor.getFirstValidId();
// for (Map.Entry<Integer, List<Item>> entry : itemsById) {
// for (Item item : entry.getValue()) {
// int id = entry.getKey();
// if (id >= nextFreeItemId) {
// nextFreeItemId = id + 1;
// } else {
// accessor.setId(item, nextFreeItemId++);
// changed++;
// }
// }
// }
//
// for (Item item : invalidIdItems) {
// accessor.setId(item, nextFreeItemId++);
// }
//
// accessor.setMaxId(nextFreeItemId - 1);
//
// if (changed > 0) {
// System.err.println("INFO: " + changed + " duplicate " + accessor.getItemName() + " IDs have been changed.");
// }
// if (invalidIdItems.size() > 0 && accessor.informAboutNewIds()) {
// System.err.println("INFO: " + invalidIdItems.size() + " new " + accessor.getItemName()
// + " IDs have been assigned.");
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/dupes/ResourceAccessor.java
// public class ResourceAccessor<T extends InstantiableResource<T, ?>> implements ItemAccessor<T> {
// private List<T> resources;
//
// public ResourceAccessor(List<T> resources) {
// this.resources = resources;
// }
//
// @Override
// public List<T> getItems() {
// return Collections.unmodifiableList(resources);
// }
//
// @Override
// public Integer getId(T item) {
// int id = item.getId();
// return id >= 0 ? id : null;
// }
//
// @Override
// public void setId(T item, int id) {
// item.setId(id);
// }
//
// @Override
// public int getFirstValidId() {
// return 0;
// }
//
// @Override
// public void setMaxId(int id) {
// // The resource lists calculate that automatically.
// }
//
// @Override
// public String getItemName() {
// if (resources.isEmpty()) {
// return "Resource";
// } else {
// return resources.get(0).getClass().getSimpleName();
// }
// }
//
// @Override
// public boolean informAboutNewIds() {
// if (resources.isEmpty()) {
// return false;
// } else {
// if (resources.get(0) instanceof GmObject) {
// return GmkSplitter.preserveIds == IdPreservation.ALL || GmkSplitter.preserveIds == IdPreservation.OBJECTS;
// } else {
// return GmkSplitter.preserveIds == IdPreservation.ALL;
// }
// }
// }
// }
| import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.file.ResourceList;
import org.lateralgm.resources.InstantiableResource;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.dupes.OrderPreservingDupeRemoval;
import com.ganggarrison.gmdec.dupes.ResourceAccessor; | package com.ganggarrison.gmdec.files;
public abstract class ResourceFormat<T extends InstantiableResource<T, ?>> extends FileTreeFormat<T> {
@Override
public void addResToTree(T resource, ResNode parent) {
ResNode child = new ResNode(resource.getName(),
ResNode.STATUS_SECONDARY, resource.getClass(), resource.reference);
parent.add(child);
}
@Override
public void addAllResourcesToGmFile(List<T> resources, GmFile gmf) {
if (resources.isEmpty()) {
return;
}
@SuppressWarnings("unchecked")
Class<T> kind = (Class<T>) resources.get(0).getClass();
checkDuplicateNames(resources, kind);
// Take care of dupes and unassigned IDs
ResourceAccessor<T> accessor = new ResourceAccessor<T>(resources); | // Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public static enum Type {
// RESOURCE, GROUP
// }
//
// Path: src/com/ganggarrison/gmdec/dupes/OrderPreservingDupeRemoval.java
// public class OrderPreservingDupeRemoval {
// public static <Item> void perform(ItemAccessor<Item> accessor) {
// int changed = 0;
//
// List<Item> items = accessor.getItems();
// List<Item> invalidIdItems = new ArrayList<Item>();
// TreeMultiMap<Integer, Item> itemsById = new TreeMultiMap<Integer, Item>();
//
// for (Item item : items) {
// Integer id = accessor.getId(item);
// if (id == null) {
// invalidIdItems.add(item);
// } else {
// itemsById.add(id, item);
// }
// }
//
// int nextFreeItemId = accessor.getFirstValidId();
// for (Map.Entry<Integer, List<Item>> entry : itemsById) {
// for (Item item : entry.getValue()) {
// int id = entry.getKey();
// if (id >= nextFreeItemId) {
// nextFreeItemId = id + 1;
// } else {
// accessor.setId(item, nextFreeItemId++);
// changed++;
// }
// }
// }
//
// for (Item item : invalidIdItems) {
// accessor.setId(item, nextFreeItemId++);
// }
//
// accessor.setMaxId(nextFreeItemId - 1);
//
// if (changed > 0) {
// System.err.println("INFO: " + changed + " duplicate " + accessor.getItemName() + " IDs have been changed.");
// }
// if (invalidIdItems.size() > 0 && accessor.informAboutNewIds()) {
// System.err.println("INFO: " + invalidIdItems.size() + " new " + accessor.getItemName()
// + " IDs have been assigned.");
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/dupes/ResourceAccessor.java
// public class ResourceAccessor<T extends InstantiableResource<T, ?>> implements ItemAccessor<T> {
// private List<T> resources;
//
// public ResourceAccessor(List<T> resources) {
// this.resources = resources;
// }
//
// @Override
// public List<T> getItems() {
// return Collections.unmodifiableList(resources);
// }
//
// @Override
// public Integer getId(T item) {
// int id = item.getId();
// return id >= 0 ? id : null;
// }
//
// @Override
// public void setId(T item, int id) {
// item.setId(id);
// }
//
// @Override
// public int getFirstValidId() {
// return 0;
// }
//
// @Override
// public void setMaxId(int id) {
// // The resource lists calculate that automatically.
// }
//
// @Override
// public String getItemName() {
// if (resources.isEmpty()) {
// return "Resource";
// } else {
// return resources.get(0).getClass().getSimpleName();
// }
// }
//
// @Override
// public boolean informAboutNewIds() {
// if (resources.isEmpty()) {
// return false;
// } else {
// if (resources.get(0) instanceof GmObject) {
// return GmkSplitter.preserveIds == IdPreservation.ALL || GmkSplitter.preserveIds == IdPreservation.OBJECTS;
// } else {
// return GmkSplitter.preserveIds == IdPreservation.ALL;
// }
// }
// }
// }
// Path: src/com/ganggarrison/gmdec/files/ResourceFormat.java
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.file.ResourceList;
import org.lateralgm.resources.InstantiableResource;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.ResourceTreeEntry.Type;
import com.ganggarrison.gmdec.dupes.OrderPreservingDupeRemoval;
import com.ganggarrison.gmdec.dupes.ResourceAccessor;
package com.ganggarrison.gmdec.files;
public abstract class ResourceFormat<T extends InstantiableResource<T, ?>> extends FileTreeFormat<T> {
@Override
public void addResToTree(T resource, ResNode parent) {
ResNode child = new ResNode(resource.getName(),
ResNode.STATUS_SECONDARY, resource.getClass(), resource.reference);
parent.add(child);
}
@Override
public void addAllResourcesToGmFile(List<T> resources, GmFile gmf) {
if (resources.isEmpty()) {
return;
}
@SuppressWarnings("unchecked")
Class<T> kind = (Class<T>) resources.get(0).getClass();
checkDuplicateNames(resources, kind);
// Take care of dupes and unassigned IDs
ResourceAccessor<T> accessor = new ResourceAccessor<T>(resources); | OrderPreservingDupeRemoval.perform(accessor); |
Medo42/Gmk-Splitter | src/com/ganggarrison/easyxml/XmlWriter.java | // Path: src/com/ganggarrison/gmdec/FileTools.java
// public class FileTools {
// public static void writeFile(File file, String content) throws IOException {
// writeFile(file, content.getBytes("UTF-8"));
// }
//
// public static void writeFile(File file, byte[] content) throws IOException {
// // Never overwrite
// if (file.exists()) {
// throw new IOException("File " + file + " already exists.");
// }
//
// FileOutputStream fos = null;
// DataOutputStream dos = null;
//
// try {
// fos = new FileOutputStream(file);
// dos = new DataOutputStream(fos);
// dos.write(content);
// } finally {
// tryToClose(fos);
// tryToClose(dos);
// }
// }
//
// /**
// * Modify the given String so that it can be used as part of a filename
// * without causing problems from illegal/special characters.
// *
// * The result should be similar to the input, but isn't necessarily
// * reversible. The implementation might change in the future, so don't rely
// * on the output staying the same.
// */
// public static String replaceBadChars(String name) {
// if (name == null || name.trim().isEmpty())
// return "_";
// name = name.trim();
// for (String badChar : badChars) {
// name = name.replace(badChar, "_");
// }
// return name;
// }
//
// public static boolean isGoodFilename(String name) {
// if (name == null || name.trim().isEmpty())
// return false;
// if (!name.trim().equals(name)) {
// return false;
// }
// for (String s : badChars) {
// if (name.contains(s))
// return false;
// }
// return true;
// }
//
// private static final String[] badChars = new String[] { "/", "\\", ":", "*", "?", "\"", "<", ">", "|", ".", "\0" };
//
// public static String readFileAsString(File file) throws IOException {
// return new String(readWholeFileBytes(file), "UTF-8");
// }
//
// public static byte[] readWholeFileBytes(File file) throws IOException {
// FileInputStream fis = null;
// DataInputStream dis = null;
// try {
// fis = new FileInputStream(file);
// dis = new DataInputStream(fis);
// byte[] buffer = new byte[(int) file.length()];
// dis.readFully(buffer);
//
// return buffer;
// } finally {
// tryToClose(fis);
// tryToClose(dis);
// }
// }
//
// private static void tryToClose(Closeable stream) {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// }
// }
// }
// }
| import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Stack;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Comment;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import com.ganggarrison.gmdec.FileTools; | String lineSep = System.getProperty("line.separator");
System.setProperty("line.separator", "\n");
try {
Transformer trans = createTransformer();
writeXml(trans, file);
} catch (TransformerConfigurationException e) {
throw new AssertionError(e);
} catch (TransformerException e) {
throw new IOException(e);
} finally {
System.setProperty("line.separator", lineSep);
}
}
private Transformer createTransformer() throws TransformerConfigurationException {
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
trans.setOutputProperty(OutputKeys.STANDALONE, "no");
trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
return trans;
}
private void writeXml(Transformer trans, File file) throws TransformerException, IOException {
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(domDocument);
trans.transform(source, result); | // Path: src/com/ganggarrison/gmdec/FileTools.java
// public class FileTools {
// public static void writeFile(File file, String content) throws IOException {
// writeFile(file, content.getBytes("UTF-8"));
// }
//
// public static void writeFile(File file, byte[] content) throws IOException {
// // Never overwrite
// if (file.exists()) {
// throw new IOException("File " + file + " already exists.");
// }
//
// FileOutputStream fos = null;
// DataOutputStream dos = null;
//
// try {
// fos = new FileOutputStream(file);
// dos = new DataOutputStream(fos);
// dos.write(content);
// } finally {
// tryToClose(fos);
// tryToClose(dos);
// }
// }
//
// /**
// * Modify the given String so that it can be used as part of a filename
// * without causing problems from illegal/special characters.
// *
// * The result should be similar to the input, but isn't necessarily
// * reversible. The implementation might change in the future, so don't rely
// * on the output staying the same.
// */
// public static String replaceBadChars(String name) {
// if (name == null || name.trim().isEmpty())
// return "_";
// name = name.trim();
// for (String badChar : badChars) {
// name = name.replace(badChar, "_");
// }
// return name;
// }
//
// public static boolean isGoodFilename(String name) {
// if (name == null || name.trim().isEmpty())
// return false;
// if (!name.trim().equals(name)) {
// return false;
// }
// for (String s : badChars) {
// if (name.contains(s))
// return false;
// }
// return true;
// }
//
// private static final String[] badChars = new String[] { "/", "\\", ":", "*", "?", "\"", "<", ">", "|", ".", "\0" };
//
// public static String readFileAsString(File file) throws IOException {
// return new String(readWholeFileBytes(file), "UTF-8");
// }
//
// public static byte[] readWholeFileBytes(File file) throws IOException {
// FileInputStream fis = null;
// DataInputStream dis = null;
// try {
// fis = new FileInputStream(file);
// dis = new DataInputStream(fis);
// byte[] buffer = new byte[(int) file.length()];
// dis.readFully(buffer);
//
// return buffer;
// } finally {
// tryToClose(fis);
// tryToClose(dis);
// }
// }
//
// private static void tryToClose(Closeable stream) {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// }
// }
// }
// }
// Path: src/com/ganggarrison/easyxml/XmlWriter.java
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Stack;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Comment;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import com.ganggarrison.gmdec.FileTools;
String lineSep = System.getProperty("line.separator");
System.setProperty("line.separator", "\n");
try {
Transformer trans = createTransformer();
writeXml(trans, file);
} catch (TransformerConfigurationException e) {
throw new AssertionError(e);
} catch (TransformerException e) {
throw new IOException(e);
} finally {
System.setProperty("line.separator", lineSep);
}
}
private Transformer createTransformer() throws TransformerConfigurationException {
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
trans.setOutputProperty(OutputKeys.STANDALONE, "no");
trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
return trans;
}
private void writeXml(Transformer trans, File file) throws TransformerException, IOException {
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(domDocument);
trans.transform(source, result); | FileTools.writeFile(file, sw.toString()); |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/BackgroundFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/BackgroundXmlFormat.java
// public class BackgroundXmlFormat extends XmlFormat<Background> {
// @Override
// public void write(Background background, XmlWriter writer) {
// writer.startElement("background");
// {
// writeIdAttribute(background, writer);
// boolean useAsTileset = background.get(PBackground.USE_AS_TILESET);
// writer.putElement("useAsTileset", useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// writer.startElement("tiles");
// int width = background.get(PBackground.TILE_WIDTH);
// int height = background.get(PBackground.TILE_HEIGHT);
// writeDimension(writer, "size", new Dimension(width, height));
//
// int offsetX = background.get(PBackground.H_OFFSET);
// int offsetY = background.get(PBackground.V_OFFSET);
// writePoint(writer, "offset", new Point(offsetX, offsetY));
//
// int sepX = background.get(PBackground.H_SEP);
// int sepY = background.get(PBackground.V_SEP);
// writePoint(writer, "separation", new Point(sepX, sepY));
// writer.endElement();
// }
// writer.putElement("preload", background.get(PBackground.PRELOAD));
// writer.putElement("smoothEdges", background.get(PBackground.SMOOTH_EDGES));
// writer.putElement("transparent", background.get(PBackground.TRANSPARENT));
// }
// writer.endElement();
// }
//
// @Override
// public Background read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Background background = new Background();
// reader.enterElement("background");
// {
// readIdAttribute(background, reader);
// boolean useAsTileset = reader.getBoolElement("useAsTileset");
// background.put(PBackground.USE_AS_TILESET, useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// reader.enterElement("tiles");
// Dimension size = readDimension(reader, "size");
// background.put(PBackground.TILE_WIDTH, size.width);
// background.put(PBackground.TILE_HEIGHT, size.height);
//
// Point offset = readPoint(reader, "offset");
// background.put(PBackground.H_OFFSET, offset.x);
// background.put(PBackground.V_OFFSET, offset.y);
//
// Point separation = readPoint(reader, "separation");
// background.put(PBackground.H_SEP, separation.x);
// background.put(PBackground.V_SEP, separation.y);
// reader.leaveElement();
// }
// background.put(PBackground.PRELOAD, reader.getBoolElement("preload"));
// background.put(PBackground.SMOOTH_EDGES, reader.getBoolElement("smoothEdges"));
// background.put(PBackground.TRANSPARENT, reader.getBoolElement("transparent"));
// }
// reader.leaveElement();
// return background;
// }
// }
| import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Background;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.BackgroundXmlFormat;
| /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class BackgroundFormat extends ResourceFormat<Background> {
@Override
| // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/BackgroundXmlFormat.java
// public class BackgroundXmlFormat extends XmlFormat<Background> {
// @Override
// public void write(Background background, XmlWriter writer) {
// writer.startElement("background");
// {
// writeIdAttribute(background, writer);
// boolean useAsTileset = background.get(PBackground.USE_AS_TILESET);
// writer.putElement("useAsTileset", useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// writer.startElement("tiles");
// int width = background.get(PBackground.TILE_WIDTH);
// int height = background.get(PBackground.TILE_HEIGHT);
// writeDimension(writer, "size", new Dimension(width, height));
//
// int offsetX = background.get(PBackground.H_OFFSET);
// int offsetY = background.get(PBackground.V_OFFSET);
// writePoint(writer, "offset", new Point(offsetX, offsetY));
//
// int sepX = background.get(PBackground.H_SEP);
// int sepY = background.get(PBackground.V_SEP);
// writePoint(writer, "separation", new Point(sepX, sepY));
// writer.endElement();
// }
// writer.putElement("preload", background.get(PBackground.PRELOAD));
// writer.putElement("smoothEdges", background.get(PBackground.SMOOTH_EDGES));
// writer.putElement("transparent", background.get(PBackground.TRANSPARENT));
// }
// writer.endElement();
// }
//
// @Override
// public Background read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Background background = new Background();
// reader.enterElement("background");
// {
// readIdAttribute(background, reader);
// boolean useAsTileset = reader.getBoolElement("useAsTileset");
// background.put(PBackground.USE_AS_TILESET, useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// reader.enterElement("tiles");
// Dimension size = readDimension(reader, "size");
// background.put(PBackground.TILE_WIDTH, size.width);
// background.put(PBackground.TILE_HEIGHT, size.height);
//
// Point offset = readPoint(reader, "offset");
// background.put(PBackground.H_OFFSET, offset.x);
// background.put(PBackground.V_OFFSET, offset.y);
//
// Point separation = readPoint(reader, "separation");
// background.put(PBackground.H_SEP, separation.x);
// background.put(PBackground.V_SEP, separation.y);
// reader.leaveElement();
// }
// background.put(PBackground.PRELOAD, reader.getBoolElement("preload"));
// background.put(PBackground.SMOOTH_EDGES, reader.getBoolElement("smoothEdges"));
// background.put(PBackground.TRANSPARENT, reader.getBoolElement("transparent"));
// }
// reader.leaveElement();
// return background;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/BackgroundFormat.java
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Background;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.BackgroundXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class BackgroundFormat extends ResourceFormat<Background> {
@Override
| public Background read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
|
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/BackgroundFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/BackgroundXmlFormat.java
// public class BackgroundXmlFormat extends XmlFormat<Background> {
// @Override
// public void write(Background background, XmlWriter writer) {
// writer.startElement("background");
// {
// writeIdAttribute(background, writer);
// boolean useAsTileset = background.get(PBackground.USE_AS_TILESET);
// writer.putElement("useAsTileset", useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// writer.startElement("tiles");
// int width = background.get(PBackground.TILE_WIDTH);
// int height = background.get(PBackground.TILE_HEIGHT);
// writeDimension(writer, "size", new Dimension(width, height));
//
// int offsetX = background.get(PBackground.H_OFFSET);
// int offsetY = background.get(PBackground.V_OFFSET);
// writePoint(writer, "offset", new Point(offsetX, offsetY));
//
// int sepX = background.get(PBackground.H_SEP);
// int sepY = background.get(PBackground.V_SEP);
// writePoint(writer, "separation", new Point(sepX, sepY));
// writer.endElement();
// }
// writer.putElement("preload", background.get(PBackground.PRELOAD));
// writer.putElement("smoothEdges", background.get(PBackground.SMOOTH_EDGES));
// writer.putElement("transparent", background.get(PBackground.TRANSPARENT));
// }
// writer.endElement();
// }
//
// @Override
// public Background read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Background background = new Background();
// reader.enterElement("background");
// {
// readIdAttribute(background, reader);
// boolean useAsTileset = reader.getBoolElement("useAsTileset");
// background.put(PBackground.USE_AS_TILESET, useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// reader.enterElement("tiles");
// Dimension size = readDimension(reader, "size");
// background.put(PBackground.TILE_WIDTH, size.width);
// background.put(PBackground.TILE_HEIGHT, size.height);
//
// Point offset = readPoint(reader, "offset");
// background.put(PBackground.H_OFFSET, offset.x);
// background.put(PBackground.V_OFFSET, offset.y);
//
// Point separation = readPoint(reader, "separation");
// background.put(PBackground.H_SEP, separation.x);
// background.put(PBackground.V_SEP, separation.y);
// reader.leaveElement();
// }
// background.put(PBackground.PRELOAD, reader.getBoolElement("preload"));
// background.put(PBackground.SMOOTH_EDGES, reader.getBoolElement("smoothEdges"));
// background.put(PBackground.TRANSPARENT, reader.getBoolElement("transparent"));
// }
// reader.leaveElement();
// return background;
// }
// }
| import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Background;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.BackgroundXmlFormat;
| /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class BackgroundFormat extends ResourceFormat<Background> {
@Override
| // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/BackgroundXmlFormat.java
// public class BackgroundXmlFormat extends XmlFormat<Background> {
// @Override
// public void write(Background background, XmlWriter writer) {
// writer.startElement("background");
// {
// writeIdAttribute(background, writer);
// boolean useAsTileset = background.get(PBackground.USE_AS_TILESET);
// writer.putElement("useAsTileset", useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// writer.startElement("tiles");
// int width = background.get(PBackground.TILE_WIDTH);
// int height = background.get(PBackground.TILE_HEIGHT);
// writeDimension(writer, "size", new Dimension(width, height));
//
// int offsetX = background.get(PBackground.H_OFFSET);
// int offsetY = background.get(PBackground.V_OFFSET);
// writePoint(writer, "offset", new Point(offsetX, offsetY));
//
// int sepX = background.get(PBackground.H_SEP);
// int sepY = background.get(PBackground.V_SEP);
// writePoint(writer, "separation", new Point(sepX, sepY));
// writer.endElement();
// }
// writer.putElement("preload", background.get(PBackground.PRELOAD));
// writer.putElement("smoothEdges", background.get(PBackground.SMOOTH_EDGES));
// writer.putElement("transparent", background.get(PBackground.TRANSPARENT));
// }
// writer.endElement();
// }
//
// @Override
// public Background read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Background background = new Background();
// reader.enterElement("background");
// {
// readIdAttribute(background, reader);
// boolean useAsTileset = reader.getBoolElement("useAsTileset");
// background.put(PBackground.USE_AS_TILESET, useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// reader.enterElement("tiles");
// Dimension size = readDimension(reader, "size");
// background.put(PBackground.TILE_WIDTH, size.width);
// background.put(PBackground.TILE_HEIGHT, size.height);
//
// Point offset = readPoint(reader, "offset");
// background.put(PBackground.H_OFFSET, offset.x);
// background.put(PBackground.V_OFFSET, offset.y);
//
// Point separation = readPoint(reader, "separation");
// background.put(PBackground.H_SEP, separation.x);
// background.put(PBackground.V_SEP, separation.y);
// reader.leaveElement();
// }
// background.put(PBackground.PRELOAD, reader.getBoolElement("preload"));
// background.put(PBackground.SMOOTH_EDGES, reader.getBoolElement("smoothEdges"));
// background.put(PBackground.TRANSPARENT, reader.getBoolElement("transparent"));
// }
// reader.leaveElement();
// return background;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/BackgroundFormat.java
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Background;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.BackgroundXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class BackgroundFormat extends ResourceFormat<Background> {
@Override
| public Background read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
|
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/BackgroundFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/BackgroundXmlFormat.java
// public class BackgroundXmlFormat extends XmlFormat<Background> {
// @Override
// public void write(Background background, XmlWriter writer) {
// writer.startElement("background");
// {
// writeIdAttribute(background, writer);
// boolean useAsTileset = background.get(PBackground.USE_AS_TILESET);
// writer.putElement("useAsTileset", useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// writer.startElement("tiles");
// int width = background.get(PBackground.TILE_WIDTH);
// int height = background.get(PBackground.TILE_HEIGHT);
// writeDimension(writer, "size", new Dimension(width, height));
//
// int offsetX = background.get(PBackground.H_OFFSET);
// int offsetY = background.get(PBackground.V_OFFSET);
// writePoint(writer, "offset", new Point(offsetX, offsetY));
//
// int sepX = background.get(PBackground.H_SEP);
// int sepY = background.get(PBackground.V_SEP);
// writePoint(writer, "separation", new Point(sepX, sepY));
// writer.endElement();
// }
// writer.putElement("preload", background.get(PBackground.PRELOAD));
// writer.putElement("smoothEdges", background.get(PBackground.SMOOTH_EDGES));
// writer.putElement("transparent", background.get(PBackground.TRANSPARENT));
// }
// writer.endElement();
// }
//
// @Override
// public Background read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Background background = new Background();
// reader.enterElement("background");
// {
// readIdAttribute(background, reader);
// boolean useAsTileset = reader.getBoolElement("useAsTileset");
// background.put(PBackground.USE_AS_TILESET, useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// reader.enterElement("tiles");
// Dimension size = readDimension(reader, "size");
// background.put(PBackground.TILE_WIDTH, size.width);
// background.put(PBackground.TILE_HEIGHT, size.height);
//
// Point offset = readPoint(reader, "offset");
// background.put(PBackground.H_OFFSET, offset.x);
// background.put(PBackground.V_OFFSET, offset.y);
//
// Point separation = readPoint(reader, "separation");
// background.put(PBackground.H_SEP, separation.x);
// background.put(PBackground.V_SEP, separation.y);
// reader.leaveElement();
// }
// background.put(PBackground.PRELOAD, reader.getBoolElement("preload"));
// background.put(PBackground.SMOOTH_EDGES, reader.getBoolElement("smoothEdges"));
// background.put(PBackground.TRANSPARENT, reader.getBoolElement("transparent"));
// }
// reader.leaveElement();
// return background;
// }
// }
| import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Background;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.BackgroundXmlFormat;
| /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class BackgroundFormat extends ResourceFormat<Background> {
@Override
public Background read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
throws IOException {
File imageFile = new File(path, baseFilename(entry) + ".png");
| // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/BackgroundXmlFormat.java
// public class BackgroundXmlFormat extends XmlFormat<Background> {
// @Override
// public void write(Background background, XmlWriter writer) {
// writer.startElement("background");
// {
// writeIdAttribute(background, writer);
// boolean useAsTileset = background.get(PBackground.USE_AS_TILESET);
// writer.putElement("useAsTileset", useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// writer.startElement("tiles");
// int width = background.get(PBackground.TILE_WIDTH);
// int height = background.get(PBackground.TILE_HEIGHT);
// writeDimension(writer, "size", new Dimension(width, height));
//
// int offsetX = background.get(PBackground.H_OFFSET);
// int offsetY = background.get(PBackground.V_OFFSET);
// writePoint(writer, "offset", new Point(offsetX, offsetY));
//
// int sepX = background.get(PBackground.H_SEP);
// int sepY = background.get(PBackground.V_SEP);
// writePoint(writer, "separation", new Point(sepX, sepY));
// writer.endElement();
// }
// writer.putElement("preload", background.get(PBackground.PRELOAD));
// writer.putElement("smoothEdges", background.get(PBackground.SMOOTH_EDGES));
// writer.putElement("transparent", background.get(PBackground.TRANSPARENT));
// }
// writer.endElement();
// }
//
// @Override
// public Background read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Background background = new Background();
// reader.enterElement("background");
// {
// readIdAttribute(background, reader);
// boolean useAsTileset = reader.getBoolElement("useAsTileset");
// background.put(PBackground.USE_AS_TILESET, useAsTileset);
// if (useAsTileset || !GmkSplitter.omitDisabledFields) {
// reader.enterElement("tiles");
// Dimension size = readDimension(reader, "size");
// background.put(PBackground.TILE_WIDTH, size.width);
// background.put(PBackground.TILE_HEIGHT, size.height);
//
// Point offset = readPoint(reader, "offset");
// background.put(PBackground.H_OFFSET, offset.x);
// background.put(PBackground.V_OFFSET, offset.y);
//
// Point separation = readPoint(reader, "separation");
// background.put(PBackground.H_SEP, separation.x);
// background.put(PBackground.V_SEP, separation.y);
// reader.leaveElement();
// }
// background.put(PBackground.PRELOAD, reader.getBoolElement("preload"));
// background.put(PBackground.SMOOTH_EDGES, reader.getBoolElement("smoothEdges"));
// background.put(PBackground.TRANSPARENT, reader.getBoolElement("transparent"));
// }
// reader.leaveElement();
// return background;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/BackgroundFormat.java
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Background;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.BackgroundXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class BackgroundFormat extends ResourceFormat<Background> {
@Override
public Background read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
throws IOException {
File imageFile = new File(path, baseFilename(entry) + ".png");
| Background background = new BackgroundXmlFormat()
|
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/FileTreeFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/FileTools.java
// public class FileTools {
// public static void writeFile(File file, String content) throws IOException {
// writeFile(file, content.getBytes("UTF-8"));
// }
//
// public static void writeFile(File file, byte[] content) throws IOException {
// // Never overwrite
// if (file.exists()) {
// throw new IOException("File " + file + " already exists.");
// }
//
// FileOutputStream fos = null;
// DataOutputStream dos = null;
//
// try {
// fos = new FileOutputStream(file);
// dos = new DataOutputStream(fos);
// dos.write(content);
// } finally {
// tryToClose(fos);
// tryToClose(dos);
// }
// }
//
// /**
// * Modify the given String so that it can be used as part of a filename
// * without causing problems from illegal/special characters.
// *
// * The result should be similar to the input, but isn't necessarily
// * reversible. The implementation might change in the future, so don't rely
// * on the output staying the same.
// */
// public static String replaceBadChars(String name) {
// if (name == null || name.trim().isEmpty())
// return "_";
// name = name.trim();
// for (String badChar : badChars) {
// name = name.replace(badChar, "_");
// }
// return name;
// }
//
// public static boolean isGoodFilename(String name) {
// if (name == null || name.trim().isEmpty())
// return false;
// if (!name.trim().equals(name)) {
// return false;
// }
// for (String s : badChars) {
// if (name.contains(s))
// return false;
// }
// return true;
// }
//
// private static final String[] badChars = new String[] { "/", "\\", ":", "*", "?", "\"", "<", ">", "|", ".", "\0" };
//
// public static String readFileAsString(File file) throws IOException {
// return new String(readWholeFileBytes(file), "UTF-8");
// }
//
// public static byte[] readWholeFileBytes(File file) throws IOException {
// FileInputStream fis = null;
// DataInputStream dis = null;
// try {
// fis = new FileInputStream(file);
// dis = new DataInputStream(fis);
// byte[] buffer = new byte[(int) file.length()];
// dis.readFully(buffer);
//
// return buffer;
// } finally {
// tryToClose(fis);
// tryToClose(dis);
// }
// }
//
// private static void tryToClose(Closeable stream) {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// }
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.FileTools;
import com.ganggarrison.gmdec.ResourceTreeEntry; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public abstract class FileTreeFormat<T> {
public abstract void write(File path, T resource, GmFile gmf) throws IOException;
/**
* Add a resource into the resource tree.
*
* @param resource
* A resource read by this format
* @param parent
* The parent node for this resource
*/
public abstract void addResToTree(T resource, ResNode parent);
/**
* Add all resources of the type read by this format into the GmFile. This
* method must be called with all resources of that type that should go into
* the GmFile, so that ID conflicts can be properly resolved.
*/
public abstract void addAllResourcesToGmFile(List<T> resources, GmFile gmf);
| // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/FileTools.java
// public class FileTools {
// public static void writeFile(File file, String content) throws IOException {
// writeFile(file, content.getBytes("UTF-8"));
// }
//
// public static void writeFile(File file, byte[] content) throws IOException {
// // Never overwrite
// if (file.exists()) {
// throw new IOException("File " + file + " already exists.");
// }
//
// FileOutputStream fos = null;
// DataOutputStream dos = null;
//
// try {
// fos = new FileOutputStream(file);
// dos = new DataOutputStream(fos);
// dos.write(content);
// } finally {
// tryToClose(fos);
// tryToClose(dos);
// }
// }
//
// /**
// * Modify the given String so that it can be used as part of a filename
// * without causing problems from illegal/special characters.
// *
// * The result should be similar to the input, but isn't necessarily
// * reversible. The implementation might change in the future, so don't rely
// * on the output staying the same.
// */
// public static String replaceBadChars(String name) {
// if (name == null || name.trim().isEmpty())
// return "_";
// name = name.trim();
// for (String badChar : badChars) {
// name = name.replace(badChar, "_");
// }
// return name;
// }
//
// public static boolean isGoodFilename(String name) {
// if (name == null || name.trim().isEmpty())
// return false;
// if (!name.trim().equals(name)) {
// return false;
// }
// for (String s : badChars) {
// if (name.contains(s))
// return false;
// }
// return true;
// }
//
// private static final String[] badChars = new String[] { "/", "\\", ":", "*", "?", "\"", "<", ">", "|", ".", "\0" };
//
// public static String readFileAsString(File file) throws IOException {
// return new String(readWholeFileBytes(file), "UTF-8");
// }
//
// public static byte[] readWholeFileBytes(File file) throws IOException {
// FileInputStream fis = null;
// DataInputStream dis = null;
// try {
// fis = new FileInputStream(file);
// dis = new DataInputStream(fis);
// byte[] buffer = new byte[(int) file.length()];
// dis.readFully(buffer);
//
// return buffer;
// } finally {
// tryToClose(fis);
// tryToClose(dis);
// }
// }
//
// private static void tryToClose(Closeable stream) {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// }
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
// Path: src/com/ganggarrison/gmdec/files/FileTreeFormat.java
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.FileTools;
import com.ganggarrison.gmdec.ResourceTreeEntry;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public abstract class FileTreeFormat<T> {
public abstract void write(File path, T resource, GmFile gmf) throws IOException;
/**
* Add a resource into the resource tree.
*
* @param resource
* A resource read by this format
* @param parent
* The parent node for this resource
*/
public abstract void addResToTree(T resource, ResNode parent);
/**
* Add all resources of the type read by this format into the GmFile. This
* method must be called with all resources of that type that should go into
* the GmFile, so that ID conflicts can be properly resolved.
*/
public abstract void addAllResourcesToGmFile(List<T> resources, GmFile gmf);
| public abstract T read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/FileTreeFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/FileTools.java
// public class FileTools {
// public static void writeFile(File file, String content) throws IOException {
// writeFile(file, content.getBytes("UTF-8"));
// }
//
// public static void writeFile(File file, byte[] content) throws IOException {
// // Never overwrite
// if (file.exists()) {
// throw new IOException("File " + file + " already exists.");
// }
//
// FileOutputStream fos = null;
// DataOutputStream dos = null;
//
// try {
// fos = new FileOutputStream(file);
// dos = new DataOutputStream(fos);
// dos.write(content);
// } finally {
// tryToClose(fos);
// tryToClose(dos);
// }
// }
//
// /**
// * Modify the given String so that it can be used as part of a filename
// * without causing problems from illegal/special characters.
// *
// * The result should be similar to the input, but isn't necessarily
// * reversible. The implementation might change in the future, so don't rely
// * on the output staying the same.
// */
// public static String replaceBadChars(String name) {
// if (name == null || name.trim().isEmpty())
// return "_";
// name = name.trim();
// for (String badChar : badChars) {
// name = name.replace(badChar, "_");
// }
// return name;
// }
//
// public static boolean isGoodFilename(String name) {
// if (name == null || name.trim().isEmpty())
// return false;
// if (!name.trim().equals(name)) {
// return false;
// }
// for (String s : badChars) {
// if (name.contains(s))
// return false;
// }
// return true;
// }
//
// private static final String[] badChars = new String[] { "/", "\\", ":", "*", "?", "\"", "<", ">", "|", ".", "\0" };
//
// public static String readFileAsString(File file) throws IOException {
// return new String(readWholeFileBytes(file), "UTF-8");
// }
//
// public static byte[] readWholeFileBytes(File file) throws IOException {
// FileInputStream fis = null;
// DataInputStream dis = null;
// try {
// fis = new FileInputStream(file);
// dis = new DataInputStream(fis);
// byte[] buffer = new byte[(int) file.length()];
// dis.readFully(buffer);
//
// return buffer;
// } finally {
// tryToClose(fis);
// tryToClose(dis);
// }
// }
//
// private static void tryToClose(Closeable stream) {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// }
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.FileTools;
import com.ganggarrison.gmdec.ResourceTreeEntry; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public abstract class FileTreeFormat<T> {
public abstract void write(File path, T resource, GmFile gmf) throws IOException;
/**
* Add a resource into the resource tree.
*
* @param resource
* A resource read by this format
* @param parent
* The parent node for this resource
*/
public abstract void addResToTree(T resource, ResNode parent);
/**
* Add all resources of the type read by this format into the GmFile. This
* method must be called with all resources of that type that should go into
* the GmFile, so that ID conflicts can be properly resolved.
*/
public abstract void addAllResourcesToGmFile(List<T> resources, GmFile gmf);
| // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/FileTools.java
// public class FileTools {
// public static void writeFile(File file, String content) throws IOException {
// writeFile(file, content.getBytes("UTF-8"));
// }
//
// public static void writeFile(File file, byte[] content) throws IOException {
// // Never overwrite
// if (file.exists()) {
// throw new IOException("File " + file + " already exists.");
// }
//
// FileOutputStream fos = null;
// DataOutputStream dos = null;
//
// try {
// fos = new FileOutputStream(file);
// dos = new DataOutputStream(fos);
// dos.write(content);
// } finally {
// tryToClose(fos);
// tryToClose(dos);
// }
// }
//
// /**
// * Modify the given String so that it can be used as part of a filename
// * without causing problems from illegal/special characters.
// *
// * The result should be similar to the input, but isn't necessarily
// * reversible. The implementation might change in the future, so don't rely
// * on the output staying the same.
// */
// public static String replaceBadChars(String name) {
// if (name == null || name.trim().isEmpty())
// return "_";
// name = name.trim();
// for (String badChar : badChars) {
// name = name.replace(badChar, "_");
// }
// return name;
// }
//
// public static boolean isGoodFilename(String name) {
// if (name == null || name.trim().isEmpty())
// return false;
// if (!name.trim().equals(name)) {
// return false;
// }
// for (String s : badChars) {
// if (name.contains(s))
// return false;
// }
// return true;
// }
//
// private static final String[] badChars = new String[] { "/", "\\", ":", "*", "?", "\"", "<", ">", "|", ".", "\0" };
//
// public static String readFileAsString(File file) throws IOException {
// return new String(readWholeFileBytes(file), "UTF-8");
// }
//
// public static byte[] readWholeFileBytes(File file) throws IOException {
// FileInputStream fis = null;
// DataInputStream dis = null;
// try {
// fis = new FileInputStream(file);
// dis = new DataInputStream(fis);
// byte[] buffer = new byte[(int) file.length()];
// dis.readFully(buffer);
//
// return buffer;
// } finally {
// tryToClose(fis);
// tryToClose(dis);
// }
// }
//
// private static void tryToClose(Closeable stream) {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// }
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
// Path: src/com/ganggarrison/gmdec/files/FileTreeFormat.java
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.FileTools;
import com.ganggarrison.gmdec.ResourceTreeEntry;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public abstract class FileTreeFormat<T> {
public abstract void write(File path, T resource, GmFile gmf) throws IOException;
/**
* Add a resource into the resource tree.
*
* @param resource
* A resource read by this format
* @param parent
* The parent node for this resource
*/
public abstract void addResToTree(T resource, ResNode parent);
/**
* Add all resources of the type read by this format into the GmFile. This
* method must be called with all resources of that type that should go into
* the GmFile, so that ID conflicts can be properly resolved.
*/
public abstract void addAllResourcesToGmFile(List<T> resources, GmFile gmf);
| public abstract T read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/FileTreeFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/FileTools.java
// public class FileTools {
// public static void writeFile(File file, String content) throws IOException {
// writeFile(file, content.getBytes("UTF-8"));
// }
//
// public static void writeFile(File file, byte[] content) throws IOException {
// // Never overwrite
// if (file.exists()) {
// throw new IOException("File " + file + " already exists.");
// }
//
// FileOutputStream fos = null;
// DataOutputStream dos = null;
//
// try {
// fos = new FileOutputStream(file);
// dos = new DataOutputStream(fos);
// dos.write(content);
// } finally {
// tryToClose(fos);
// tryToClose(dos);
// }
// }
//
// /**
// * Modify the given String so that it can be used as part of a filename
// * without causing problems from illegal/special characters.
// *
// * The result should be similar to the input, but isn't necessarily
// * reversible. The implementation might change in the future, so don't rely
// * on the output staying the same.
// */
// public static String replaceBadChars(String name) {
// if (name == null || name.trim().isEmpty())
// return "_";
// name = name.trim();
// for (String badChar : badChars) {
// name = name.replace(badChar, "_");
// }
// return name;
// }
//
// public static boolean isGoodFilename(String name) {
// if (name == null || name.trim().isEmpty())
// return false;
// if (!name.trim().equals(name)) {
// return false;
// }
// for (String s : badChars) {
// if (name.contains(s))
// return false;
// }
// return true;
// }
//
// private static final String[] badChars = new String[] { "/", "\\", ":", "*", "?", "\"", "<", ">", "|", ".", "\0" };
//
// public static String readFileAsString(File file) throws IOException {
// return new String(readWholeFileBytes(file), "UTF-8");
// }
//
// public static byte[] readWholeFileBytes(File file) throws IOException {
// FileInputStream fis = null;
// DataInputStream dis = null;
// try {
// fis = new FileInputStream(file);
// dis = new DataInputStream(fis);
// byte[] buffer = new byte[(int) file.length()];
// dis.readFully(buffer);
//
// return buffer;
// } finally {
// tryToClose(fis);
// tryToClose(dis);
// }
// }
//
// private static void tryToClose(Closeable stream) {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// }
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.FileTools;
import com.ganggarrison.gmdec.ResourceTreeEntry; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public abstract class FileTreeFormat<T> {
public abstract void write(File path, T resource, GmFile gmf) throws IOException;
/**
* Add a resource into the resource tree.
*
* @param resource
* A resource read by this format
* @param parent
* The parent node for this resource
*/
public abstract void addResToTree(T resource, ResNode parent);
/**
* Add all resources of the type read by this format into the GmFile. This
* method must be called with all resources of that type that should go into
* the GmFile, so that ID conflicts can be properly resolved.
*/
public abstract void addAllResourcesToGmFile(List<T> resources, GmFile gmf);
public abstract T read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
throws IOException;
public abstract ResourceTreeEntry createResourceTreeEntry(T resource);
protected String baseFilename(Resource<?, ?> resource) {
return baseFilename(resource.getName());
}
protected String baseFilename(String resourceName) { | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/FileTools.java
// public class FileTools {
// public static void writeFile(File file, String content) throws IOException {
// writeFile(file, content.getBytes("UTF-8"));
// }
//
// public static void writeFile(File file, byte[] content) throws IOException {
// // Never overwrite
// if (file.exists()) {
// throw new IOException("File " + file + " already exists.");
// }
//
// FileOutputStream fos = null;
// DataOutputStream dos = null;
//
// try {
// fos = new FileOutputStream(file);
// dos = new DataOutputStream(fos);
// dos.write(content);
// } finally {
// tryToClose(fos);
// tryToClose(dos);
// }
// }
//
// /**
// * Modify the given String so that it can be used as part of a filename
// * without causing problems from illegal/special characters.
// *
// * The result should be similar to the input, but isn't necessarily
// * reversible. The implementation might change in the future, so don't rely
// * on the output staying the same.
// */
// public static String replaceBadChars(String name) {
// if (name == null || name.trim().isEmpty())
// return "_";
// name = name.trim();
// for (String badChar : badChars) {
// name = name.replace(badChar, "_");
// }
// return name;
// }
//
// public static boolean isGoodFilename(String name) {
// if (name == null || name.trim().isEmpty())
// return false;
// if (!name.trim().equals(name)) {
// return false;
// }
// for (String s : badChars) {
// if (name.contains(s))
// return false;
// }
// return true;
// }
//
// private static final String[] badChars = new String[] { "/", "\\", ":", "*", "?", "\"", "<", ">", "|", ".", "\0" };
//
// public static String readFileAsString(File file) throws IOException {
// return new String(readWholeFileBytes(file), "UTF-8");
// }
//
// public static byte[] readWholeFileBytes(File file) throws IOException {
// FileInputStream fis = null;
// DataInputStream dis = null;
// try {
// fis = new FileInputStream(file);
// dis = new DataInputStream(fis);
// byte[] buffer = new byte[(int) file.length()];
// dis.readFully(buffer);
//
// return buffer;
// } finally {
// tryToClose(fis);
// tryToClose(dis);
// }
// }
//
// private static void tryToClose(Closeable stream) {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// }
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
// Path: src/com/ganggarrison/gmdec/files/FileTreeFormat.java
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.lateralgm.components.impl.ResNode;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Resource;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.FileTools;
import com.ganggarrison.gmdec.ResourceTreeEntry;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public abstract class FileTreeFormat<T> {
public abstract void write(File path, T resource, GmFile gmf) throws IOException;
/**
* Add a resource into the resource tree.
*
* @param resource
* A resource read by this format
* @param parent
* The parent node for this resource
*/
public abstract void addResToTree(T resource, ResNode parent);
/**
* Add all resources of the type read by this format into the GmFile. This
* method must be called with all resources of that type that should go into
* the GmFile, so that ID conflicts can be properly resolved.
*/
public abstract void addAllResourcesToGmFile(List<T> resources, GmFile gmf);
public abstract T read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn)
throws IOException;
public abstract ResourceTreeEntry createResourceTreeEntry(T resource);
protected String baseFilename(Resource<?, ?> resource) {
return baseFilename(resource.getName());
}
protected String baseFilename(String resourceName) { | return FileTools.replaceBadChars(resourceName); |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/TimelineFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/TimelineXmlFormat.java
// public class TimelineXmlFormat extends XmlFormat<Timeline> {
//
// @Override
// public void write(Timeline timeline, XmlWriter writer) {
// writer.startElement("timeline");
// {
// writeIdAttribute(timeline, writer);
// for (Moment moment : timeline.moments) {
// writer.startElement("moment");
// writer.putAttribute("stepNo", moment.stepNo);
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// for (Action action : moment.actions) {
// actionFormat.write(action, writer);
// }
// writer.endElement();
// }
// }
// writer.endElement();
// }
//
// @Override
// public Timeline read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Timeline timeline = new Timeline();
// reader.enterElement("timeline");
// {
// readIdAttribute(timeline, reader);
// while (reader.hasNextElement()) {
// Moment moment = timeline.addMoment();
// reader.enterElement("moment");
// moment.stepNo = reader.getIntAttribute("stepNo");
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// while (reader.hasNextElement()) {
// moment.actions.add(actionFormat.read(reader, notifier));
// }
// reader.leaveElement();
// }
// }
// reader.leaveElement();
// return timeline;
// }
// }
| import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Timeline;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.TimelineXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class TimelineFormat extends ResourceFormat<Timeline> {
@Override | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/TimelineXmlFormat.java
// public class TimelineXmlFormat extends XmlFormat<Timeline> {
//
// @Override
// public void write(Timeline timeline, XmlWriter writer) {
// writer.startElement("timeline");
// {
// writeIdAttribute(timeline, writer);
// for (Moment moment : timeline.moments) {
// writer.startElement("moment");
// writer.putAttribute("stepNo", moment.stepNo);
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// for (Action action : moment.actions) {
// actionFormat.write(action, writer);
// }
// writer.endElement();
// }
// }
// writer.endElement();
// }
//
// @Override
// public Timeline read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Timeline timeline = new Timeline();
// reader.enterElement("timeline");
// {
// readIdAttribute(timeline, reader);
// while (reader.hasNextElement()) {
// Moment moment = timeline.addMoment();
// reader.enterElement("moment");
// moment.stepNo = reader.getIntAttribute("stepNo");
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// while (reader.hasNextElement()) {
// moment.actions.add(actionFormat.read(reader, notifier));
// }
// reader.leaveElement();
// }
// }
// reader.leaveElement();
// return timeline;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/TimelineFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Timeline;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.TimelineXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class TimelineFormat extends ResourceFormat<Timeline> {
@Override | public Timeline read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException { |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/TimelineFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/TimelineXmlFormat.java
// public class TimelineXmlFormat extends XmlFormat<Timeline> {
//
// @Override
// public void write(Timeline timeline, XmlWriter writer) {
// writer.startElement("timeline");
// {
// writeIdAttribute(timeline, writer);
// for (Moment moment : timeline.moments) {
// writer.startElement("moment");
// writer.putAttribute("stepNo", moment.stepNo);
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// for (Action action : moment.actions) {
// actionFormat.write(action, writer);
// }
// writer.endElement();
// }
// }
// writer.endElement();
// }
//
// @Override
// public Timeline read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Timeline timeline = new Timeline();
// reader.enterElement("timeline");
// {
// readIdAttribute(timeline, reader);
// while (reader.hasNextElement()) {
// Moment moment = timeline.addMoment();
// reader.enterElement("moment");
// moment.stepNo = reader.getIntAttribute("stepNo");
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// while (reader.hasNextElement()) {
// moment.actions.add(actionFormat.read(reader, notifier));
// }
// reader.leaveElement();
// }
// }
// reader.leaveElement();
// return timeline;
// }
// }
| import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Timeline;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.TimelineXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class TimelineFormat extends ResourceFormat<Timeline> {
@Override | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/TimelineXmlFormat.java
// public class TimelineXmlFormat extends XmlFormat<Timeline> {
//
// @Override
// public void write(Timeline timeline, XmlWriter writer) {
// writer.startElement("timeline");
// {
// writeIdAttribute(timeline, writer);
// for (Moment moment : timeline.moments) {
// writer.startElement("moment");
// writer.putAttribute("stepNo", moment.stepNo);
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// for (Action action : moment.actions) {
// actionFormat.write(action, writer);
// }
// writer.endElement();
// }
// }
// writer.endElement();
// }
//
// @Override
// public Timeline read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Timeline timeline = new Timeline();
// reader.enterElement("timeline");
// {
// readIdAttribute(timeline, reader);
// while (reader.hasNextElement()) {
// Moment moment = timeline.addMoment();
// reader.enterElement("moment");
// moment.stepNo = reader.getIntAttribute("stepNo");
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// while (reader.hasNextElement()) {
// moment.actions.add(actionFormat.read(reader, notifier));
// }
// reader.leaveElement();
// }
// }
// reader.leaveElement();
// return timeline;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/TimelineFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Timeline;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.TimelineXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class TimelineFormat extends ResourceFormat<Timeline> {
@Override | public Timeline read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException { |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/TimelineFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/TimelineXmlFormat.java
// public class TimelineXmlFormat extends XmlFormat<Timeline> {
//
// @Override
// public void write(Timeline timeline, XmlWriter writer) {
// writer.startElement("timeline");
// {
// writeIdAttribute(timeline, writer);
// for (Moment moment : timeline.moments) {
// writer.startElement("moment");
// writer.putAttribute("stepNo", moment.stepNo);
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// for (Action action : moment.actions) {
// actionFormat.write(action, writer);
// }
// writer.endElement();
// }
// }
// writer.endElement();
// }
//
// @Override
// public Timeline read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Timeline timeline = new Timeline();
// reader.enterElement("timeline");
// {
// readIdAttribute(timeline, reader);
// while (reader.hasNextElement()) {
// Moment moment = timeline.addMoment();
// reader.enterElement("moment");
// moment.stepNo = reader.getIntAttribute("stepNo");
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// while (reader.hasNextElement()) {
// moment.actions.add(actionFormat.read(reader, notifier));
// }
// reader.leaveElement();
// }
// }
// reader.leaveElement();
// return timeline;
// }
// }
| import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Timeline;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.TimelineXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class TimelineFormat extends ResourceFormat<Timeline> {
@Override
public Timeline read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException { | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/TimelineXmlFormat.java
// public class TimelineXmlFormat extends XmlFormat<Timeline> {
//
// @Override
// public void write(Timeline timeline, XmlWriter writer) {
// writer.startElement("timeline");
// {
// writeIdAttribute(timeline, writer);
// for (Moment moment : timeline.moments) {
// writer.startElement("moment");
// writer.putAttribute("stepNo", moment.stepNo);
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// for (Action action : moment.actions) {
// actionFormat.write(action, writer);
// }
// writer.endElement();
// }
// }
// writer.endElement();
// }
//
// @Override
// public Timeline read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Timeline timeline = new Timeline();
// reader.enterElement("timeline");
// {
// readIdAttribute(timeline, reader);
// while (reader.hasNextElement()) {
// Moment moment = timeline.addMoment();
// reader.enterElement("moment");
// moment.stepNo = reader.getIntAttribute("stepNo");
// ActionXmlFormat actionFormat = new ActionXmlFormat();
// while (reader.hasNextElement()) {
// moment.actions.add(actionFormat.read(reader, notifier));
// }
// reader.leaveElement();
// }
// }
// reader.leaveElement();
// return timeline;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/TimelineFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Timeline;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.TimelineXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class TimelineFormat extends ResourceFormat<Timeline> {
@Override
public Timeline read(File path, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException { | Timeline timeline = new TimelineXmlFormat().read(getXmlFile(path, entry), drcn); |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/PathFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/PathXmlFormat.java
// public class PathXmlFormat extends XmlFormat<Path> {
//
// @Override
// public void write(Path path, XmlWriter writer) {
// writer.startElement("path");
// {
// writeIdAttribute(path, writer);
// writer.startElement("points");
// for (PathPoint pp : path.points) {
// writer.startElement("point");
// writer.putAttribute("x", pp.getX());
// writer.putAttribute("y", pp.getY());
// writer.putAttribute("speed", pp.getSpeed());
// writer.endElement();
// }
// writer.endElement();
// writeResourceRef(writer, "backgroundRoom", (ResourceReference<?>) path.get(PPath.BACKGROUND_ROOM));
// writer.putElement("closed", path.get(PPath.CLOSED));
// writer.putElement("precision", path.get(PPath.PRECISION));
// writer.putElement("smooth", path.get(PPath.SMOOTH));
//
// int snapX = path.get(PPath.SNAP_X);
// int snapY = path.get(PPath.SNAP_Y);
// writePoint(writer, "snap", new Point(snapX, snapY));
// }
// writer.endElement();
// }
//
// @Override
// public Path read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Path path = new Path();
//
// reader.enterElement("path");
// {
// readIdAttribute(path, reader);
// reader.enterElement("points");
// while (reader.hasNextElement()) {
// reader.enterElement("point");
// PathPoint pp = path.addPoint();
// pp.setX(reader.getIntAttribute("x"));
// pp.setY(reader.getIntAttribute("y"));
// pp.setSpeed(reader.getIntAttribute("speed"));
// reader.leaveElement();
// }
// reader.leaveElement();
// String backgroundRoomRef = readResourceRef(reader, "backgroundRoom");
// DeferredReferenceCreator rc = new DeferredPropertyReferenceCreator<PPath>(
// path.properties, PPath.BACKGROUND_ROOM, Room.class, backgroundRoomRef);
// notifier.addDeferredReferenceCreator(rc);
// path.put(PPath.CLOSED, reader.getBoolElement("closed"));
// path.put(PPath.PRECISION, reader.getIntElement("precision"));
// path.put(PPath.SMOOTH, reader.getBoolElement("smooth"));
//
// Point snap = readPoint(reader, "snap");
// path.put(PPath.SNAP_X, snap.x);
// path.put(PPath.SNAP_Y, snap.y);
// }
// reader.leaveElement();
// return path;
// }
// }
| import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Path;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.PathXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class PathFormat extends ResourceFormat<Path> {
@Override | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/PathXmlFormat.java
// public class PathXmlFormat extends XmlFormat<Path> {
//
// @Override
// public void write(Path path, XmlWriter writer) {
// writer.startElement("path");
// {
// writeIdAttribute(path, writer);
// writer.startElement("points");
// for (PathPoint pp : path.points) {
// writer.startElement("point");
// writer.putAttribute("x", pp.getX());
// writer.putAttribute("y", pp.getY());
// writer.putAttribute("speed", pp.getSpeed());
// writer.endElement();
// }
// writer.endElement();
// writeResourceRef(writer, "backgroundRoom", (ResourceReference<?>) path.get(PPath.BACKGROUND_ROOM));
// writer.putElement("closed", path.get(PPath.CLOSED));
// writer.putElement("precision", path.get(PPath.PRECISION));
// writer.putElement("smooth", path.get(PPath.SMOOTH));
//
// int snapX = path.get(PPath.SNAP_X);
// int snapY = path.get(PPath.SNAP_Y);
// writePoint(writer, "snap", new Point(snapX, snapY));
// }
// writer.endElement();
// }
//
// @Override
// public Path read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Path path = new Path();
//
// reader.enterElement("path");
// {
// readIdAttribute(path, reader);
// reader.enterElement("points");
// while (reader.hasNextElement()) {
// reader.enterElement("point");
// PathPoint pp = path.addPoint();
// pp.setX(reader.getIntAttribute("x"));
// pp.setY(reader.getIntAttribute("y"));
// pp.setSpeed(reader.getIntAttribute("speed"));
// reader.leaveElement();
// }
// reader.leaveElement();
// String backgroundRoomRef = readResourceRef(reader, "backgroundRoom");
// DeferredReferenceCreator rc = new DeferredPropertyReferenceCreator<PPath>(
// path.properties, PPath.BACKGROUND_ROOM, Room.class, backgroundRoomRef);
// notifier.addDeferredReferenceCreator(rc);
// path.put(PPath.CLOSED, reader.getBoolElement("closed"));
// path.put(PPath.PRECISION, reader.getIntElement("precision"));
// path.put(PPath.SMOOTH, reader.getBoolElement("smooth"));
//
// Point snap = readPoint(reader, "snap");
// path.put(PPath.SNAP_X, snap.x);
// path.put(PPath.SNAP_Y, snap.y);
// }
// reader.leaveElement();
// return path;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/PathFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Path;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.PathXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class PathFormat extends ResourceFormat<Path> {
@Override | public Path read(File filePath, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException { |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/PathFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/PathXmlFormat.java
// public class PathXmlFormat extends XmlFormat<Path> {
//
// @Override
// public void write(Path path, XmlWriter writer) {
// writer.startElement("path");
// {
// writeIdAttribute(path, writer);
// writer.startElement("points");
// for (PathPoint pp : path.points) {
// writer.startElement("point");
// writer.putAttribute("x", pp.getX());
// writer.putAttribute("y", pp.getY());
// writer.putAttribute("speed", pp.getSpeed());
// writer.endElement();
// }
// writer.endElement();
// writeResourceRef(writer, "backgroundRoom", (ResourceReference<?>) path.get(PPath.BACKGROUND_ROOM));
// writer.putElement("closed", path.get(PPath.CLOSED));
// writer.putElement("precision", path.get(PPath.PRECISION));
// writer.putElement("smooth", path.get(PPath.SMOOTH));
//
// int snapX = path.get(PPath.SNAP_X);
// int snapY = path.get(PPath.SNAP_Y);
// writePoint(writer, "snap", new Point(snapX, snapY));
// }
// writer.endElement();
// }
//
// @Override
// public Path read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Path path = new Path();
//
// reader.enterElement("path");
// {
// readIdAttribute(path, reader);
// reader.enterElement("points");
// while (reader.hasNextElement()) {
// reader.enterElement("point");
// PathPoint pp = path.addPoint();
// pp.setX(reader.getIntAttribute("x"));
// pp.setY(reader.getIntAttribute("y"));
// pp.setSpeed(reader.getIntAttribute("speed"));
// reader.leaveElement();
// }
// reader.leaveElement();
// String backgroundRoomRef = readResourceRef(reader, "backgroundRoom");
// DeferredReferenceCreator rc = new DeferredPropertyReferenceCreator<PPath>(
// path.properties, PPath.BACKGROUND_ROOM, Room.class, backgroundRoomRef);
// notifier.addDeferredReferenceCreator(rc);
// path.put(PPath.CLOSED, reader.getBoolElement("closed"));
// path.put(PPath.PRECISION, reader.getIntElement("precision"));
// path.put(PPath.SMOOTH, reader.getBoolElement("smooth"));
//
// Point snap = readPoint(reader, "snap");
// path.put(PPath.SNAP_X, snap.x);
// path.put(PPath.SNAP_Y, snap.y);
// }
// reader.leaveElement();
// return path;
// }
// }
| import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Path;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.PathXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class PathFormat extends ResourceFormat<Path> {
@Override | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/PathXmlFormat.java
// public class PathXmlFormat extends XmlFormat<Path> {
//
// @Override
// public void write(Path path, XmlWriter writer) {
// writer.startElement("path");
// {
// writeIdAttribute(path, writer);
// writer.startElement("points");
// for (PathPoint pp : path.points) {
// writer.startElement("point");
// writer.putAttribute("x", pp.getX());
// writer.putAttribute("y", pp.getY());
// writer.putAttribute("speed", pp.getSpeed());
// writer.endElement();
// }
// writer.endElement();
// writeResourceRef(writer, "backgroundRoom", (ResourceReference<?>) path.get(PPath.BACKGROUND_ROOM));
// writer.putElement("closed", path.get(PPath.CLOSED));
// writer.putElement("precision", path.get(PPath.PRECISION));
// writer.putElement("smooth", path.get(PPath.SMOOTH));
//
// int snapX = path.get(PPath.SNAP_X);
// int snapY = path.get(PPath.SNAP_Y);
// writePoint(writer, "snap", new Point(snapX, snapY));
// }
// writer.endElement();
// }
//
// @Override
// public Path read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Path path = new Path();
//
// reader.enterElement("path");
// {
// readIdAttribute(path, reader);
// reader.enterElement("points");
// while (reader.hasNextElement()) {
// reader.enterElement("point");
// PathPoint pp = path.addPoint();
// pp.setX(reader.getIntAttribute("x"));
// pp.setY(reader.getIntAttribute("y"));
// pp.setSpeed(reader.getIntAttribute("speed"));
// reader.leaveElement();
// }
// reader.leaveElement();
// String backgroundRoomRef = readResourceRef(reader, "backgroundRoom");
// DeferredReferenceCreator rc = new DeferredPropertyReferenceCreator<PPath>(
// path.properties, PPath.BACKGROUND_ROOM, Room.class, backgroundRoomRef);
// notifier.addDeferredReferenceCreator(rc);
// path.put(PPath.CLOSED, reader.getBoolElement("closed"));
// path.put(PPath.PRECISION, reader.getIntElement("precision"));
// path.put(PPath.SMOOTH, reader.getBoolElement("smooth"));
//
// Point snap = readPoint(reader, "snap");
// path.put(PPath.SNAP_X, snap.x);
// path.put(PPath.SNAP_Y, snap.y);
// }
// reader.leaveElement();
// return path;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/PathFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Path;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.PathXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class PathFormat extends ResourceFormat<Path> {
@Override | public Path read(File filePath, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException { |
Medo42/Gmk-Splitter | src/com/ganggarrison/gmdec/files/PathFormat.java | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/PathXmlFormat.java
// public class PathXmlFormat extends XmlFormat<Path> {
//
// @Override
// public void write(Path path, XmlWriter writer) {
// writer.startElement("path");
// {
// writeIdAttribute(path, writer);
// writer.startElement("points");
// for (PathPoint pp : path.points) {
// writer.startElement("point");
// writer.putAttribute("x", pp.getX());
// writer.putAttribute("y", pp.getY());
// writer.putAttribute("speed", pp.getSpeed());
// writer.endElement();
// }
// writer.endElement();
// writeResourceRef(writer, "backgroundRoom", (ResourceReference<?>) path.get(PPath.BACKGROUND_ROOM));
// writer.putElement("closed", path.get(PPath.CLOSED));
// writer.putElement("precision", path.get(PPath.PRECISION));
// writer.putElement("smooth", path.get(PPath.SMOOTH));
//
// int snapX = path.get(PPath.SNAP_X);
// int snapY = path.get(PPath.SNAP_Y);
// writePoint(writer, "snap", new Point(snapX, snapY));
// }
// writer.endElement();
// }
//
// @Override
// public Path read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Path path = new Path();
//
// reader.enterElement("path");
// {
// readIdAttribute(path, reader);
// reader.enterElement("points");
// while (reader.hasNextElement()) {
// reader.enterElement("point");
// PathPoint pp = path.addPoint();
// pp.setX(reader.getIntAttribute("x"));
// pp.setY(reader.getIntAttribute("y"));
// pp.setSpeed(reader.getIntAttribute("speed"));
// reader.leaveElement();
// }
// reader.leaveElement();
// String backgroundRoomRef = readResourceRef(reader, "backgroundRoom");
// DeferredReferenceCreator rc = new DeferredPropertyReferenceCreator<PPath>(
// path.properties, PPath.BACKGROUND_ROOM, Room.class, backgroundRoomRef);
// notifier.addDeferredReferenceCreator(rc);
// path.put(PPath.CLOSED, reader.getBoolElement("closed"));
// path.put(PPath.PRECISION, reader.getIntElement("precision"));
// path.put(PPath.SMOOTH, reader.getBoolElement("smooth"));
//
// Point snap = readPoint(reader, "snap");
// path.put(PPath.SNAP_X, snap.x);
// path.put(PPath.SNAP_Y, snap.y);
// }
// reader.leaveElement();
// return path;
// }
// }
| import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Path;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.PathXmlFormat; | /*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class PathFormat extends ResourceFormat<Path> {
@Override
public Path read(File filePath, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException { | // Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
//
// public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// drcSet.add(drc);
// }
//
// public void createReferences(GmFile gmf) {
// for (DeferredReferenceCreator drc : drcSet) {
// drc.createReferences(gmf);
// }
// }
// }
//
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// public String name;
// public String filename;
// public Type type;
//
// public ResourceTreeEntry(String name, String filename, Type type) {
// this.name = name;
// this.filename = filename;
// this.type = type;
// }
//
// public ResourceTreeEntry() {
// }
//
// public String getFilename() {
// String result;
// if (filename != null && !filename.isEmpty()) {
// result = filename;
// } else {
// result = name;
// }
// if (FileTools.isGoodFilename(result)) {
// return result;
// } else {
// throw new IllegalStateException("Bad filename in resource list: " + result);
// }
// }
//
// public static enum Type {
// RESOURCE, GROUP
// }
// }
//
// Path: src/com/ganggarrison/gmdec/xml/PathXmlFormat.java
// public class PathXmlFormat extends XmlFormat<Path> {
//
// @Override
// public void write(Path path, XmlWriter writer) {
// writer.startElement("path");
// {
// writeIdAttribute(path, writer);
// writer.startElement("points");
// for (PathPoint pp : path.points) {
// writer.startElement("point");
// writer.putAttribute("x", pp.getX());
// writer.putAttribute("y", pp.getY());
// writer.putAttribute("speed", pp.getSpeed());
// writer.endElement();
// }
// writer.endElement();
// writeResourceRef(writer, "backgroundRoom", (ResourceReference<?>) path.get(PPath.BACKGROUND_ROOM));
// writer.putElement("closed", path.get(PPath.CLOSED));
// writer.putElement("precision", path.get(PPath.PRECISION));
// writer.putElement("smooth", path.get(PPath.SMOOTH));
//
// int snapX = path.get(PPath.SNAP_X);
// int snapY = path.get(PPath.SNAP_Y);
// writePoint(writer, "snap", new Point(snapX, snapY));
// }
// writer.endElement();
// }
//
// @Override
// public Path read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// Path path = new Path();
//
// reader.enterElement("path");
// {
// readIdAttribute(path, reader);
// reader.enterElement("points");
// while (reader.hasNextElement()) {
// reader.enterElement("point");
// PathPoint pp = path.addPoint();
// pp.setX(reader.getIntAttribute("x"));
// pp.setY(reader.getIntAttribute("y"));
// pp.setSpeed(reader.getIntAttribute("speed"));
// reader.leaveElement();
// }
// reader.leaveElement();
// String backgroundRoomRef = readResourceRef(reader, "backgroundRoom");
// DeferredReferenceCreator rc = new DeferredPropertyReferenceCreator<PPath>(
// path.properties, PPath.BACKGROUND_ROOM, Room.class, backgroundRoomRef);
// notifier.addDeferredReferenceCreator(rc);
// path.put(PPath.CLOSED, reader.getBoolElement("closed"));
// path.put(PPath.PRECISION, reader.getIntElement("precision"));
// path.put(PPath.SMOOTH, reader.getBoolElement("smooth"));
//
// Point snap = readPoint(reader, "snap");
// path.put(PPath.SNAP_X, snap.x);
// path.put(PPath.SNAP_Y, snap.y);
// }
// reader.leaveElement();
// return path;
// }
// }
// Path: src/com/ganggarrison/gmdec/files/PathFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Path;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.PathXmlFormat;
/*
* Copyright (C) 2010 Medo <[email protected]>
*
* This file is part of GmkSplitter.
* GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package com.ganggarrison.gmdec.files;
public class PathFormat extends ResourceFormat<Path> {
@Override
public Path read(File filePath, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException { | Path path = new PathXmlFormat().read(getXmlFile(filePath, entry), drcn); |
wmr513/reactive | threshold/java/threshold/AMQPConsumer.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon; | package threshold;
public class AMQPConsumer {
//actual response times
int lower = 0;
int upper = 0;
public void execute(String mode) throws Exception {
| // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: threshold/java/threshold/AMQPConsumer.java
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon;
package threshold;
public class AMQPConsumer {
//actual response times
int lower = 0;
int upper = 0;
public void execute(String mode) throws Exception {
| Channel channel = AMQPCommon.connect(); |
wmr513/reactive | workflow/java/workflow/AMQPWorkflowConsumer2.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon; | package workflow;
public class AMQPWorkflowConsumer2 {
public void execute() throws Exception { | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: workflow/java/workflow/AMQPWorkflowConsumer2.java
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon;
package workflow;
public class AMQPWorkflowConsumer2 {
public void execute() throws Exception { | Channel channel = AMQPCommon.connect(); |
wmr513/reactive | workflow/java/workflow/AMQPWorkflowProducer.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import java.util.Random;
import com.rabbitmq.client.Channel;
import common.AMQPCommon; | package workflow;
/**
* Continuously produce messages every 1 second
*/
public class AMQPWorkflowProducer {
public static void main(String[] args) throws Exception {
AMQPWorkflowProducer app = new AMQPWorkflowProducer();
app.produceMessages(args);
}
private void produceMessages(String[] args) throws Exception { | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: workflow/java/workflow/AMQPWorkflowProducer.java
import java.util.Random;
import com.rabbitmq.client.Channel;
import common.AMQPCommon;
package workflow;
/**
* Continuously produce messages every 1 second
*/
public class AMQPWorkflowProducer {
public static void main(String[] args) throws Exception {
AMQPWorkflowProducer app = new AMQPWorkflowProducer();
app.produceMessages(args);
}
private void produceMessages(String[] args) throws Exception { | Channel channel = AMQPCommon.connect(); |
wmr513/reactive | producercontrolflow/java/producerflow/AMQPContConsumer.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon; | package producerflow;
/**
* Continuously consume messages every 2 seconds
*/
public class AMQPContConsumer {
public static void main(String[] args) throws Exception { | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: producercontrolflow/java/producerflow/AMQPContConsumer.java
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon;
package producerflow;
/**
* Continuously consume messages every 2 seconds
*/
public class AMQPContConsumer {
public static void main(String[] args) throws Exception { | Channel channel = AMQPCommon.connect(); |
wmr513/reactive | monitor/java/monitor/AMQPMonitor.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import com.rabbitmq.client.Channel;
import common.AMQPCommon; | package monitor;
public class AMQPMonitor {
public static void main(String[] args) {
try { | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: monitor/java/monitor/AMQPMonitor.java
import com.rabbitmq.client.Channel;
import common.AMQPCommon;
package monitor;
public class AMQPMonitor {
public static void main(String[] args) {
try { | Channel channel = AMQPCommon.connect(); |
wmr513/reactive | supervisor/java/supervisor/AMQPSupervisor.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import common.AMQPCommon; | package supervisor;
public class AMQPSupervisor {
private List<AMQPConsumer> consumers = new ArrayList<AMQPConsumer>();
Connection connection;
public void run(long keepAlive, boolean isSupervisor, long consumerCount) throws Exception {
System.out.println("Starting service");
if (isSupervisor) {
System.out.println("Starting supervisor");
} | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: supervisor/java/supervisor/AMQPSupervisor.java
import java.util.ArrayList;
import java.util.List;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import common.AMQPCommon;
package supervisor;
public class AMQPSupervisor {
private List<AMQPConsumer> consumers = new ArrayList<AMQPConsumer>();
Connection connection;
public void run(long keepAlive, boolean isSupervisor, long consumerCount) throws Exception {
System.out.println("Starting service");
if (isSupervisor) {
System.out.println("Starting supervisor");
} | Channel channel = AMQPCommon.connect(); |
wmr513/reactive | threshold/java/threshold/AMQPProducer.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon; | package threshold;
//timer is usually timestamp, but in this demo it is the number of messages due to
//the long times when things get worse
public class AMQPProducer {
long low = 0;
long current = 1000;
long high = 0;
long timerSec = 10;
long startTimer = System.currentTimeMillis();
long tradeCount = 0;
long timeout = 10; //trigger timeout after 10 trades with no adjustment
List<Long> durations = new ArrayList<Long>();
List<Long> highDurations = new ArrayList<Long>();
double mean = 0;
Channel channel = null;
public void execute(String mode) throws Exception { | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: threshold/java/threshold/AMQPProducer.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon;
package threshold;
//timer is usually timestamp, but in this demo it is the number of messages due to
//the long times when things get worse
public class AMQPProducer {
long low = 0;
long current = 1000;
long high = 0;
long timerSec = 10;
long startTimer = System.currentTimeMillis();
long tradeCount = 0;
long timeout = 10; //trigger timeout after 10 trades with no adjustment
List<Long> durations = new ArrayList<Long>();
List<Long> highDurations = new ArrayList<Long>();
double mean = 0;
Channel channel = null;
public void execute(String mode) throws Exception { | channel = AMQPCommon.connect(); |
wmr513/reactive | threaddelegate/java/threaddelegate/Sender.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import java.util.Random;
import com.rabbitmq.client.Channel;
import common.AMQPCommon; | package threaddelegate;
public class Sender {
public static void main(String[] args) throws Exception {
Sender app = new Sender();
app.produceMessages();
System.exit(0);
}
private void produceMessages() throws Exception { | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: threaddelegate/java/threaddelegate/Sender.java
import java.util.Random;
import com.rabbitmq.client.Channel;
import common.AMQPCommon;
package threaddelegate;
public class Sender {
public static void main(String[] args) throws Exception {
Sender app = new Sender();
app.produceMessages();
System.exit(0);
}
private void produceMessages() throws Exception { | Channel channel = AMQPCommon.connect(); |
wmr513/reactive | producercontrolflow/java/producerflow/AMQPFlowMonitor.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import com.rabbitmq.client.Channel;
import common.AMQPCommon; | package producerflow;
public class AMQPFlowMonitor {
public void run() throws Exception { | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: producercontrolflow/java/producerflow/AMQPFlowMonitor.java
import com.rabbitmq.client.Channel;
import common.AMQPCommon;
package producerflow;
public class AMQPFlowMonitor {
public void run() throws Exception { | Channel channel = AMQPCommon.connect(); |
wmr513/reactive | producercontrolflow/java/producerflow/AMQPContProducer.java | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
| import java.util.Random;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon; | package producerflow;
/**
* Continuously produce messages every 1 second based on delay value
*/
public class AMQPContProducer {
private Long delay = 1000l;
private Connection connection;
public static void main(String[] args) throws Exception {
AMQPContProducer app = new AMQPContProducer(); | // Path: common/java/common/AMQPCommon.java
// public class AMQPCommon {
//
// public static Channel connect() throws Exception {
// ConnectionFactory factory = new ConnectionFactory();
// factory.setHost("127.0.0.1");
// factory.setPort(32768);
// Connection conn = factory.newConnection();
// return conn.createChannel();
// }
//
// public static void close(Channel channel) throws Exception {
// channel.close();
// channel.getConnection().close();
// }
//
// }
// Path: producercontrolflow/java/producerflow/AMQPContProducer.java
import java.util.Random;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.QueueingConsumer;
import common.AMQPCommon;
package producerflow;
/**
* Continuously produce messages every 1 second based on delay value
*/
public class AMQPContProducer {
private Long delay = 1000l;
private Connection connection;
public static void main(String[] args) throws Exception {
AMQPContProducer app = new AMQPContProducer(); | app.connection = AMQPCommon.connect().getConnection(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.