Merge branch 'master' into bug2822_boatcolors

This commit is contained in:
Steffen Schäfer
2017-05-16 16:12:16 +02:00
2774 changed files with 302070 additions and 302070 deletions
+54 -54
View File
@@ -1,54 +1,54 @@
#!/bin/bash
# You need an installation of the Mars release of "Eclipse IDE for Eclipse Committers" matching you OS and JDK (32 vs 64 Bit):
# http://www.eclipse.org/downloads/packages/eclipse-ide-eclipse-committers/marsr
if [[ $1 == "" ]]; then
echo "You need to specify the Eclipse installation directory"
exit 1
fi
installPath="$1"
installPlugins() {
"$installPath/eclipse" -application org.eclipse.equinox.p2.director -noSplash -roaming -repository $1 -installIU $2
echo ""
}
updatePlugins() {
"$installPath/eclipse" -application org.eclipse.equinox.p2.director -noSplash -roaming -repository $1 -uninstallIU $2 -installIU $2
echo ""
}
# Not necessary if using Eclipse for JEE developers
echo "Installing webtools (WTP/WST/JPT) and m2e that are required by the GWT plugin..."
installPlugins http://download.eclipse.org/releases/mars org.eclipse.wst.web_ui.feature.feature.group,org.eclipse.jst.web_ui.feature.feature.group,org.eclipse.wst.xml_ui.feature.feature.group,org.eclipse.jpt.common.feature.feature.group,org.eclipse.jpt.jpa.feature.feature.group,org.eclipse.m2e.feature.feature.group,org.eclipse.m2e.wtp.feature.feature.group
echo "Installing GWT plugin..."
installPlugins http://storage.googleapis.com/gwt-eclipse-plugin/release com.google.gdt.eclipse.suite.e44.feature.feature.group
echo "Installing Android Tools..."
installPlugins https://dl-ssl.google.com/android/eclipse com.android.ide.eclipse.adt.feature.feature.group
echo "Installing GWT SDM debug bridge..."
installPlugins http://p2.sapsailing.com/p2/sdbg com.github.sdbg.feature.feature.group
echo "Installing EasyShell..."
installPlugins http://anb0s.github.io/EasyShell com.tetrade.eclipse.plugins.easyshell.feature.feature.group
echo "Installing BIRT charts (requirement for MAT)..."
installPlugins http://download.eclipse.org/birt/update-site/4.6 org.eclipse.birt.chart.feature.group
echo "Installing Memory Analyzer..."
installPlugins http://download.eclipse.org/mat/1.6/update-site/ org.eclipse.mat.feature.feature.group,org.eclipse.mat.chart.feature.feature.group
echo "Installing latest version of Code Recommenders ..."
updatePlugins http://download.eclipse.org/recommenders/updates/stable/ org.eclipse.recommenders.rcp.feature.feature.group,org.eclipse.recommenders.mylyn.rcp.feature.feature.group,org.eclipse.recommenders.snipmatch.rcp.feature.feature.group
echo "Installing latest version of EGit ..."
updatePlugins http://download.eclipse.org/egit/updates org.eclipse.jgit.feature.group,org.eclipse.jgit.http.apache.feature.group,org.eclipse.egit.feature.group,org.eclipse.egit.mylyn.feature.group
echo "Installing latest version of Mylyn ..."
updatePlugins http://download.eclipse.org/mylyn/releases/latest org.eclipse.mylyn_feature.feature.group,org.eclipse.mylyn.bugzilla_feature.feature.group,org.eclipse.mylyn.builds.feature.group,org.eclipse.mylyn.commons.feature.group,org.eclipse.mylyn.commons.identity.feature.group,org.eclipse.mylyn.commons.notifications.feature.group,org.eclipse.mylyn.commons.repositories.feature.group,org.eclipse.mylyn.commons.repositories.http.feature.group,org.eclipse.mylyn.context_feature.feature.group,org.eclipse.mylyn.discovery.feature.group,org.eclipse.mylyn.gerrit.feature.feature.group,org.eclipse.mylyn.git.feature.group,org.eclipse.mylyn.hudson.feature.group,org.eclipse.mylyn.java_feature.feature.group,org.eclipse.mylyn.monitor.feature.group,org.eclipse.mylyn.reviews.feature.feature.group,org.eclipse.mylyn.team_feature.feature.group,org.eclipse.mylyn.versions.feature.group,org.eclipse.mylyn.wikitext_feature.feature.group
echo "Installation completed!"
#!/bin/bash
# You need an installation of the Mars release of "Eclipse IDE for Eclipse Committers" matching you OS and JDK (32 vs 64 Bit):
# http://www.eclipse.org/downloads/packages/eclipse-ide-eclipse-committers/marsr
if [[ $1 == "" ]]; then
echo "You need to specify the Eclipse installation directory"
exit 1
fi
installPath="$1"
installPlugins() {
"$installPath/eclipse" -application org.eclipse.equinox.p2.director -noSplash -roaming -repository $1 -installIU $2
echo ""
}
updatePlugins() {
"$installPath/eclipse" -application org.eclipse.equinox.p2.director -noSplash -roaming -repository $1 -uninstallIU $2 -installIU $2
echo ""
}
# Not necessary if using Eclipse for JEE developers
echo "Installing webtools (WTP/WST/JPT) and m2e that are required by the GWT plugin..."
installPlugins http://download.eclipse.org/releases/mars org.eclipse.wst.web_ui.feature.feature.group,org.eclipse.jst.web_ui.feature.feature.group,org.eclipse.wst.xml_ui.feature.feature.group,org.eclipse.jpt.common.feature.feature.group,org.eclipse.jpt.jpa.feature.feature.group,org.eclipse.m2e.feature.feature.group,org.eclipse.m2e.wtp.feature.feature.group
echo "Installing GWT plugin..."
installPlugins http://storage.googleapis.com/gwt-eclipse-plugin/release com.google.gdt.eclipse.suite.e44.feature.feature.group
echo "Installing Android Tools..."
installPlugins https://dl-ssl.google.com/android/eclipse com.android.ide.eclipse.adt.feature.feature.group
echo "Installing GWT SDM debug bridge..."
installPlugins http://p2.sapsailing.com/p2/sdbg com.github.sdbg.feature.feature.group
echo "Installing EasyShell..."
installPlugins http://anb0s.github.io/EasyShell com.tetrade.eclipse.plugins.easyshell.feature.feature.group
echo "Installing BIRT charts (requirement for MAT)..."
installPlugins http://download.eclipse.org/birt/update-site/4.6 org.eclipse.birt.chart.feature.group
echo "Installing Memory Analyzer..."
installPlugins http://download.eclipse.org/mat/1.6/update-site/ org.eclipse.mat.feature.feature.group,org.eclipse.mat.chart.feature.feature.group
echo "Installing latest version of Code Recommenders ..."
updatePlugins http://download.eclipse.org/recommenders/updates/stable/ org.eclipse.recommenders.rcp.feature.feature.group,org.eclipse.recommenders.mylyn.rcp.feature.feature.group,org.eclipse.recommenders.snipmatch.rcp.feature.feature.group
echo "Installing latest version of EGit ..."
updatePlugins http://download.eclipse.org/egit/updates org.eclipse.jgit.feature.group,org.eclipse.jgit.http.apache.feature.group,org.eclipse.egit.feature.group,org.eclipse.egit.mylyn.feature.group
echo "Installing latest version of Mylyn ..."
updatePlugins http://download.eclipse.org/mylyn/releases/latest org.eclipse.mylyn_feature.feature.group,org.eclipse.mylyn.bugzilla_feature.feature.group,org.eclipse.mylyn.builds.feature.group,org.eclipse.mylyn.commons.feature.group,org.eclipse.mylyn.commons.identity.feature.group,org.eclipse.mylyn.commons.notifications.feature.group,org.eclipse.mylyn.commons.repositories.feature.group,org.eclipse.mylyn.commons.repositories.http.feature.group,org.eclipse.mylyn.context_feature.feature.group,org.eclipse.mylyn.discovery.feature.group,org.eclipse.mylyn.gerrit.feature.feature.group,org.eclipse.mylyn.git.feature.group,org.eclipse.mylyn.hudson.feature.group,org.eclipse.mylyn.java_feature.feature.group,org.eclipse.mylyn.monitor.feature.group,org.eclipse.mylyn.reviews.feature.feature.group,org.eclipse.mylyn.team_feature.feature.group,org.eclipse.mylyn.versions.feature.group,org.eclipse.mylyn.wikitext_feature.feature.group
echo "Installation completed!"
+40 -40
View File
@@ -1,40 +1,40 @@
<settings>
<servers>
<server>
<id>ssh-repository</id>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
</servers>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.wdf.sap.corp</host>
<port>8080</port>
<nonProxyHosts>localhost|*.sap.corp</nonProxyHosts>
</proxy>
</proxies>
<profiles>
<profile>
<id>sailing.analytics</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Leave empty, if no proxy is needed in your environment! -->
<parameters.proxy>
-Dhttp.proxyHost=proxy.wdf.sap.corp -Dhttp.proxyPort=8080
</parameters.proxy>
<!-- Change the configuration file to the one you like to use for the tests. -->
<parameters.integration-tests>
-Dselenium.test.environment.configuration=ci-test-environment.xml -Dmongo.dbName=winddbTest -DspatialWind=true
</parameters.integration-tests>
</properties>
</profile>
</profiles>
</settings>
<settings>
<servers>
<server>
<id>ssh-repository</id>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
</servers>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.wdf.sap.corp</host>
<port>8080</port>
<nonProxyHosts>localhost|*.sap.corp</nonProxyHosts>
</proxy>
</proxies>
<profiles>
<profile>
<id>sailing.analytics</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Leave empty, if no proxy is needed in your environment! -->
<parameters.proxy>
-Dhttp.proxyHost=proxy.wdf.sap.corp -Dhttp.proxyPort=8080
</parameters.proxy>
<!-- Change the configuration file to the one you like to use for the tests. -->
<parameters.integration-tests>
-Dselenium.test.environment.configuration=ci-test-environment.xml -Dmongo.dbName=winddbTest -DspatialWind=true
</parameters.integration-tests>
</properties>
</profile>
</profiles>
</settings>
+39 -39
View File
@@ -1,39 +1,39 @@
<settings>
<servers>
<server>
<id>ssh-repository</id>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
</servers>
<proxies>
<proxy>
<active>false</active>
<protocol>http</protocol>
<host>proxy.wdf.sap.corp</host>
<port>8080</port>
<nonProxyHosts>localhost|*.sap.corp</nonProxyHosts>
</proxy>
</proxies>
<profiles>
<profile>
<id>sailing.analytics</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Leave empty, if no proxy is needed in your environment! -->
<parameters.proxy>
</parameters.proxy>
<!-- Change the configuration file to the one you like to use for the tests. -->
<parameters.integration-tests>
-Dselenium.test.environment.configuration=ci-test-environment.xml -Dmongo.dbName=winddbTest -DspatialWind=true
</parameters.integration-tests>
</properties>
</profile>
</profiles>
</settings>
<settings>
<servers>
<server>
<id>ssh-repository</id>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
</servers>
<proxies>
<proxy>
<active>false</active>
<protocol>http</protocol>
<host>proxy.wdf.sap.corp</host>
<port>8080</port>
<nonProxyHosts>localhost|*.sap.corp</nonProxyHosts>
</proxy>
</proxies>
<profiles>
<profile>
<id>sailing.analytics</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Leave empty, if no proxy is needed in your environment! -->
<parameters.proxy>
</parameters.proxy>
<!-- Change the configuration file to the one you like to use for the tests. -->
<parameters.integration-tests>
-Dselenium.test.environment.configuration=ci-test-environment.xml -Dmongo.dbName=winddbTest -DspatialWind=true
</parameters.integration-tests>
</properties>
</profile>
</profiles>
</settings>
+13 -13
View File
@@ -1,13 +1,13 @@
#!/bin/bash
export JAVA_HOME=/home/trac/jdk1.7.0_02
jar=`find plugins -name 'com.sap.sailing.expeditionconnector_*.jar' | sort | tail -1`
echo Using JAR file $jar
if [ $# -eq 0 ]; then
ARGS="-v 2012 localhost 2010 localhost 2011 localhost 2013 localhost 2014"
else
ARGS=$*
fi
echo "Using $ARGS"
java -cp "$jar" -Djava.util.logging.config.file=udpmirrorLog.properties com.sap.sailing.expeditionconnector.UDPMirror $ARGS
#!/bin/bash
export JAVA_HOME=/home/trac/jdk1.7.0_02
jar=`find plugins -name 'com.sap.sailing.expeditionconnector_*.jar' | sort | tail -1`
echo Using JAR file $jar
if [ $# -eq 0 ]; then
ARGS="-v 2012 localhost 2010 localhost 2011 localhost 2013 localhost 2014"
else
ARGS=$*
fi
echo "Using $ARGS"
java -cp "$jar" -Djava.util.logging.config.file=udpmirrorLog.properties com.sap.sailing.expeditionconnector.UDPMirror $ARGS
+136 -136
View File
@@ -1,136 +1,136 @@
Logging in:
http://tracms.germanmaster.traclive.dk
Username: baur@sailing-team-germany.de
Password: MarcusBaur
Tracking devices have some kind of an "expiry date" when attached to a
mark. As a clean-up measure, Jakob had to reset some of these expiry
dates.
One database for one "event." Start/end is the start/end date of the
whole regatta. Tracking data received is keyed by time and tracker
association. Only if it's inside the event window the tracker data is
accepted. If a tracker is associated with an event, it's data is
recorded, even if not yet associated with an object. Later, the
tracker may be associated with an object, associating its track with
that object. This way it's possible to recover from various types of
"situations."
Edit an event. As a club event it has a long duration.
Courses - Marks/waypoints:
Show advanced: Tracking device session. Shows tracking device
association to the mark for a time frame. A tracking device cannot be
used for other marks if it is still associated for the time frame
under consideration with another object. Before re-using a tracking
device for a time frame, it must be disassociated with all other
objects for that time frame.
Create a new mark:
Mark's short name must not be longer than two characters. It's
currently not possible to associate trackers to marks if the trackers
are associated to *any* other object with *any* time frame. We
currently have to re-use existing mark definitions because of this
problem.
A mark can also be created without tracking devices associated. Then
show the advanced page for the tracking device. There we can set the
start/end time, and all trackers not associated during this period
should become available for selection / association.
Create a course:
New course, give it a name. Choose "Mark/Waypoint" as Course Type. Add
marks (control points) as waypoint. Can be updated while the race is
on, but marks have to be in the course before the first boat passes
this mark.
Inserting a mark first always appends it to the end. Then, drag&drop
is possible to move it to the desired position in the waypoint
list. Afterwards, "Update" needs to be pressed.
When waypoint data is changed too late, tracking data needs to be
re-run through the system to update the mark passings. This can only
be done by TracTrac administrators.
A course needs to be associated to a race. You cannot have the same
course associated with many races. But a new course's waypoints can be
copied from any other existing course.
Race:
New race; give it a name. Enter start of tracking, end of tracking,
start of race. Times are all UTC. Start of race needs to be between
start and end of tracking. Choose the (default) course. Start of race
can only be entered later, when known. Don't try to change the
course-race association. Edit the course instead. It's a 1:1
association between race and course anyhow since courses cannot
directly be re-used (only copied) in a different race.
Checkbox "Populate start and endtime to entries" means that race
timing is applied to the tracking device sessions associated with the
race.
Editing entries (competitors) information:
It's possible to import from "another race" which typically happens
for fleet races. Competitor information can also be imported from CSV
files. Field names: Short name, Last name, Nationality, Class, Team,
External ID, Tracking device, Picture. Don't use special characters in
the boat class name.
Boat classes and pictures can be maintained under the "Details" menu.
A tracker can be substituted in the Entries page, clicking the
"Replace" button next to the tracking device number, entering a UTC
time for when the replacement shall become effective. If mark passings
have happened in between, mark passings either need to be entered
manually or TracTrac administrators can re-run the data by the mark
passing algorithm.
Manually enter a mark passing:
Go to the races page. Press the SailMarks button (red container). In
the popup dialog the mark passing times can be manually
entered. Automatically-detected mark passings will automatically
update if the algorithm detects a better candidate for the mark
passing. Manually entered mark passings may be overwritten by the
algorithm, also during a re-run.
Replacing a tracker on a mark: click the replace button next to a mark
in the marks list.
Monitoring page:
When the battery indicator shows a dying battery, we can schedule a
planned replacement.
Send interval configuration: Clicking the checkbox next to the device
in the monitoring page enables sending an SMS to the device. For this,
we need to inform TracTrac about which SIM card with which phone
number went into which tracker. This can be provided in a CSV file
that has the format "tracker-ID;phone-number" where the phone number
starts with the country prefix, e.g. "1".
Green button will reboot the devices with checkmarks on. The device
rebooted will send all buffered information once back up.
A Teltonika command can be sent to all devices wich checkmark
set. "CF1;" "CF2;" and "CF3;" are the commands to send the device into
the respective mode. CF1 is most aggressive (quickest possible
sampling, sending out directly); CF2 sends every 15 seconds; CF3 sends
every 120 seconds.
Recharging a depleted battery takes about 3h. Batteries can be
replaced. It's a standard Nokia battery: BL-5C
- registering boat and mark trackers
- setting up the fleet
- defining the course with the marks
- setting and updating the start time
- fixing erroneous mark passing events
- updating a course before and during a race
Logging in:
http://tracms.germanmaster.traclive.dk
Username: baur@sailing-team-germany.de
Password: MarcusBaur
Tracking devices have some kind of an "expiry date" when attached to a
mark. As a clean-up measure, Jakob had to reset some of these expiry
dates.
One database for one "event." Start/end is the start/end date of the
whole regatta. Tracking data received is keyed by time and tracker
association. Only if it's inside the event window the tracker data is
accepted. If a tracker is associated with an event, it's data is
recorded, even if not yet associated with an object. Later, the
tracker may be associated with an object, associating its track with
that object. This way it's possible to recover from various types of
"situations."
Edit an event. As a club event it has a long duration.
Courses - Marks/waypoints:
Show advanced: Tracking device session. Shows tracking device
association to the mark for a time frame. A tracking device cannot be
used for other marks if it is still associated for the time frame
under consideration with another object. Before re-using a tracking
device for a time frame, it must be disassociated with all other
objects for that time frame.
Create a new mark:
Mark's short name must not be longer than two characters. It's
currently not possible to associate trackers to marks if the trackers
are associated to *any* other object with *any* time frame. We
currently have to re-use existing mark definitions because of this
problem.
A mark can also be created without tracking devices associated. Then
show the advanced page for the tracking device. There we can set the
start/end time, and all trackers not associated during this period
should become available for selection / association.
Create a course:
New course, give it a name. Choose "Mark/Waypoint" as Course Type. Add
marks (control points) as waypoint. Can be updated while the race is
on, but marks have to be in the course before the first boat passes
this mark.
Inserting a mark first always appends it to the end. Then, drag&drop
is possible to move it to the desired position in the waypoint
list. Afterwards, "Update" needs to be pressed.
When waypoint data is changed too late, tracking data needs to be
re-run through the system to update the mark passings. This can only
be done by TracTrac administrators.
A course needs to be associated to a race. You cannot have the same
course associated with many races. But a new course's waypoints can be
copied from any other existing course.
Race:
New race; give it a name. Enter start of tracking, end of tracking,
start of race. Times are all UTC. Start of race needs to be between
start and end of tracking. Choose the (default) course. Start of race
can only be entered later, when known. Don't try to change the
course-race association. Edit the course instead. It's a 1:1
association between race and course anyhow since courses cannot
directly be re-used (only copied) in a different race.
Checkbox "Populate start and endtime to entries" means that race
timing is applied to the tracking device sessions associated with the
race.
Editing entries (competitors) information:
It's possible to import from "another race" which typically happens
for fleet races. Competitor information can also be imported from CSV
files. Field names: Short name, Last name, Nationality, Class, Team,
External ID, Tracking device, Picture. Don't use special characters in
the boat class name.
Boat classes and pictures can be maintained under the "Details" menu.
A tracker can be substituted in the Entries page, clicking the
"Replace" button next to the tracking device number, entering a UTC
time for when the replacement shall become effective. If mark passings
have happened in between, mark passings either need to be entered
manually or TracTrac administrators can re-run the data by the mark
passing algorithm.
Manually enter a mark passing:
Go to the races page. Press the SailMarks button (red container). In
the popup dialog the mark passing times can be manually
entered. Automatically-detected mark passings will automatically
update if the algorithm detects a better candidate for the mark
passing. Manually entered mark passings may be overwritten by the
algorithm, also during a re-run.
Replacing a tracker on a mark: click the replace button next to a mark
in the marks list.
Monitoring page:
When the battery indicator shows a dying battery, we can schedule a
planned replacement.
Send interval configuration: Clicking the checkbox next to the device
in the monitoring page enables sending an SMS to the device. For this,
we need to inform TracTrac about which SIM card with which phone
number went into which tracker. This can be provided in a CSV file
that has the format "tracker-ID;phone-number" where the phone number
starts with the country prefix, e.g. "1".
Green button will reboot the devices with checkmarks on. The device
rebooted will send all buffered information once back up.
A Teltonika command can be sent to all devices wich checkmark
set. "CF1;" "CF2;" and "CF3;" are the commands to send the device into
the respective mode. CF1 is most aggressive (quickest possible
sampling, sending out directly); CF2 sends every 15 seconds; CF3 sends
every 120 seconds.
Recharging a depleted battery takes about 3h. Batteries can be
replaced. It's a standard Nokia battery: BL-5C
- registering boat and mark trackers
- setting up the fleet
- defining the course with the marks
- setting and updating the start time
- fixing erroneous mark passing events
- updating a course before and during a race
+75 -75
View File
@@ -1,75 +1,75 @@
Trac Trac accounts and their access parameters
Internationale Deutsche Meisterschaften
http://germanmaster.traclive.dk/events/event_20110929_Internatio/jsonservice.php
Sailing Team Germany
http://germanmaster.traclive.dk/events/event_20110505_SailingTea/jsonservice.php
Kieler Woche
http://germanmaster.traclive.dk/events/event_20110609_KielerWoch/jsonservice.php
Live-URI: tcp://germanmaster.traclive.dk:1520
Stored-URI: tcp://germanmaster.traclive.dk:1521
Arenal Training Camps Regatta 2012
http://germanmaster.traclive.dk/events/event_20120314_ArenalTrai/jsonservice.php
Live-URI: tcp://germanmaster.traclive.dk:1520
Stored-URI: tcp://germanmaster.traclive.dk:1521
SAP 2011 505 World Championship
http://germanmaster.traclive.dk/events/event_20110308_SAPWorldCh/jsonservice.php
Live-URI: tcp://germanmaster.traclive.dk:1520
Stored-URI: tcp://germanmaster.traclive.dk:1521
505 Worlds 2010
http://germanmaster.traclive.dk/events/event_20100725_OWorlds/jsonservice.php
Live-URI: tcp://germanmaster.traclive.dk:1520
Stored-URI: tcp://germanmaster.traclive.dk:1521
505 World Championship 2012:
http://germanmaster.traclive.dk/events/event_20120714_SAPWorldCh/jsonservice.php
Kieler Woche 2012:
http://germanmaster.traclive.dk/events/event_20120615_KielerWoch/jsonservice.php
http://germanmaster.traclive.dk/events/event_20120621_KielerWoch/jsonservice.php
http://germanmaster.traclive.dk/events/event_20120615_KielerWoch1/jsonservice.php
Extreme Sailing Series 2012:
http://germanmaster.traclive.dk/events/event_20120101_ExtremeSai/jsonservice.php
Extreme Sailing Series 2014:
http://secondary.traclive.dk/events/event_20140218_ESSSingapo/jsonservice.php
OBMR 2012:
http://germanmaster.traclive.dk/events/event_20121031_OBMR/jsonservice.php
Academy Tracking 2011:
http://germanmaster.traclive.dk/events/event_20110505_SailingTea/jsonservice.php
Academy Tracking 2012:
http://germanmaster.traclive.dk/events/event_20120501_SailingTea/jsonservice.php
BMW Cup:
http://kml.skitrac.traclive.dk/events/event_20120803_BMWCup/jsonservice.php
YES 2012:
http://germanmaster.traclive.dk/events/event_20120525_YES/jsonservice.php
IDM Drachen 2012:
http://kml.skitrac.traclive.dk/events/event_20120730_IDMDrachen/jsonservice.php
49er European Championship:
http://traclive.dk/events/event_20120905_erEuropean/jsonservice.php
RC44 Sweden Cup:
http://germanmaster.traclive.dk/events/event_20110815_RCSwedenCu/jsonservice.php
Extreme Sailing Series 2013:
Traclive
http://traclive.dk/events/event_20130302_ESSMuscat/jsonservice.php
Live: tcp://traclive.dk:44005
Stored: tcp://traclive.dk:44015
LocalServer
http://192.168.1.46/events/event_20130302_ESSMuscat/jsonservice.php
Live: tcp://192.168.1.46:4400
Stored: tcp://192.168.1.46:4401
Trac Trac accounts and their access parameters
Internationale Deutsche Meisterschaften
http://germanmaster.traclive.dk/events/event_20110929_Internatio/jsonservice.php
Sailing Team Germany
http://germanmaster.traclive.dk/events/event_20110505_SailingTea/jsonservice.php
Kieler Woche
http://germanmaster.traclive.dk/events/event_20110609_KielerWoch/jsonservice.php
Live-URI: tcp://germanmaster.traclive.dk:1520
Stored-URI: tcp://germanmaster.traclive.dk:1521
Arenal Training Camps Regatta 2012
http://germanmaster.traclive.dk/events/event_20120314_ArenalTrai/jsonservice.php
Live-URI: tcp://germanmaster.traclive.dk:1520
Stored-URI: tcp://germanmaster.traclive.dk:1521
SAP 2011 505 World Championship
http://germanmaster.traclive.dk/events/event_20110308_SAPWorldCh/jsonservice.php
Live-URI: tcp://germanmaster.traclive.dk:1520
Stored-URI: tcp://germanmaster.traclive.dk:1521
505 Worlds 2010
http://germanmaster.traclive.dk/events/event_20100725_OWorlds/jsonservice.php
Live-URI: tcp://germanmaster.traclive.dk:1520
Stored-URI: tcp://germanmaster.traclive.dk:1521
505 World Championship 2012:
http://germanmaster.traclive.dk/events/event_20120714_SAPWorldCh/jsonservice.php
Kieler Woche 2012:
http://germanmaster.traclive.dk/events/event_20120615_KielerWoch/jsonservice.php
http://germanmaster.traclive.dk/events/event_20120621_KielerWoch/jsonservice.php
http://germanmaster.traclive.dk/events/event_20120615_KielerWoch1/jsonservice.php
Extreme Sailing Series 2012:
http://germanmaster.traclive.dk/events/event_20120101_ExtremeSai/jsonservice.php
Extreme Sailing Series 2014:
http://secondary.traclive.dk/events/event_20140218_ESSSingapo/jsonservice.php
OBMR 2012:
http://germanmaster.traclive.dk/events/event_20121031_OBMR/jsonservice.php
Academy Tracking 2011:
http://germanmaster.traclive.dk/events/event_20110505_SailingTea/jsonservice.php
Academy Tracking 2012:
http://germanmaster.traclive.dk/events/event_20120501_SailingTea/jsonservice.php
BMW Cup:
http://kml.skitrac.traclive.dk/events/event_20120803_BMWCup/jsonservice.php
YES 2012:
http://germanmaster.traclive.dk/events/event_20120525_YES/jsonservice.php
IDM Drachen 2012:
http://kml.skitrac.traclive.dk/events/event_20120730_IDMDrachen/jsonservice.php
49er European Championship:
http://traclive.dk/events/event_20120905_erEuropean/jsonservice.php
RC44 Sweden Cup:
http://germanmaster.traclive.dk/events/event_20110815_RCSwedenCu/jsonservice.php
Extreme Sailing Series 2013:
Traclive
http://traclive.dk/events/event_20130302_ESSMuscat/jsonservice.php
Live: tcp://traclive.dk:44005
Stored: tcp://traclive.dk:44015
LocalServer
http://192.168.1.46/events/event_20130302_ESSMuscat/jsonservice.php
Live: tcp://192.168.1.46:4400
Stored: tcp://192.168.1.46:4401
Vendored
+90 -90
View File
@@ -1,90 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+5 -5
View File
@@ -1,5 +1,5 @@
#Fri Jul 29 09:33:48 CEST 2011
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
#Fri Jul 29 09:33:48 CEST 2011
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
+291 -291
View File
@@ -1,291 +1,291 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Spaces" version="12">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="8"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
</profile>
</profiles>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Spaces" version="12">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="8"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
</profile>
</profiles>
+7 -7
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/gwt-dev.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/gwt-dev.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+28 -28
View File
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.google.gwt.dev</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.google.gwt.dev</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
@@ -1,3 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
+3 -3
View File
@@ -1,3 +1,3 @@
bin.includes = META-INF/,\
.,\
lib/gwt-dev.jar
bin.includes = META-INF/,\
.,\
lib/gwt-dev.jar
+8 -8
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/gwt-servlet.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="lib" path="lib/gwt-servlet-deps.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/gwt-servlet.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="lib" path="lib/gwt-servlet-deps.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+28 -28
View File
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.google.gwt.servlet</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.google.gwt.servlet</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
@@ -1,3 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
+4 -4
View File
@@ -1,4 +1,4 @@
bin.includes = META-INF/,\
.,\
lib/gwt-servlet.jar,\
lib/gwt-servlet-deps.jar
bin.includes = META-INF/,\
.,\
lib/gwt-servlet.jar,\
lib/gwt-servlet-deps.jar
+7 -7
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/gwt-user.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/gwt-user.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+28 -28
View File
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.google.gwt.user</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.google.gwt.user</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
@@ -1,3 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
+3 -3
View File
@@ -1,3 +1,3 @@
bin.includes = META-INF/,\
.,\
lib/gwt-user.jar
bin.includes = META-INF/,\
.,\
lib/gwt-user.jar
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.googlecode.java-diff-utils.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.googlecode.java-diff-utils.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -1,5 +1,5 @@
#Fri Jul 29 09:33:56 CEST 2011
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
#Fri Jul 29 09:33:56 CEST 2011
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -1,4 +1,4 @@
#Fri Jun 10 10:54:00 CEST 2011
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
#Fri Jun 10 10:54:00 CEST 2011
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
@@ -1,6 +1,6 @@
source.. = src/
output.. = bin/,\
test
bin.includes = META-INF/,\
.,\
test/
source.. = src/
output.. = bin/,\
test
bin.includes = META-INF/,\
.,\
test/
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>root</artifactId>
<groupId>com.sap.sailing</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.googlecode.java-diff-utils.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>root</artifactId>
<groupId>com.sap.sailing</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.googlecode.java-diff-utils.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
</project>
@@ -1,27 +1,27 @@
package diffutils;
import java.io.File;
import java.util.List;
import difflib.DiffUtils;
import difflib.Patch;
import difflib.PatchFailedException;
public class ApplyPatch extends Example {
static final String FS = File.separator;
static final String ORIGINAL = "test" + FS + "mocks" + FS + "issue10_base.txt";
static final String PATCH = "test" + FS + "mocks" + FS + "issue10_patch.txt";
public static void main(String[] args) throws PatchFailedException {
List<String> original = fileToLines(ORIGINAL);
List<String> patched = fileToLines(PATCH);
// At first, parse the unified diff file and get the patch
Patch<String> patch = DiffUtils.parseUnifiedDiff(patched);
// Then apply the computed patch to the given text
List<String> result = DiffUtils.patch(original, patch);
System.out.println(result);
/// Or we can call patch.applyTo(original). There is no difference.
}
}
package diffutils;
import java.io.File;
import java.util.List;
import difflib.DiffUtils;
import difflib.Patch;
import difflib.PatchFailedException;
public class ApplyPatch extends Example {
static final String FS = File.separator;
static final String ORIGINAL = "test" + FS + "mocks" + FS + "issue10_base.txt";
static final String PATCH = "test" + FS + "mocks" + FS + "issue10_patch.txt";
public static void main(String[] args) throws PatchFailedException {
List<String> original = fileToLines(ORIGINAL);
List<String> patched = fileToLines(PATCH);
// At first, parse the unified diff file and get the patch
Patch<String> patch = DiffUtils.parseUnifiedDiff(patched);
// Then apply the computed patch to the given text
List<String> result = DiffUtils.patch(original, patch);
System.out.println(result);
/// Or we can call patch.applyTo(original). There is no difference.
}
}
@@ -1,26 +1,26 @@
package diffutils;
import java.io.File;
import java.util.List;
import difflib.Delta;
import difflib.DiffUtils;
import difflib.Patch;
public class ComputeDifference extends Example {
static final String FS = File.separator;
static final String ORIGINAL = "test" + FS + "mocks" + FS + "original.txt";
static final String REVISED = "test" + FS + "mocks" + FS + "revised.txt";
public static void main(String[] args) {
List<String> original = fileToLines(ORIGINAL);
List<String> revised = fileToLines(REVISED);
// Compute diff. Get the Patch object. Patch is the container for computed deltas.
Patch<String> patch = DiffUtils.diff(original, revised);
for (Delta<String> delta: patch.getDeltas()) {
System.out.println(delta);
}
}
}
package diffutils;
import java.io.File;
import java.util.List;
import difflib.Delta;
import difflib.DiffUtils;
import difflib.Patch;
public class ComputeDifference extends Example {
static final String FS = File.separator;
static final String ORIGINAL = "test" + FS + "mocks" + FS + "original.txt";
static final String REVISED = "test" + FS + "mocks" + FS + "revised.txt";
public static void main(String[] args) {
List<String> original = fileToLines(ORIGINAL);
List<String> revised = fileToLines(REVISED);
// Compute diff. Get the Patch object. Patch is the container for computed deltas.
Patch<String> patch = DiffUtils.diff(original, revised);
for (Delta<String> delta: patch.getDeltas()) {
System.out.println(delta);
}
}
}
@@ -1,61 +1,61 @@
package diffutils;
import difflib.*;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class DiffTest extends TestCase {
public void testDiff_Insert() {
final Patch<String> patch = DiffUtils.diff(Arrays.asList("hhh"), Arrays.asList("hhh", "jjj", "kkk"));
assertNotNull(patch);
assertEquals(1, patch.getDeltas().size());
final Delta<String> delta = patch.getDeltas().get(0);
assertEquals(InsertDelta.class, delta.getClass());
List<String> emptyList = Collections.emptyList();
assertEquals(new Chunk<String>(1, emptyList), delta.getOriginal());
assertEquals(new Chunk<String>(1, Arrays.asList("jjj", "kkk")), delta.getRevised());
}
public void testDiff_Delete() {
final Patch<String> patch = DiffUtils.diff(Arrays.asList("ddd", "fff", "ggg"), Arrays.asList("ggg"));
assertNotNull(patch);
assertEquals(1, patch.getDeltas().size());
final Delta<String> delta = patch.getDeltas().get(0);
assertEquals(DeleteDelta.class, delta.getClass());
assertEquals(new Chunk<String>(0, Arrays.asList("ddd", "fff")), delta.getOriginal());
List<String> emptyList = Collections.emptyList();
assertEquals(new Chunk<String>(0, emptyList), delta.getRevised());
}
public void testDiff_Change() {
final List<String> changeTest_from = Arrays.asList("aaa", "bbb", "ccc");
final List<String> changeTest_to = Arrays.asList("aaa", "zzz", "ccc");
final Patch<String> patch = DiffUtils.diff(changeTest_from, changeTest_to);
assertNotNull(patch);
assertEquals(1, patch.getDeltas().size());
final Delta<String> delta = patch.getDeltas().get(0);
assertEquals(ChangeDelta.class, delta.getClass());
assertEquals(new Chunk<String>(1, Arrays.asList("bbb")), delta.getOriginal());
assertEquals(new Chunk<String>(1, Arrays.asList("zzz")), delta.getRevised());
}
public void testDiff_EmptyList() {
final Patch<String> patch = DiffUtils.diff(new ArrayList<String>(), new ArrayList<String>());
assertNotNull(patch);
assertEquals(0, patch.getDeltas().size());
}
public void testDiff_EmptyListWithNonEmpty() {
final Patch<String> patch = DiffUtils.diff(new ArrayList<String>(), Arrays.asList("aaa"));
assertNotNull(patch);
assertEquals(1, patch.getDeltas().size());
final Delta<String> delta = patch.getDeltas().get(0);
assertEquals(InsertDelta.class, delta.getClass());
}
}
package diffutils;
import difflib.*;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class DiffTest extends TestCase {
public void testDiff_Insert() {
final Patch<String> patch = DiffUtils.diff(Arrays.asList("hhh"), Arrays.asList("hhh", "jjj", "kkk"));
assertNotNull(patch);
assertEquals(1, patch.getDeltas().size());
final Delta<String> delta = patch.getDeltas().get(0);
assertEquals(InsertDelta.class, delta.getClass());
List<String> emptyList = Collections.emptyList();
assertEquals(new Chunk<String>(1, emptyList), delta.getOriginal());
assertEquals(new Chunk<String>(1, Arrays.asList("jjj", "kkk")), delta.getRevised());
}
public void testDiff_Delete() {
final Patch<String> patch = DiffUtils.diff(Arrays.asList("ddd", "fff", "ggg"), Arrays.asList("ggg"));
assertNotNull(patch);
assertEquals(1, patch.getDeltas().size());
final Delta<String> delta = patch.getDeltas().get(0);
assertEquals(DeleteDelta.class, delta.getClass());
assertEquals(new Chunk<String>(0, Arrays.asList("ddd", "fff")), delta.getOriginal());
List<String> emptyList = Collections.emptyList();
assertEquals(new Chunk<String>(0, emptyList), delta.getRevised());
}
public void testDiff_Change() {
final List<String> changeTest_from = Arrays.asList("aaa", "bbb", "ccc");
final List<String> changeTest_to = Arrays.asList("aaa", "zzz", "ccc");
final Patch<String> patch = DiffUtils.diff(changeTest_from, changeTest_to);
assertNotNull(patch);
assertEquals(1, patch.getDeltas().size());
final Delta<String> delta = patch.getDeltas().get(0);
assertEquals(ChangeDelta.class, delta.getClass());
assertEquals(new Chunk<String>(1, Arrays.asList("bbb")), delta.getOriginal());
assertEquals(new Chunk<String>(1, Arrays.asList("zzz")), delta.getRevised());
}
public void testDiff_EmptyList() {
final Patch<String> patch = DiffUtils.diff(new ArrayList<String>(), new ArrayList<String>());
assertNotNull(patch);
assertEquals(0, patch.getDeltas().size());
}
public void testDiff_EmptyListWithNonEmpty() {
final Patch<String> patch = DiffUtils.diff(new ArrayList<String>(), Arrays.asList("aaa"));
assertNotNull(patch);
assertEquals(1, patch.getDeltas().size());
final Delta<String> delta = patch.getDeltas().get(0);
assertEquals(InsertDelta.class, delta.getClass());
}
}
@@ -1,24 +1,24 @@
package diffutils;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
public class Example {
public static List<String> fileToLines(String filename) {
List<String> lines = new LinkedList<String>();
String line = "";
try {
BufferedReader in = new BufferedReader(new FileReader(filename));
while ((line = in.readLine()) != null) {
lines.add(line);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
}
return lines;
}
}
package diffutils;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
public class Example {
public static List<String> fileToLines(String filename) {
List<String> lines = new LinkedList<String>();
String line = "";
try {
BufferedReader in = new BufferedReader(new FileReader(filename));
while ((line = in.readLine()) != null) {
lines.add(line);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
}
return lines;
}
}
@@ -1,129 +1,129 @@
package diffutils;
import difflib.DiffUtils;
import difflib.Patch;
import difflib.PatchFailedException;
import junit.framework.TestCase;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class GenerateUnifiedDiffTest extends TestCase {
private static final String FS = File.separator;
private static final String MOCK_FOLDER = "test" + FS + "mocks" + FS;
public List<String> fileToLines(String filename) {
List<String> lines = new LinkedList<String>();
String line = "";
try {
BufferedReader in = new BufferedReader(new FileReader(filename));
while ((line = in.readLine()) != null) {
lines.add(line);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
return lines;
}
public void testGenerateUnified() {
List<String> origLines = fileToLines(MOCK_FOLDER + "original.txt");
List<String> revLines = fileToLines(MOCK_FOLDER + "revised.txt");
verify(origLines, revLines, "original.txt", "revised.txt");
}
public void testGenerateUnifiedWithOneDelta() {
List<String> origLines = fileToLines(MOCK_FOLDER + "one_delta_test_original.txt");
List<String> revLines = fileToLines(MOCK_FOLDER + "one_delta_test_revised.txt");
verify(origLines, revLines, "one_delta_test_original.txt", "one_delta_test_revised.txt");
}
public void testGenerateUnifiedDiffWithoutAnyDeltas() {
List<String> test = Arrays.asList("abc");
Patch<String> patch = DiffUtils.diff(test, test);
DiffUtils.generateUnifiedDiff("abc", "abc", test, patch, 0);
}
public void testDiff_Issue10() {
final List<String> baseLines = fileToLines(MOCK_FOLDER + "issue10_base.txt");
final List<String> patchLines = fileToLines(MOCK_FOLDER + "issue10_patch.txt");
final Patch<String> p = DiffUtils.parseUnifiedDiff(patchLines);
try {
DiffUtils.patch(baseLines, p);
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
/**
* Issue 12
*/
public void testPatchWithNoDeltas() {
final List<String> lines1 = fileToLines(MOCK_FOLDER + "issue11_1.txt");
final List<String> lines2 = fileToLines(MOCK_FOLDER + "issue11_2.txt");
verify(lines1, lines2, "issue11_1.txt", "issue11_2.txt");
}
public void testDiff5() {
final List<String> lines1 = fileToLines(MOCK_FOLDER + "5A.txt");
final List<String> lines2 = fileToLines(MOCK_FOLDER + "5B.txt");
verify(lines1, lines2, "5A.txt", "5B.txt");
}
/**
* Issue 19
*/
public void testDiffWithHeaderLineInText() {
List<String> original = new ArrayList<String>();
List<String> revised = new ArrayList<String>();
original.add("test line1");
original.add("test line2");
original.add("test line 4");
original.add("test line 5");
revised.add("test line1");
revised.add("test line2");
revised.add("@@ -2,6 +2,7 @@");
revised.add("test line 4");
revised.add("test line 5");
Patch<String> patch = DiffUtils.diff(original, revised);
List<String> udiff = DiffUtils.generateUnifiedDiff("original", "revised",
original, patch, 10);
DiffUtils.parseUnifiedDiff(udiff);
}
private void verify(List<String> origLines, List<String> revLines,
String originalFile, String revisedFile) {
Patch<String> patch = DiffUtils.diff(origLines, revLines);
List<String> unifiedDiff = DiffUtils.generateUnifiedDiff(originalFile, revisedFile,
origLines, patch, 10);
Patch<String> fromUnifiedPatch = DiffUtils.parseUnifiedDiff(unifiedDiff);
List<String> patchedLines;
try {
patchedLines = (List<String>) fromUnifiedPatch.applyTo(origLines);
assertTrue(revLines.size() == patchedLines.size());
for (int i = 0; i < revLines.size(); i++) {
String l1 = revLines.get(i);
String l2 = patchedLines.get(i);
if (!l1.equals(l2)) {
fail("Line " + (i + 1) + " of the patched file did not match the revised original");
}
}
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
}
package diffutils;
import difflib.DiffUtils;
import difflib.Patch;
import difflib.PatchFailedException;
import junit.framework.TestCase;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class GenerateUnifiedDiffTest extends TestCase {
private static final String FS = File.separator;
private static final String MOCK_FOLDER = "test" + FS + "mocks" + FS;
public List<String> fileToLines(String filename) {
List<String> lines = new LinkedList<String>();
String line = "";
try {
BufferedReader in = new BufferedReader(new FileReader(filename));
while ((line = in.readLine()) != null) {
lines.add(line);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
return lines;
}
public void testGenerateUnified() {
List<String> origLines = fileToLines(MOCK_FOLDER + "original.txt");
List<String> revLines = fileToLines(MOCK_FOLDER + "revised.txt");
verify(origLines, revLines, "original.txt", "revised.txt");
}
public void testGenerateUnifiedWithOneDelta() {
List<String> origLines = fileToLines(MOCK_FOLDER + "one_delta_test_original.txt");
List<String> revLines = fileToLines(MOCK_FOLDER + "one_delta_test_revised.txt");
verify(origLines, revLines, "one_delta_test_original.txt", "one_delta_test_revised.txt");
}
public void testGenerateUnifiedDiffWithoutAnyDeltas() {
List<String> test = Arrays.asList("abc");
Patch<String> patch = DiffUtils.diff(test, test);
DiffUtils.generateUnifiedDiff("abc", "abc", test, patch, 0);
}
public void testDiff_Issue10() {
final List<String> baseLines = fileToLines(MOCK_FOLDER + "issue10_base.txt");
final List<String> patchLines = fileToLines(MOCK_FOLDER + "issue10_patch.txt");
final Patch<String> p = DiffUtils.parseUnifiedDiff(patchLines);
try {
DiffUtils.patch(baseLines, p);
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
/**
* Issue 12
*/
public void testPatchWithNoDeltas() {
final List<String> lines1 = fileToLines(MOCK_FOLDER + "issue11_1.txt");
final List<String> lines2 = fileToLines(MOCK_FOLDER + "issue11_2.txt");
verify(lines1, lines2, "issue11_1.txt", "issue11_2.txt");
}
public void testDiff5() {
final List<String> lines1 = fileToLines(MOCK_FOLDER + "5A.txt");
final List<String> lines2 = fileToLines(MOCK_FOLDER + "5B.txt");
verify(lines1, lines2, "5A.txt", "5B.txt");
}
/**
* Issue 19
*/
public void testDiffWithHeaderLineInText() {
List<String> original = new ArrayList<String>();
List<String> revised = new ArrayList<String>();
original.add("test line1");
original.add("test line2");
original.add("test line 4");
original.add("test line 5");
revised.add("test line1");
revised.add("test line2");
revised.add("@@ -2,6 +2,7 @@");
revised.add("test line 4");
revised.add("test line 5");
Patch<String> patch = DiffUtils.diff(original, revised);
List<String> udiff = DiffUtils.generateUnifiedDiff("original", "revised",
original, patch, 10);
DiffUtils.parseUnifiedDiff(udiff);
}
private void verify(List<String> origLines, List<String> revLines,
String originalFile, String revisedFile) {
Patch<String> patch = DiffUtils.diff(origLines, revLines);
List<String> unifiedDiff = DiffUtils.generateUnifiedDiff(originalFile, revisedFile,
origLines, patch, 10);
Patch<String> fromUnifiedPatch = DiffUtils.parseUnifiedDiff(unifiedDiff);
List<String> patchedLines;
try {
patchedLines = (List<String>) fromUnifiedPatch.applyTo(origLines);
assertTrue(revLines.size() == patchedLines.size());
for (int i = 0; i < revLines.size(); i++) {
String l1 = revLines.get(i);
String l2 = patchedLines.get(i);
if (!l1.equals(l2)) {
fail("Line " + (i + 1) + " of the patched file did not match the revised original");
}
}
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
}
@@ -1,64 +1,64 @@
package diffutils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import junit.framework.TestCase;
import difflib.DiffUtils;
import difflib.Patch;
import difflib.PatchFailedException;
public class PatchTest extends TestCase {
public void testPatch_Insert() {
final List<String> insertTest_from = Arrays.asList("hhh");
final List<String> insertTest_to = Arrays.asList("hhh", "jjj", "kkk", "lll");
final Patch<String> patch = DiffUtils.diff(insertTest_from, insertTest_to);
try {
assertEquals(insertTest_to, DiffUtils.patch(insertTest_from, patch));
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
public void testPatch_Delete() {
final List<String> deleteTest_from = Arrays.asList("ddd", "fff", "ggg", "hhh");
final List<String> deleteTest_to = Arrays.asList("ggg");
final Patch<String> patch = DiffUtils.diff(deleteTest_from, deleteTest_to);
try {
assertEquals(deleteTest_to, DiffUtils.patch(deleteTest_from, patch));
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
public void testPatch_Change() {
final List<String> changeTest_from = Arrays.asList("aaa", "bbb", "ccc", "ddd");
final List<String> changeTest_to = Arrays.asList("aaa", "bxb", "cxc", "ddd");
final Patch<String> patch = DiffUtils.diff(changeTest_from, changeTest_to);
try {
assertEquals(changeTest_to, DiffUtils.patch(changeTest_from, patch));
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
public void testPatch_EntirelyDifferent() {
final List<String> changeTest_from = new ArrayList<String>();
changeTest_from.add("aaa");
changeTest_from.add("bbb");
final List<String> changeTest_to = Arrays.asList("ccc", "ddd");
final Patch<String> patch = DiffUtils.diff(changeTest_from, changeTest_to);
try {
patch.applyToInPlace(changeTest_from);
assertEquals(changeTest_to, changeTest_from);
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
}
package diffutils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import junit.framework.TestCase;
import difflib.DiffUtils;
import difflib.Patch;
import difflib.PatchFailedException;
public class PatchTest extends TestCase {
public void testPatch_Insert() {
final List<String> insertTest_from = Arrays.asList("hhh");
final List<String> insertTest_to = Arrays.asList("hhh", "jjj", "kkk", "lll");
final Patch<String> patch = DiffUtils.diff(insertTest_from, insertTest_to);
try {
assertEquals(insertTest_to, DiffUtils.patch(insertTest_from, patch));
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
public void testPatch_Delete() {
final List<String> deleteTest_from = Arrays.asList("ddd", "fff", "ggg", "hhh");
final List<String> deleteTest_to = Arrays.asList("ggg");
final Patch<String> patch = DiffUtils.diff(deleteTest_from, deleteTest_to);
try {
assertEquals(deleteTest_to, DiffUtils.patch(deleteTest_from, patch));
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
public void testPatch_Change() {
final List<String> changeTest_from = Arrays.asList("aaa", "bbb", "ccc", "ddd");
final List<String> changeTest_to = Arrays.asList("aaa", "bxb", "cxc", "ddd");
final Patch<String> patch = DiffUtils.diff(changeTest_from, changeTest_to);
try {
assertEquals(changeTest_to, DiffUtils.patch(changeTest_from, patch));
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
public void testPatch_EntirelyDifferent() {
final List<String> changeTest_from = new ArrayList<String>();
changeTest_from.add("aaa");
changeTest_from.add("bbb");
final List<String> changeTest_to = Arrays.asList("ccc", "ddd");
final Patch<String> patch = DiffUtils.diff(changeTest_from, changeTest_to);
try {
patch.applyToInPlace(changeTest_from);
assertEquals(changeTest_to, changeTest_from);
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
}
@@ -1,372 +1,372 @@
#!/bin/bash
#
# Copyright (c) 2006 Johannes E. Schindelin
#
test_description='Test special whitespace in diff engine.
'
. ./test-lib.sh
. ../diff-lib.sh
# Ray Lehtiniemi's example
cat << EOF > x
do {
nothing;
} while (0);
EOF
git update-index --add x
cat << EOF > x
do
{
nothing;
}
while (0);
EOF
cat << EOF > expect
diff --git a/x b/x
index adf3937..6edc172 100644
--- a/x
+++ b/x
@@ -1,3 +1,5 @@
-do {
+do
+{
nothing;
-} while (0);
+}
+while (0);
EOF
git diff > out
test_expect_success "Ray's example without options" 'test_cmp expect out'
git diff -w > out
test_expect_success "Ray's example with -w" 'test_cmp expect out'
git diff -b > out
test_expect_success "Ray's example with -b" 'test_cmp expect out'
tr 'Q' '\015' << EOF > x
whitespace at beginning
whitespace change
whitespace in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git update-index x
tr '_' ' ' << EOF > x
whitespace at beginning
whitespace change
white space in the middle
whitespace at end__
unchanged line
CR at end
EOF
tr 'Q_' '\015 ' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
-whitespace change
-whitespace in the middle
-whitespace at end
+ whitespace at beginning
+whitespace change
+white space in the middle
+whitespace at end__
unchanged line
-CR at endQ
+CR at end
EOF
git diff > out
test_expect_success 'another test, without options' 'test_cmp expect out'
cat << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
EOF
git diff -w > out
test_expect_success 'another test, with -w' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
+ whitespace at beginning
whitespace change
-whitespace in the middle
+white space in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git diff -b > out
test_expect_success 'another test, with -b' 'test_cmp expect out'
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check with no whitespace errors' '
git commit -m "snapshot" &&
echo "foo();" > x &&
git diff --check
'
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
test_must_fail git diff --check
'
test_expect_success '--check and --exit-code are not exclusive' '
git checkout x &&
git diff --check --exit-code
'
test_expect_success '--check and --quiet are not exclusive' '
git diff --check --quiet
'
test_expect_success 'check staged with no whitespace errors' '
echo "foo();" > x &&
git add x &&
git diff --cached --check
'
test_expect_success 'check staged with trailing whitespace' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check staged with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --check HEAD
'
test_expect_success 'check with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check staged with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --cached --check HEAD
'
test_expect_success 'check staged with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check staged with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check with no whitespace errors (diff-tree)' '
echo "foo();" > x &&
git commit -m "new commit" x &&
git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with trailing whitespace (diff-tree)' '
echo "foo(); " > x &&
git commit -m "another commit" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with space before tab in indent (diff-tree)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check trailing whitespace (trailing-space: off)' '
git config core.whitespace "-trailing-space" &&
echo "foo (); " > x &&
git diff --check
'
test_expect_success 'check trailing whitespace (trailing-space: on)' '
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: off)' '
# indent contains space followed by HT
git config core.whitespace "-space-before-tab" &&
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: on)' '
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
git config core.whitespace "-indent-with-non-tab"
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'line numbers in --check output are correct' '
echo "" > x &&
echo "foo(); " >> x &&
git diff --check | grep "x:2:"
'
test_expect_success 'checkdiff detects trailing blank lines' '
echo "foo();" >x &&
echo "" >>x &&
git diff --check | grep "ends with blank"
'
test_expect_success 'checkdiff allows new blank lines' '
git checkout x &&
mv x y &&
(
echo "/* This is new */" &&
echo "" &&
cat y
) >x &&
git diff --check
'
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
echo >x hello &&
git commit -m "one side" x &&
git checkout HEAD^ &&
echo >x goodbye &&
git commit -m "the other side" x &&
git config core.autocrlf true &&
test_must_fail git merge master &&
git diff | sed -e "1,/^@@@/d" >actual &&
! grep "^-" actual
'
test_done
#!/bin/bash
#
# Copyright (c) 2006 Johannes E. Schindelin
#
test_description='Test special whitespace in diff engine.
'
. ./test-lib.sh
. ../diff-lib.sh
# Ray Lehtiniemi's example
cat << EOF > x
do {
nothing;
} while (0);
EOF
git update-index --add x
cat << EOF > x
do
{
nothing;
}
while (0);
EOF
cat << EOF > expect
diff --git a/x b/x
index adf3937..6edc172 100644
--- a/x
+++ b/x
@@ -1,3 +1,5 @@
-do {
+do
+{
nothing;
-} while (0);
+}
+while (0);
EOF
git diff > out
test_expect_success "Ray's example without options" 'test_cmp expect out'
git diff -w > out
test_expect_success "Ray's example with -w" 'test_cmp expect out'
git diff -b > out
test_expect_success "Ray's example with -b" 'test_cmp expect out'
tr 'Q' '\015' << EOF > x
whitespace at beginning
whitespace change
whitespace in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git update-index x
tr '_' ' ' << EOF > x
whitespace at beginning
whitespace change
white space in the middle
whitespace at end__
unchanged line
CR at end
EOF
tr 'Q_' '\015 ' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
-whitespace change
-whitespace in the middle
-whitespace at end
+ whitespace at beginning
+whitespace change
+white space in the middle
+whitespace at end__
unchanged line
-CR at endQ
+CR at end
EOF
git diff > out
test_expect_success 'another test, without options' 'test_cmp expect out'
cat << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
EOF
git diff -w > out
test_expect_success 'another test, with -w' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
+ whitespace at beginning
whitespace change
-whitespace in the middle
+white space in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git diff -b > out
test_expect_success 'another test, with -b' 'test_cmp expect out'
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check with no whitespace errors' '
git commit -m "snapshot" &&
echo "foo();" > x &&
git diff --check
'
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
test_must_fail git diff --check
'
test_expect_success '--check and --exit-code are not exclusive' '
git checkout x &&
git diff --check --exit-code
'
test_expect_success '--check and --quiet are not exclusive' '
git diff --check --quiet
'
test_expect_success 'check staged with no whitespace errors' '
echo "foo();" > x &&
git add x &&
git diff --cached --check
'
test_expect_success 'check staged with trailing whitespace' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check staged with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --check HEAD
'
test_expect_success 'check with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check staged with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --cached --check HEAD
'
test_expect_success 'check staged with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check staged with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check with no whitespace errors (diff-tree)' '
echo "foo();" > x &&
git commit -m "new commit" x &&
git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with trailing whitespace (diff-tree)' '
echo "foo(); " > x &&
git commit -m "another commit" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with space before tab in indent (diff-tree)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check trailing whitespace (trailing-space: off)' '
git config core.whitespace "-trailing-space" &&
echo "foo (); " > x &&
git diff --check
'
test_expect_success 'check trailing whitespace (trailing-space: on)' '
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: off)' '
# indent contains space followed by HT
git config core.whitespace "-space-before-tab" &&
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: on)' '
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
git config core.whitespace "-indent-with-non-tab"
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'line numbers in --check output are correct' '
echo "" > x &&
echo "foo(); " >> x &&
git diff --check | grep "x:2:"
'
test_expect_success 'checkdiff detects trailing blank lines' '
echo "foo();" >x &&
echo "" >>x &&
git diff --check | grep "ends with blank"
'
test_expect_success 'checkdiff allows new blank lines' '
git checkout x &&
mv x y &&
(
echo "/* This is new */" &&
echo "" &&
cat y
) >x &&
git diff --check
'
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
echo >x hello &&
git commit -m "one side" x &&
git checkout HEAD^ &&
echo >x goodbye &&
git commit -m "the other side" x &&
git config core.autocrlf true &&
test_must_fail git merge master &&
git diff | sed -e "1,/^@@@/d" >actual &&
! grep "^-" actual
'
test_done
@@ -1,381 +1,381 @@
#!/bin/bash
#
# Copyright (c) 2006 Johannes E. Schindelin
#
test_description='Test special whitespace in diff engine.
'
. ./test-lib.sh
. ../diff-lib.sh
# Ray Lehtiniemi's example
cat << EOF > x
do {
nothing;
} while (0);
EOF
git update-index --add x
cat << EOF > x
do
{
nothing;
}
while (0);
EOF
cat << EOF > expect
diff --git a/x b/x
index adf3937..6edc172 100644
--- a/x
+++ b/x
@@ -1,3 +1,5 @@
-do {
+do
+{
nothing;
-} while (0);
+}
+while (0);
EOF
git diff > out
test_expect_success "Ray's example without options" 'test_cmp expect out'
git diff -w > out
test_expect_success "Ray's example with -w" 'test_cmp expect out'
git diff -b > out
test_expect_success "Ray's example with -b" 'test_cmp expect out'
tr 'Q' '\015' << EOF > x
whitespace at beginning
whitespace change
whitespace in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git update-index x
tr '_' ' ' << EOF > x
whitespace at beginning
whitespace change
white space in the middle
whitespace at end__
unchanged line
CR at end
EOF
tr 'Q_' '\015 ' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
-whitespace change
-whitespace in the middle
-whitespace at end
+ whitespace at beginning
+whitespace change
+white space in the middle
+whitespace at end__
unchanged line
-CR at endQ
+CR at end
EOF
git diff > out
test_expect_success 'another test, without options' 'test_cmp expect out'
cat << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
EOF
git diff -w > out
test_expect_success 'another test, with -w' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
+ whitespace at beginning
whitespace change
-whitespace in the middle
+white space in the middle
whitespace at end
unchanged line
CR at endQ
git diff -b --ignore-space-at-eol > out
test_expect_failure 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
EOF
git diff -b > out
test_expect_success 'another test, with -b' 'test_cmp expect out'
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check with no whitespace errors' '
git commit -m "snapshot" &&
echo "foo();" > x &&
git diff --check
'
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
test_must_fail git diff --check
'
test_expect_success '--check and --exit-code are not exclusive' '
git checkout x &&
git diff --check --exit-code
'
test_expect_success '--check and --quiet are not exclusive' '
git diff --check --quiet
'
test_expect_success 'check staged with no whitespace errors' '
echo "foo();" > x &&
git add x &&
git diff --cached --check
'
test_expect_success 'check staged with trailing whitespace' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check staged with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --check HEAD
'
test_expect_success 'check with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check staged with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --cached --check HEAD
'
test_expect_success 'check staged with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check staged with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check with no whitespace errors (diff-tree)' '
echo "foo();" > x &&
git commit -m "new commit" x &&
git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with trailing whitespace (diff-tree)' '
echo "foo(); " > x &&
git commit -m "another commit" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with space before tab in indent (diff-tree)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check trailing whitespace (trailing-space: off)' '
git config core.whitespace "-trailing-space" &&
echo "foo (); " > x &&
git diff --check
'
test_expect_success 'check trailing whitespace (trailing-space: on)' '
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: off)' '
# indent contains space followed by HT
git config core.whitespace "-space-before-tab" &&
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: on)' '
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
git config core.whitespace "-indent-with-non-tab"
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'line numbers in --check output are correct' '
echo "" > x &&
echo "foo(); " >> x &&
git diff --check | grep "x:2:"
'
test_expect_success 'checkdiff detects trailing blank lines' '
echo "foo();" >x &&
echo "" >>x &&
git diff --check | grep "ends with blank"
'
test_expect_success 'checkdiff allows new blank lines' '
git checkout x &&
mv x y &&
(
echo "/* This is new */" &&
echo "" &&
cat y
) >x &&
git diff --check
'
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
echo >x hello &&
git commit -m "one side" x &&
git checkout HEAD^ &&
echo >x goodbye &&
git commit -m "the other side" x &&
git config core.autocrlf true &&
test_must_fail git merge master &&
git diff | sed -e "1,/^@@@/d" >actual &&
! grep "^-" actual
'
test_done
#!/bin/bash
#
# Copyright (c) 2006 Johannes E. Schindelin
#
test_description='Test special whitespace in diff engine.
'
. ./test-lib.sh
. ../diff-lib.sh
# Ray Lehtiniemi's example
cat << EOF > x
do {
nothing;
} while (0);
EOF
git update-index --add x
cat << EOF > x
do
{
nothing;
}
while (0);
EOF
cat << EOF > expect
diff --git a/x b/x
index adf3937..6edc172 100644
--- a/x
+++ b/x
@@ -1,3 +1,5 @@
-do {
+do
+{
nothing;
-} while (0);
+}
+while (0);
EOF
git diff > out
test_expect_success "Ray's example without options" 'test_cmp expect out'
git diff -w > out
test_expect_success "Ray's example with -w" 'test_cmp expect out'
git diff -b > out
test_expect_success "Ray's example with -b" 'test_cmp expect out'
tr 'Q' '\015' << EOF > x
whitespace at beginning
whitespace change
whitespace in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git update-index x
tr '_' ' ' << EOF > x
whitespace at beginning
whitespace change
white space in the middle
whitespace at end__
unchanged line
CR at end
EOF
tr 'Q_' '\015 ' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
-whitespace change
-whitespace in the middle
-whitespace at end
+ whitespace at beginning
+whitespace change
+white space in the middle
+whitespace at end__
unchanged line
-CR at endQ
+CR at end
EOF
git diff > out
test_expect_success 'another test, without options' 'test_cmp expect out'
cat << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
EOF
git diff -w > out
test_expect_success 'another test, with -w' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
+ whitespace at beginning
whitespace change
-whitespace in the middle
+white space in the middle
whitespace at end
unchanged line
CR at endQ
git diff -b --ignore-space-at-eol > out
test_expect_failure 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
EOF
git diff -b > out
test_expect_success 'another test, with -b' 'test_cmp expect out'
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check with no whitespace errors' '
git commit -m "snapshot" &&
echo "foo();" > x &&
git diff --check
'
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
test_must_fail git diff --check
'
test_expect_success '--check and --exit-code are not exclusive' '
git checkout x &&
git diff --check --exit-code
'
test_expect_success '--check and --quiet are not exclusive' '
git diff --check --quiet
'
test_expect_success 'check staged with no whitespace errors' '
echo "foo();" > x &&
git add x &&
git diff --cached --check
'
test_expect_success 'check staged with trailing whitespace' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check staged with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --check HEAD
'
test_expect_success 'check with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check staged with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --cached --check HEAD
'
test_expect_success 'check staged with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check staged with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check with no whitespace errors (diff-tree)' '
echo "foo();" > x &&
git commit -m "new commit" x &&
git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with trailing whitespace (diff-tree)' '
echo "foo(); " > x &&
git commit -m "another commit" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with space before tab in indent (diff-tree)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check trailing whitespace (trailing-space: off)' '
git config core.whitespace "-trailing-space" &&
echo "foo (); " > x &&
git diff --check
'
test_expect_success 'check trailing whitespace (trailing-space: on)' '
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: off)' '
# indent contains space followed by HT
git config core.whitespace "-space-before-tab" &&
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: on)' '
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
git config core.whitespace "-indent-with-non-tab"
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'line numbers in --check output are correct' '
echo "" > x &&
echo "foo(); " >> x &&
git diff --check | grep "x:2:"
'
test_expect_success 'checkdiff detects trailing blank lines' '
echo "foo();" >x &&
echo "" >>x &&
git diff --check | grep "ends with blank"
'
test_expect_success 'checkdiff allows new blank lines' '
git checkout x &&
mv x y &&
(
echo "/* This is new */" &&
echo "" &&
cat y
) >x &&
git diff --check
'
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
echo >x hello &&
git commit -m "one side" x &&
git checkout HEAD^ &&
echo >x goodbye &&
git commit -m "the other side" x &&
git config core.autocrlf true &&
test_must_fail git merge master &&
git diff | sed -e "1,/^@@@/d" >actual &&
! grep "^-" actual
'
test_done
@@ -1,46 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Python" name="Python">
<configuration sdkName="Python 2.7 (C:/Python27/python.exe)" />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 2.7 (C:/Python27/python.exe) interpreter library" level="application" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/commons-io-1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/java-diff-utils-1.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jython.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Python" name="Python">
<configuration sdkName="Python 2.7 (C:/Python27/python.exe)" />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 2.7 (C:/Python27/python.exe) interpreter library" level="application" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/commons-io-1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/java-diff-utils-1.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jython.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
@@ -1,10 +1,10 @@
--- /bonobo/bonobo.iml
+++ /bonobo/bonobo.iml
@@ -41,6 +40,7 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="library" name="Python 2.6.6 (/usr/bin/python2.6) interpreter library" level="application" />
</component>
</module>
--- /bonobo/bonobo.iml
+++ /bonobo/bonobo.iml
@@ -41,6 +40,7 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="library" name="Python 2.6.6 (/usr/bin/python2.6) interpreter library" level="application" />
</component>
</module>
@@ -1 +1 @@
svn: '77954' path not found
svn: '77954' path not found
@@ -1 +1 @@
svn: '77954' path not found
svn: '77954' path not found
@@ -1,54 +1,54 @@
<p>Esta &eacute; uma obra Online.</p>
<p>&nbsp;</p>
<p><strong>Este texto &eacute; negrito</strong></p>
<p><em>Este texto &eacute; it&aacute;lico</em></p>
<p><span style="text-decoration:underline;">Este texto est&aacute; sublinhado</span></p>
<p><span style="text-decoration: line-through;">Este texto est&aacute; riscado</span></p>
<p style="text-align: center;">Este texto est&aacute; centralizado</p>
<p style="text-align: right;">Este texto est&aacute; alinhado a direita</p>
<ol>
<li>Este texto est&aacute; em uma lista num&eacute;rica<ol>
<li>Este texto est&aacute; identado</li>
</ol></li>
</ol>
<p><a title="uol" href="http://www.uol.com.br" target="_blank">Este
aqui &eacute; um link</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>,
<p>&nbsp;</p>
<p>P&aacute;gina 1</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>P&aacute;gina 2</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>P&aacute;gina 3</p>
<p>Esta &eacute; uma obra Online.</p>
<p>&nbsp;</p>
<p><strong>Este texto &eacute; negrito</strong></p>
<p><em>Este texto &eacute; it&aacute;lico</em></p>
<p><span style="text-decoration:underline;">Este texto est&aacute; sublinhado</span></p>
<p><span style="text-decoration: line-through;">Este texto est&aacute; riscado</span></p>
<p style="text-align: center;">Este texto est&aacute; centralizado</p>
<p style="text-align: right;">Este texto est&aacute; alinhado a direita</p>
<ol>
<li>Este texto est&aacute; em uma lista num&eacute;rica<ol>
<li>Este texto est&aacute; identado</li>
</ol></li>
</ol>
<p><a title="uol" href="http://www.uol.com.br" target="_blank">Este
aqui &eacute; um link</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>,
<p>&nbsp;</p>
<p>P&aacute;gina 1</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>P&aacute;gina 2</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>P&aacute;gina 3</p>
<p>&nbsp;</p>
@@ -1,11 +1,11 @@
<p>Revis&atilde;o 3</p><p>&nbsp;</p><p>Esta &eacute; uma obra
Online.</p><p>&nbsp;</p><p><strong>Este texto &eacute;
negrit</strong></p><p>Este texto &eacute; it&aacute;lico/p><p><span
style="text-decoration: undeline;">Este texto est&aacute;
sublinhado</span></p><p>Este texto est&aacute; riscado agora n&atilde;o
est&aacute; mais</p>p style="text-align: left;">Este texto est&aacute;
centralizado nem este</p><p style="text-align: right;">Este texto
est&aacute; alinhado a direita</p><ol><li>Este texto est&aacute; em uma
lista num&eacute;rica</li></ol><p><a title="uol"
href="http://www.uol.com.br" target="_blank">Este aqui &eacute; um
<p>Revis&atilde;o 3</p><p>&nbsp;</p><p>Esta &eacute; uma obra
Online.</p><p>&nbsp;</p><p><strong>Este texto &eacute;
negrit</strong></p><p>Este texto &eacute; it&aacute;lico/p><p><span
style="text-decoration: undeline;">Este texto est&aacute;
sublinhado</span></p><p>Este texto est&aacute; riscado agora n&atilde;o
est&aacute; mais</p>p style="text-align: left;">Este texto est&aacute;
centralizado nem este</p><p style="text-align: right;">Este texto
est&aacute; alinhado a direita</p><ol><li>Este texto est&aacute; em uma
lista num&eacute;rica</li></ol><p><a title="uol"
href="http://www.uol.com.br" target="_blank">Este aqui &eacute; um
link</a></p>
@@ -1,174 +1,174 @@
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utills Library.
Java Diff Utills Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utills Library 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utills Library. If not, see <http://www.gnu.org/licenses/>.
*/
package difflib;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import difflib.myers.*;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static DiffAlgorithm defaultDiffAlgorithm = new MyersDiff();
private static Pattern unifiedDiffChunkRe =
Pattern.compile("@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised) {
return DiffUtils.diff(original, revised, defaultDiffAlgorithm);
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised, DiffAlgorithm algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static List<?> patch(List<?> original, Patch patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static List<?> unpatch(List<?> revised, Patch patch) {
return patch.restore(revised);
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch patch = new Patch();
int old_ln = 0, old_n = 0, new_ln = 0, new_n = 0;
String tag = "", rest = "";
for (String line: diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
old_n = m.group(2) == null ? 1 : Integer.parseInt(m.group(2));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
new_n = m.group(4) == null ? 1 : Integer.parseInt(m.group(4));
old_ln = Integer.parseInt(m.group(1));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[] {tag, rest});
}
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
return patch;
}
}
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utills Library.
Java Diff Utills Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utills Library 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utills Library. If not, see <http://www.gnu.org/licenses/>.
*/
package difflib;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import difflib.myers.*;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static DiffAlgorithm defaultDiffAlgorithm = new MyersDiff();
private static Pattern unifiedDiffChunkRe =
Pattern.compile("@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised) {
return DiffUtils.diff(original, revised, defaultDiffAlgorithm);
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised, DiffAlgorithm algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static List<?> patch(List<?> original, Patch patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static List<?> unpatch(List<?> revised, Patch patch) {
return patch.restore(revised);
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch patch = new Patch();
int old_ln = 0, old_n = 0, new_ln = 0, new_n = 0;
String tag = "", rest = "";
for (String line: diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
old_n = m.group(2) == null ? 1 : Integer.parseInt(m.group(2));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
new_n = m.group(4) == null ? 1 : Integer.parseInt(m.group(4));
old_ln = Integer.parseInt(m.group(1));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[] {tag, rest});
}
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
return patch;
}
}
@@ -1,308 +1,308 @@
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utils Library.
Java Diff Utils Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utils Library 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utils Library. If not, see <http://www.gnu.org/licenses/>.
*/
package difflib;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import difflib.myers.*;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static DiffAlgorithm defaultDiffAlgorithm = new MyersDiff();
private static Pattern unifiedDiffChunkRe =
Pattern.compile("@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised) {
return DiffUtils.diff(original, revised, defaultDiffAlgorithm);
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised, DiffAlgorithm algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static List<?> patch(List<?> original, Patch patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static List<?> unpatch(List<?> revised, Patch patch) {
return patch.restore(revised); // bla-bla-bla
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch patch = new Patch();
int old_ln = 0, old_n = 0, new_ln = 0, new_n = 0;
String tag = "", rest = "";
for (String line: diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
old_n = m.group(2) == null ? 1 : Integer.parseInt(m.group(2));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
new_n = m.group(4) == null ? 1 : Integer.parseInt(m.group(4));
old_ln = Integer.parseInt(m.group(1));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[] {tag, rest});
}
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk)
{
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-"))
{
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+"))
{
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
return patch;
}
/**
* generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing the Patch.
* @author Bill James (tankerbay@gmail.com)
*
* @param fname1 - Filename of the original (unrevised file)
* @param fname2 - Filename of the revised file
* @param originalLines - Lines of the original file
* @param patch - Patch created by the diff() function
* @param contextSize - number of lines of context output around each difference in the file.
* @return List of strings representing the Unified Diff representation of the Patch argument.
*/
public static List<String> generateUnifiedDiff(String fname1, String fname2, List<String> originalLines, Patch patch, int contextSize ) {
List<String> ret = new ArrayList<String>();
ret.add( "--- " + fname1 );
ret.add( "+++ " + fname2 );
List<Delta> cur = new ArrayList<Delta>(); // current list of Delta's to process
int deltact = patch.getDeltas().size();
// if there's more than 1 Delta, we may need to output them together
if ( deltact > 1 ) {
Delta curDelta = patch.getDelta(0);
cur.add( curDelta ); // add the first Delta to the current set
for ( int i = 1; i < deltact; i++ ) {
int curpos = curDelta.getOriginal().getPosition(); // store the current position of the first Delta
Delta nextDelta = patch.getDelta(i); // Check if the next Delta is too close to the current position
if ( (curpos + curDelta.getOriginal().getSize() + contextSize) >= ( nextDelta.getOriginal().getPosition()-contextSize ) ) {
cur.add( nextDelta ); // if it is, add it to the current set
} else {
List<String> curBlock = processDeltas( originalLines, cur, contextSize );
ret.addAll( curBlock ); // if it isn't, output the current set, then create a new
cur.clear(); // set and add the current Delta to it.
cur.add( nextDelta );
}
curDelta = nextDelta;
}
List<String> curBlock = processDeltas( originalLines, cur, contextSize ); // don't forget to process the last set of Deltas
ret.addAll( curBlock );
}
return ret;
}
/**
* processDeltas takes a list of Deltas and outputs them together in a single block of Unified-Diff-format text.
* @author Bill James (tankerbay@gmail.com)
*
* @param origLines - the lines of the original file
* @param deltas - the Deltas to be output as a single block
* @param contextSize - the number of lines of context to place around block
* @return
*/
private static List<String> processDeltas( List<String> origLines, List<Delta> deltas, int contextSize ) {
List<String> buffer = new ArrayList<String>();
int origTotal = 0; // counter for total lines output from Original
int revTotal = 0; // counter for total lines output from Original
int line;
Delta curDelta = deltas.get(0); // start with the first Delta
int origStart = curDelta.getOriginal().getPosition()+1 - contextSize; // note the +1 to overcome the 0-offset Position
if ( origStart < 1 ) origStart = 1; // clamp to the start of the file
int revStart = curDelta.getRevised().getPosition()+1 - contextSize; // note the +1 to overcome the 0-offset Position
if ( revStart < 1 ) revStart = 1; // clamp to the start of the file
int contextStart = curDelta.getOriginal().getPosition() - contextSize; // find the start of the wrapper context code
if ( contextStart < 0 ) contextStart = 0; // clamp to the start of the file
for ( line = contextStart; line < curDelta.getOriginal().getPosition(); line++ ) { // output the context before the first Delta
buffer.add( " " + origLines.get( line ) );
origTotal++;
revTotal++;
}
buffer.addAll( getDeltaText( curDelta ) ); // output the first Delta
origTotal += curDelta.getOriginal().getLines().size();
revTotal += curDelta.getRevised().getLines().size();
int deltaIndex = 1;
while ( deltaIndex < deltas.size() ) { // for each of the other Deltas
Delta nextDelta = deltas.get( deltaIndex );
int intermediateStart = curDelta.getOriginal().getPosition() + curDelta.getOriginal().getLines().size();
for ( line = intermediateStart; line < nextDelta.getOriginal().getPosition(); line++ ) {
buffer.add( " " + origLines.get( line ) ); // output the code between the last Delta and this one
origTotal++;
revTotal++;
}
buffer.addAll( getDeltaText( nextDelta ) ); // output the Delta
origTotal += nextDelta.getOriginal().getLines().size();
revTotal += nextDelta.getRevised().getLines().size();
curDelta = nextDelta;
deltaIndex++; // increment the iterator
}
// Now output the post-Delta context code, clamping the end of the file
contextStart = curDelta.getOriginal().getPosition() + curDelta.getOriginal().getLines().size();
for ( line = contextStart; ( line < (contextStart + contextSize )) && ( line < origLines.size() ); line++ ) {
buffer.add( " " + origLines.get( line ) );
origTotal++;
revTotal++;
}
// Create and insert the block header, conforming to the Unified Diff standard
StringBuffer header = new StringBuffer();
header.append( "@@ -" );
header.append( origStart );
header.append( "," );
header.append( origTotal );
header.append( " +" );
header.append( revStart );
header.append( "," );
header.append( revTotal );
header.append( " @@" );
buffer.add( 0, header.toString() );
return buffer;
}
/**
* getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter
* @author Bill James (tankerbay@gmail.com)
*
* @param delta - the Delta to output
* @return list of String lines of code.
*/
private static List<String> getDeltaText( Delta delta ) {
List<String> buffer = new ArrayList<String>();
for ( Object line: delta.getOriginal().getLines() ) {
buffer.add( "-" + line );
}
for ( Object line: delta.getRevised().getLines() ) {
buffer.add( "+" + line );
}
return buffer;
}
}
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utils Library.
Java Diff Utils Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utils Library 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utils Library. If not, see <http://www.gnu.org/licenses/>.
*/
package difflib;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import difflib.myers.*;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static DiffAlgorithm defaultDiffAlgorithm = new MyersDiff();
private static Pattern unifiedDiffChunkRe =
Pattern.compile("@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised) {
return DiffUtils.diff(original, revised, defaultDiffAlgorithm);
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised, DiffAlgorithm algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static List<?> patch(List<?> original, Patch patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static List<?> unpatch(List<?> revised, Patch patch) {
return patch.restore(revised); // bla-bla-bla
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch patch = new Patch();
int old_ln = 0, old_n = 0, new_ln = 0, new_n = 0;
String tag = "", rest = "";
for (String line: diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
old_n = m.group(2) == null ? 1 : Integer.parseInt(m.group(2));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
new_n = m.group(4) == null ? 1 : Integer.parseInt(m.group(4));
old_ln = Integer.parseInt(m.group(1));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[] {tag, rest});
}
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk)
{
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-"))
{
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+"))
{
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
return patch;
}
/**
* generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing the Patch.
* @author Bill James (tankerbay@gmail.com)
*
* @param fname1 - Filename of the original (unrevised file)
* @param fname2 - Filename of the revised file
* @param originalLines - Lines of the original file
* @param patch - Patch created by the diff() function
* @param contextSize - number of lines of context output around each difference in the file.
* @return List of strings representing the Unified Diff representation of the Patch argument.
*/
public static List<String> generateUnifiedDiff(String fname1, String fname2, List<String> originalLines, Patch patch, int contextSize ) {
List<String> ret = new ArrayList<String>();
ret.add( "--- " + fname1 );
ret.add( "+++ " + fname2 );
List<Delta> cur = new ArrayList<Delta>(); // current list of Delta's to process
int deltact = patch.getDeltas().size();
// if there's more than 1 Delta, we may need to output them together
if ( deltact > 1 ) {
Delta curDelta = patch.getDelta(0);
cur.add( curDelta ); // add the first Delta to the current set
for ( int i = 1; i < deltact; i++ ) {
int curpos = curDelta.getOriginal().getPosition(); // store the current position of the first Delta
Delta nextDelta = patch.getDelta(i); // Check if the next Delta is too close to the current position
if ( (curpos + curDelta.getOriginal().getSize() + contextSize) >= ( nextDelta.getOriginal().getPosition()-contextSize ) ) {
cur.add( nextDelta ); // if it is, add it to the current set
} else {
List<String> curBlock = processDeltas( originalLines, cur, contextSize );
ret.addAll( curBlock ); // if it isn't, output the current set, then create a new
cur.clear(); // set and add the current Delta to it.
cur.add( nextDelta );
}
curDelta = nextDelta;
}
List<String> curBlock = processDeltas( originalLines, cur, contextSize ); // don't forget to process the last set of Deltas
ret.addAll( curBlock );
}
return ret;
}
/**
* processDeltas takes a list of Deltas and outputs them together in a single block of Unified-Diff-format text.
* @author Bill James (tankerbay@gmail.com)
*
* @param origLines - the lines of the original file
* @param deltas - the Deltas to be output as a single block
* @param contextSize - the number of lines of context to place around block
* @return
*/
private static List<String> processDeltas( List<String> origLines, List<Delta> deltas, int contextSize ) {
List<String> buffer = new ArrayList<String>();
int origTotal = 0; // counter for total lines output from Original
int revTotal = 0; // counter for total lines output from Original
int line;
Delta curDelta = deltas.get(0); // start with the first Delta
int origStart = curDelta.getOriginal().getPosition()+1 - contextSize; // note the +1 to overcome the 0-offset Position
if ( origStart < 1 ) origStart = 1; // clamp to the start of the file
int revStart = curDelta.getRevised().getPosition()+1 - contextSize; // note the +1 to overcome the 0-offset Position
if ( revStart < 1 ) revStart = 1; // clamp to the start of the file
int contextStart = curDelta.getOriginal().getPosition() - contextSize; // find the start of the wrapper context code
if ( contextStart < 0 ) contextStart = 0; // clamp to the start of the file
for ( line = contextStart; line < curDelta.getOriginal().getPosition(); line++ ) { // output the context before the first Delta
buffer.add( " " + origLines.get( line ) );
origTotal++;
revTotal++;
}
buffer.addAll( getDeltaText( curDelta ) ); // output the first Delta
origTotal += curDelta.getOriginal().getLines().size();
revTotal += curDelta.getRevised().getLines().size();
int deltaIndex = 1;
while ( deltaIndex < deltas.size() ) { // for each of the other Deltas
Delta nextDelta = deltas.get( deltaIndex );
int intermediateStart = curDelta.getOriginal().getPosition() + curDelta.getOriginal().getLines().size();
for ( line = intermediateStart; line < nextDelta.getOriginal().getPosition(); line++ ) {
buffer.add( " " + origLines.get( line ) ); // output the code between the last Delta and this one
origTotal++;
revTotal++;
}
buffer.addAll( getDeltaText( nextDelta ) ); // output the Delta
origTotal += nextDelta.getOriginal().getLines().size();
revTotal += nextDelta.getRevised().getLines().size();
curDelta = nextDelta;
deltaIndex++; // increment the iterator
}
// Now output the post-Delta context code, clamping the end of the file
contextStart = curDelta.getOriginal().getPosition() + curDelta.getOriginal().getLines().size();
for ( line = contextStart; ( line < (contextStart + contextSize )) && ( line < origLines.size() ); line++ ) {
buffer.add( " " + origLines.get( line ) );
origTotal++;
revTotal++;
}
// Create and insert the block header, conforming to the Unified Diff standard
StringBuffer header = new StringBuffer();
header.append( "@@ -" );
header.append( origStart );
header.append( "," );
header.append( origTotal );
header.append( " +" );
header.append( revStart );
header.append( "," );
header.append( revTotal );
header.append( " @@" );
buffer.add( 0, header.toString() );
return buffer;
}
/**
* getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter
* @author Bill James (tankerbay@gmail.com)
*
* @param delta - the Delta to output
* @return list of String lines of code.
*/
private static List<String> getDeltaText( Delta delta ) {
List<String> buffer = new ArrayList<String>();
for ( Object line: delta.getOriginal().getLines() ) {
buffer.add( "-" + line );
}
for ( Object line: delta.getRevised().getLines() ) {
buffer.add( "+" + line );
}
return buffer;
}
}
+28 -28
View File
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.googlecode.java-diff-utils</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.googlecode.java-diff-utils</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -1,12 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
@@ -1,5 +1,5 @@
#Fri Jul 29 09:33:56 CEST 2011
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
#Fri Jul 29 09:33:56 CEST 2011
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -1,4 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
+13 -13
View File
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>root</artifactId>
<groupId>com.sap.sailing</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.googlecode.java-diff-utils</artifactId>
<version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>root</artifactId>
<groupId>com.sap.sailing</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.googlecode.java-diff-utils</artifactId>
<version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
@@ -1,92 +1,92 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.List;
/**
* Describes the change-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class ChangeDelta<T> extends Delta<T> {
/**
* {@inheritDoc}
*/
public ChangeDelta(Chunk<T> original, Chunk<T> revised) {
super(original, revised);
}
/**
* {@inheritDoc}
*
* @throws PatchFailedException
*/
@Override
public void applyTo(List<T> target) throws PatchFailedException {
verify(target);
int position = getOriginal().getPosition();
int size = getOriginal().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
int i = 0;
for (T line : getRevised().getLines()) {
target.add(position + i, line);
i++;
}
}
/**
* {@inheritDoc}
*/
@Override
public void restore(List<T> target) {
int position = getRevised().getPosition();
int size = getRevised().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
int i = 0;
for (T line : getOriginal().getLines()) {
target.add(position + i, line);
i++;
}
}
/**
* {@inheritDoc}
*/
public void verify(List<T> target) throws PatchFailedException {
getOriginal().verify(target);
if (getOriginal().getPosition() > target.size()) {
throw new PatchFailedException("Incorrect patch for delta: "
+ "delta original position > target size");
}
}
@Override
public String toString() {
return "[ChangeDelta, position: " + getOriginal().getPosition() + ", lines: "
+ getOriginal().getLines() + " to " + getRevised().getLines() + "]";
}
@Override
public TYPE getType() {
return Delta.TYPE.CHANGE;
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.List;
/**
* Describes the change-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class ChangeDelta<T> extends Delta<T> {
/**
* {@inheritDoc}
*/
public ChangeDelta(Chunk<T> original, Chunk<T> revised) {
super(original, revised);
}
/**
* {@inheritDoc}
*
* @throws PatchFailedException
*/
@Override
public void applyTo(List<T> target) throws PatchFailedException {
verify(target);
int position = getOriginal().getPosition();
int size = getOriginal().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
int i = 0;
for (T line : getRevised().getLines()) {
target.add(position + i, line);
i++;
}
}
/**
* {@inheritDoc}
*/
@Override
public void restore(List<T> target) {
int position = getRevised().getPosition();
int size = getRevised().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
int i = 0;
for (T line : getOriginal().getLines()) {
target.add(position + i, line);
i++;
}
}
/**
* {@inheritDoc}
*/
public void verify(List<T> target) throws PatchFailedException {
getOriginal().verify(target);
if (getOriginal().getPosition() > target.size()) {
throw new PatchFailedException("Incorrect patch for delta: "
+ "delta original position > target size");
}
}
@Override
public String toString() {
return "[ChangeDelta, position: " + getOriginal().getPosition() + ", lines: "
+ getOriginal().getLines() + " to " + getRevised().getLines() + "]";
}
@Override
public TYPE getType() {
return Delta.TYPE.CHANGE;
}
}
@@ -1,154 +1,154 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.Arrays;
import java.util.List;
/**
* Holds the information about the part of text involved in the diff process
*
* <p>
* Text is represented as <code>Object[]</code> because the diff engine is
* capable of handling more than plain ascci. In fact, arrays or lists of any
* type that implements {@link java.lang.Object#hashCode hashCode()} and
* {@link java.lang.Object#equals equals()} correctly can be subject to
* differencing using this library.
* </p>
*
* @author <a href="dm.naumenko@gmail.com>Dmitry Naumenko</a>
*/
public class Chunk<T> {
private final int position;
private final List<T> lines;
/**
* Creates a chunk and saves a copy of affected lines
*
* @param position
* the start position
* @param lines
* the affected lines
*/
public Chunk(int position, List<T> lines) {
this.position = position;
this.lines = lines;
}
/**
* Creates a chunk and saves a copy of affected lines
*
* @param position
* the start position
* @param lines
* the affected lines
*/
public Chunk(int position, T[] lines) {
this.position = position;
this.lines = Arrays.asList(lines);
}
/**
* Verifies that this chunk's saved text matches the corresponding text in
* the given sequence.
*
* @param target
* the sequence to verify against.
*/
public void verify(List<T> target) throws PatchFailedException {
if (last() > target.size()) {
throw new PatchFailedException("Incorrect Chunk: the position of chunk > target size");
}
for (int i = 0; i < size(); i++) {
if (!target.get(position + i).equals(lines.get(i))) {
throw new PatchFailedException(
"Incorrect Chunk: the chunk content doesn't match the target");
}
}
}
/**
* @return the start position of chunk in the text
*/
public int getPosition() {
return position;
}
/**
* @return the affected lines
*/
public List<T> getLines() {
return lines;
}
public int size() {
return lines.size();
}
/**
* Returns the index of the last line of the chunk.
*/
public int last() {
return getPosition() + size() - 1;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((lines == null) ? 0 : lines.hashCode());
result = prime * result + position;
result = prime * result + size();
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
@SuppressWarnings("unchecked")
Chunk<T> other = (Chunk<T>) obj;
if (lines == null) {
if (other.lines != null)
return false;
} else if (!lines.equals(other.lines))
return false;
if (position != other.position)
return false;
return true;
}
@Override
public String toString() {
return "[position: " + position + ", size: " + size() + ", lines: " + lines + "]";
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.Arrays;
import java.util.List;
/**
* Holds the information about the part of text involved in the diff process
*
* <p>
* Text is represented as <code>Object[]</code> because the diff engine is
* capable of handling more than plain ascci. In fact, arrays or lists of any
* type that implements {@link java.lang.Object#hashCode hashCode()} and
* {@link java.lang.Object#equals equals()} correctly can be subject to
* differencing using this library.
* </p>
*
* @author <a href="dm.naumenko@gmail.com>Dmitry Naumenko</a>
*/
public class Chunk<T> {
private final int position;
private final List<T> lines;
/**
* Creates a chunk and saves a copy of affected lines
*
* @param position
* the start position
* @param lines
* the affected lines
*/
public Chunk(int position, List<T> lines) {
this.position = position;
this.lines = lines;
}
/**
* Creates a chunk and saves a copy of affected lines
*
* @param position
* the start position
* @param lines
* the affected lines
*/
public Chunk(int position, T[] lines) {
this.position = position;
this.lines = Arrays.asList(lines);
}
/**
* Verifies that this chunk's saved text matches the corresponding text in
* the given sequence.
*
* @param target
* the sequence to verify against.
*/
public void verify(List<T> target) throws PatchFailedException {
if (last() > target.size()) {
throw new PatchFailedException("Incorrect Chunk: the position of chunk > target size");
}
for (int i = 0; i < size(); i++) {
if (!target.get(position + i).equals(lines.get(i))) {
throw new PatchFailedException(
"Incorrect Chunk: the chunk content doesn't match the target");
}
}
}
/**
* @return the start position of chunk in the text
*/
public int getPosition() {
return position;
}
/**
* @return the affected lines
*/
public List<T> getLines() {
return lines;
}
public int size() {
return lines.size();
}
/**
* Returns the index of the last line of the chunk.
*/
public int last() {
return getPosition() + size() - 1;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((lines == null) ? 0 : lines.hashCode());
result = prime * result + position;
result = prime * result + size();
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
@SuppressWarnings("unchecked")
Chunk<T> other = (Chunk<T>) obj;
if (lines == null) {
if (other.lines != null)
return false;
} else if (!lines.equals(other.lines))
return false;
if (position != other.position)
return false;
return true;
}
@Override
public String toString() {
return "[position: " + position + ", size: " + size() + ", lines: " + lines + "]";
}
}
@@ -1,76 +1,76 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.List;
/**
* Describes the delete-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class DeleteDelta<T> extends Delta<T> {
/**
* {@inheritDoc}
*/
public DeleteDelta(Chunk<T> original, Chunk<T> revised) {
super(original, revised);
}
/**
* {@inheritDoc}
*
* @throws PatchFailedException
*/
@Override
public void applyTo(List<T> target) throws PatchFailedException {
verify(target);
int position = getOriginal().getPosition();
int size = getOriginal().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
}
/**
* {@inheritDoc}
*/
@Override
public void restore(List<T> target) {
int position = this.getRevised().getPosition();
List<T> lines = this.getOriginal().getLines();
for (int i = 0; i < lines.size(); i++) {
target.add(position + i, lines.get(i));
}
}
@Override
public TYPE getType() {
return Delta.TYPE.DELETE;
}
@Override
public void verify(List<T> target) throws PatchFailedException {
getOriginal().verify(target);
}
@Override
public String toString() {
return "[DeleteDelta, position: " + getOriginal().getPosition() + ", lines: "
+ getOriginal().getLines() + "]";
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.List;
/**
* Describes the delete-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class DeleteDelta<T> extends Delta<T> {
/**
* {@inheritDoc}
*/
public DeleteDelta(Chunk<T> original, Chunk<T> revised) {
super(original, revised);
}
/**
* {@inheritDoc}
*
* @throws PatchFailedException
*/
@Override
public void applyTo(List<T> target) throws PatchFailedException {
verify(target);
int position = getOriginal().getPosition();
int size = getOriginal().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
}
/**
* {@inheritDoc}
*/
@Override
public void restore(List<T> target) {
int position = this.getRevised().getPosition();
List<T> lines = this.getOriginal().getLines();
for (int i = 0; i < lines.size(); i++) {
target.add(position + i, lines.get(i));
}
}
@Override
public TYPE getType() {
return Delta.TYPE.DELETE;
}
@Override
public void verify(List<T> target) throws PatchFailedException {
getOriginal().verify(target);
}
@Override
public String toString() {
return "[DeleteDelta, position: " + getOriginal().getPosition() + ", lines: "
+ getOriginal().getLines() + "]";
}
}
@@ -1,146 +1,146 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.*;
/**
* Describes the delta between original and revised object lists. Applying the patch only uses {@link List#add(int, Object)}
* and {@link List#remove(int)} as modifying operations. In particular, no call to {@link List#set(int, Object)} needs to be
* expected.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public abstract class Delta<T> {
private Chunk<T> original;
private Chunk<T> revised;
public enum TYPE {
CHANGE, DELETE, INSERT
}
/**
* Construct the delta for original and revised chunks
*
* @param original chunk describes the original text
* @param revised chunk describes the revised text
*/
public Delta(Chunk<T> original, Chunk<T> revised) {
this.original = original;
this.revised = revised;
}
/**
* Verifies that this delta can be used to patch the given text.
*
* @param target the text to patch.
* @throws PatchFailedException if the patch cannot be applied.
*/
public abstract void verify(List<T> target) throws PatchFailedException;
/**
* Applies this delta as the patch for a given target
*
* @param target the given target
* @throws PatchFailedException
*/
public abstract void applyTo(List<T> target) throws PatchFailedException;
/**
* Cancel this delta for a given revised text. The action is opposite to
* patch.
*
* @param target the given revised text
*/
public abstract void restore(List<T> target);
/**
* Returns the type of delta
* @return the type enum
*/
public abstract TYPE getType();
/**
* @return the Chunk describing the original text
*/
public Chunk<T> getOriginal() {
return original;
}
/**
* @param original the Chunk describing the original text to set
*/
public void setOriginal(Chunk<T> original) {
this.original = original;
}
/**
* @return the Chunk describing the revised text
*/
public Chunk<T> getRevised() {
return revised;
}
/**
* @param revised the Chunk describing the revised text to set
*/
public void setRevised(Chunk<T> revised) {
this.revised = revised;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((original == null) ? 0 : original.hashCode());
result = prime * result + ((revised == null) ? 0 : revised.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
@SuppressWarnings("unchecked")
Delta<T> other = (Delta<T>) obj;
if (original == null) {
if (other.original != null)
return false;
} else if (!original.equals(other.original))
return false;
if (revised == null) {
if (other.revised != null)
return false;
} else if (!revised.equals(other.revised))
return false;
return true;
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.*;
/**
* Describes the delta between original and revised object lists. Applying the patch only uses {@link List#add(int, Object)}
* and {@link List#remove(int)} as modifying operations. In particular, no call to {@link List#set(int, Object)} needs to be
* expected.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public abstract class Delta<T> {
private Chunk<T> original;
private Chunk<T> revised;
public enum TYPE {
CHANGE, DELETE, INSERT
}
/**
* Construct the delta for original and revised chunks
*
* @param original chunk describes the original text
* @param revised chunk describes the revised text
*/
public Delta(Chunk<T> original, Chunk<T> revised) {
this.original = original;
this.revised = revised;
}
/**
* Verifies that this delta can be used to patch the given text.
*
* @param target the text to patch.
* @throws PatchFailedException if the patch cannot be applied.
*/
public abstract void verify(List<T> target) throws PatchFailedException;
/**
* Applies this delta as the patch for a given target
*
* @param target the given target
* @throws PatchFailedException
*/
public abstract void applyTo(List<T> target) throws PatchFailedException;
/**
* Cancel this delta for a given revised text. The action is opposite to
* patch.
*
* @param target the given revised text
*/
public abstract void restore(List<T> target);
/**
* Returns the type of delta
* @return the type enum
*/
public abstract TYPE getType();
/**
* @return the Chunk describing the original text
*/
public Chunk<T> getOriginal() {
return original;
}
/**
* @param original the Chunk describing the original text to set
*/
public void setOriginal(Chunk<T> original) {
this.original = original;
}
/**
* @return the Chunk describing the revised text
*/
public Chunk<T> getRevised() {
return revised;
}
/**
* @param revised the Chunk describing the revised text to set
*/
public void setRevised(Chunk<T> revised) {
this.revised = revised;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((original == null) ? 0 : original.hashCode());
result = prime * result + ((revised == null) ? 0 : revised.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
@SuppressWarnings("unchecked")
Delta<T> other = (Delta<T>) obj;
if (original == null) {
if (other.original != null)
return false;
} else if (!original.equals(other.original))
return false;
if (revised == null) {
if (other.revised != null)
return false;
} else if (!revised.equals(other.revised))
return false;
return true;
}
}
@@ -1,25 +1,25 @@
package difflib;
import java.io.Serializable;
import java.util.Comparator;
/**
* @author mksenzov
*/
public class DeltaComparator<T> implements Comparator<Delta<T>>, Serializable {
private static final long serialVersionUID = 1L;
public DeltaComparator() {
}
public int compare(final Delta<T> a, final Delta<T> b) {
final int posA = a.getOriginal().getPosition();
final int posB = b.getOriginal().getPosition();
if (posA > posB) {
return 1;
} else if (posA < posB) {
return -1;
}
return 0;
}
package difflib;
import java.io.Serializable;
import java.util.Comparator;
/**
* @author mksenzov
*/
public class DeltaComparator<T> implements Comparator<Delta<T>>, Serializable {
private static final long serialVersionUID = 1L;
public DeltaComparator() {
}
public int compare(final Delta<T> a, final Delta<T> b) {
final int posA = a.getOriginal().getPosition();
final int posB = b.getOriginal().getPosition();
if (posA > posB) {
return 1;
} else if (posA < posB) {
return -1;
}
return 0;
}
}
@@ -1,44 +1,44 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
/**
* The general interface for computing diffs between two texts
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public interface DiffAlgorithm<T> {
/**
* Computes the difference between the original sequence and the revised
* sequence and returns it as a {@link difflib.Patch Patch} object.
*
* @param original the original text
* @param revised the revised text
* @return the patch
*/
public Patch<T> diff(T[] original, T[] revised);
/**
* Computes the difference between the original sequence and the revised
* sequence and returns it as a {@link difflib.Patch Patch} object.
*
* @param original the original text
* @param revised the revised text
* @return the patch
*/
public Patch<T> diff(Iterable<T> original, Iterable<T> revised);
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
/**
* The general interface for computing diffs between two texts
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public interface DiffAlgorithm<T> {
/**
* Computes the difference between the original sequence and the revised
* sequence and returns it as a {@link difflib.Patch Patch} object.
*
* @param original the original text
* @param revised the revised text
* @return the patch
*/
public Patch<T> diff(T[] original, T[] revised);
/**
* Computes the difference between the original sequence and the revised
* sequence and returns it as a {@link difflib.Patch Patch} object.
*
* @param original the original text
* @param revised the revised text
* @return the patch
*/
public Patch<T> diff(Iterable<T> original, Iterable<T> revised);
}
@@ -1,33 +1,33 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
/**
* Base class for all exceptions emanating from this package.
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*/
public class DiffException extends Exception {
private static final long serialVersionUID = 1L;
public DiffException() {
}
public DiffException(String msg) {
super(msg);
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
/**
* Base class for all exceptions emanating from this package.
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*/
public class DiffException extends Exception {
private static final long serialVersionUID = 1L;
public DiffException() {
}
public DiffException(String msg) {
super(msg);
}
}
@@ -1,131 +1,131 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
/**
* Describes the diff row in form [tag, oldLine, newLine) for showing the
* difference between two texts
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class DiffRow {
private Tag tag;
private String oldLine;
private String newLine;
public DiffRow(Tag tag, String oldLine, String newLine) {
this.tag = tag;
this.oldLine = oldLine;
this.newLine = newLine;
}
public enum Tag {
INSERT, DELETE, CHANGE, EQUAL
}
/**
* @return the tag
*/
public Tag getTag() {
return tag;
}
/**
* @param tag the tag to set
*/
public void setTag(Tag tag) {
this.tag = tag;
}
/**
* @return the oldLine
*/
public String getOldLine() {
return oldLine;
}
/**
* @param oldLine the oldLine to set
*/
public void setOldLine(String oldLine) {
this.oldLine = oldLine;
}
/**
* @return the newLine
*/
public String getNewLine() {
return newLine;
}
/**
* @param newLine the newLine to set
*/
public void setNewLine(String newLine) {
this.newLine = newLine;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((newLine == null) ? 0 : newLine.hashCode());
result = prime * result + ((oldLine == null) ? 0 : oldLine.hashCode());
result = prime * result + ((tag == null) ? 0 : tag.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DiffRow other = (DiffRow) obj;
if (newLine == null) {
if (other.newLine != null)
return false;
} else if (!newLine.equals(other.newLine))
return false;
if (oldLine == null) {
if (other.oldLine != null)
return false;
} else if (!oldLine.equals(other.oldLine))
return false;
if (tag == null) {
if (other.tag != null)
return false;
} else if (!tag.equals(other.tag))
return false;
return true;
}
public String toString() {
return "[" + this.tag + "," + this.oldLine + "," + this.newLine + "]";
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
/**
* Describes the diff row in form [tag, oldLine, newLine) for showing the
* difference between two texts
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class DiffRow {
private Tag tag;
private String oldLine;
private String newLine;
public DiffRow(Tag tag, String oldLine, String newLine) {
this.tag = tag;
this.oldLine = oldLine;
this.newLine = newLine;
}
public enum Tag {
INSERT, DELETE, CHANGE, EQUAL
}
/**
* @return the tag
*/
public Tag getTag() {
return tag;
}
/**
* @param tag the tag to set
*/
public void setTag(Tag tag) {
this.tag = tag;
}
/**
* @return the oldLine
*/
public String getOldLine() {
return oldLine;
}
/**
* @param oldLine the oldLine to set
*/
public void setOldLine(String oldLine) {
this.oldLine = oldLine;
}
/**
* @return the newLine
*/
public String getNewLine() {
return newLine;
}
/**
* @param newLine the newLine to set
*/
public void setNewLine(String newLine) {
this.newLine = newLine;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((newLine == null) ? 0 : newLine.hashCode());
result = prime * result + ((oldLine == null) ? 0 : oldLine.hashCode());
result = prime * result + ((tag == null) ? 0 : tag.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DiffRow other = (DiffRow) obj;
if (newLine == null) {
if (other.newLine != null)
return false;
} else if (!newLine.equals(other.newLine))
return false;
if (oldLine == null) {
if (other.oldLine != null)
return false;
} else if (!oldLine.equals(other.oldLine))
return false;
if (tag == null) {
if (other.tag != null)
return false;
} else if (!tag.equals(other.tag))
return false;
return true;
}
public String toString() {
return "[" + this.tag + "," + this.oldLine + "," + this.newLine + "]";
}
}
@@ -1,336 +1,336 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import difflib.myers.MyersDiff;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static Pattern unifiedDiffChunkRe =
Pattern.compile("^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@$");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static <T> Patch<T> diff(Iterable<T> original, Iterable<T> revised) {
return DiffUtils.diff(original, revised, new MyersDiff<T>());
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static <T> Patch<T> diff(Iterable<T> original, Iterable<T> revised, DiffAlgorithm<T> algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static <T> List<T> patch(List<T> original, Patch<T> patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static <T> List<T> unpatch(List<T> revised, Patch<T> patch) {
return patch.restore(revised);
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch<String> parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch<String> patch = new Patch<String>();
int old_ln = 0, new_ln = 0;
String tag;
String rest;
for (String line : diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line : rawChunk) {
tag = (String) raw_line[0];
rest = (String) raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta<String>(new Chunk<String>(old_ln - 1, oldChunkLines),
new Chunk<String>(new_ln - 1, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[]{tag, rest});
}
} else {
rawChunk.add(new Object[]{" ", ""});
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line : rawChunk) {
tag = (String) raw_line[0];
rest = (String) raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta<String>(new Chunk<String>(old_ln - 1, oldChunkLines), new Chunk<String>(
new_ln - 1, newChunkLines)));
rawChunk.clear();
}
return patch;
}
/**
* generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing the Patch.
*
* @param original - Filename of the original (unrevised file)
* @param revised - Filename of the revised file
* @param originalLines - Lines of the original file
* @param patch - Patch created by the diff() function
* @param contextSize - number of lines of context output around each difference in the file.
* @return List of strings representing the Unified Diff representation of the Patch argument.
* @author Bill James (tankerbay@gmail.com)
*/
public static List<String> generateUnifiedDiff(String original, String revised,
List<String> originalLines, Patch<String> patch, int contextSize) {
if (!patch.getDeltas().isEmpty()) {
List<String> ret = new ArrayList<String>();
ret.add("--- " + original);
ret.add("+++ " + revised);
List<Delta<String>> patchDeltas = new ArrayList<Delta<String>>(patch.getDeltas());
// code outside the if block also works for single-delta issues.
List<Delta<String>> deltas = new ArrayList<Delta<String>>(); // current list of Delta's to process
Delta<String> delta = patchDeltas.get(0);
deltas.add(delta); // add the first Delta to the current set
// if there's more than 1 Delta, we may need to output them together
if (patchDeltas.size() > 1) {
for (int i = 1; i < patchDeltas.size(); i++) {
int position = delta.getOriginal().getPosition(); // store the current position of
// the first Delta
// Check if the next Delta is too close to the current position.
// And if it is, add it to the current set
Delta<String> nextDelta = patchDeltas.get(i);
if ((position + delta.getOriginal().size() + contextSize) >=
(nextDelta.getOriginal().getPosition() - contextSize)) {
deltas.add(nextDelta);
} else {
// if it isn't, output the current set,
// then create a new set and add the current Delta to it.
List<String> curBlock = processDeltas(originalLines, deltas, contextSize);
ret.addAll(curBlock);
deltas.clear();
deltas.add(nextDelta);
}
delta = nextDelta;
}
}
// don't forget to process the last set of Deltas
List<String> curBlock = processDeltas(originalLines, deltas, contextSize);
ret.addAll(curBlock);
return ret;
}
return new ArrayList<String>();
}
/**
* processDeltas takes a list of Deltas and outputs them together in a single block of Unified-Diff-format text.
*
* @param origLines - the lines of the original file
* @param deltas - the Deltas to be output as a single block
* @param contextSize - the number of lines of context to place around block
* @return
* @author Bill James (tankerbay@gmail.com)
*/
private static List<String> processDeltas(List<String> origLines, List<Delta<String>> deltas,
int contextSize) {
List<String> buffer = new ArrayList<String>();
int origTotal = 0; // counter for total lines output from Original
int revTotal = 0; // counter for total lines output from Original
int line;
Delta<String> curDelta = deltas.get(0);
// NOTE: +1 to overcome the 0-offset Position
int origStart = curDelta.getOriginal().getPosition() + 1 - contextSize;
if (origStart < 1) {
origStart = 1;
}
int revStart = curDelta.getRevised().getPosition() + 1 - contextSize;
if (revStart < 1) {
revStart = 1;
}
// find the start of the wrapper context code
int contextStart = curDelta.getOriginal().getPosition() - contextSize;
if (contextStart < 0) {
contextStart = 0; // clamp to the start of the file
}
// output the context before the first Delta
for (line = contextStart; line < curDelta.getOriginal().getPosition(); line++) { //
buffer.add(" " + origLines.get(line));
origTotal++;
revTotal++;
}
// output the first Delta
buffer.addAll(getDeltaText(curDelta));
origTotal += curDelta.getOriginal().getLines().size();
revTotal += curDelta.getRevised().getLines().size();
int deltaIndex = 1;
while (deltaIndex < deltas.size()) { // for each of the other Deltas
Delta<String> nextDelta = deltas.get(deltaIndex);
int intermediateStart = curDelta.getOriginal().getPosition()
+ curDelta.getOriginal().getLines().size();
for (line = intermediateStart; line < nextDelta.getOriginal().getPosition(); line++) {
// output the code between the last Delta and this one
buffer.add(" " + origLines.get(line));
origTotal++;
revTotal++;
}
buffer.addAll(getDeltaText(nextDelta)); // output the Delta
origTotal += nextDelta.getOriginal().getLines().size();
revTotal += nextDelta.getRevised().getLines().size();
curDelta = nextDelta;
deltaIndex++;
}
// Now output the post-Delta context code, clamping the end of the file
contextStart = curDelta.getOriginal().getPosition()
+ curDelta.getOriginal().getLines().size();
for (line = contextStart; (line < (contextStart + contextSize))
&& (line < origLines.size()); line++) {
buffer.add(" " + origLines.get(line));
origTotal++;
revTotal++;
}
// Create and insert the block header, conforming to the Unified Diff standard
StringBuffer header = new StringBuffer();
header.append("@@ -");
header.append(origStart);
header.append(",");
header.append(origTotal);
header.append(" +");
header.append(revStart);
header.append(",");
header.append(revTotal);
header.append(" @@");
buffer.add(0, header.toString());
return buffer;
}
/**
* getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter
*
* @param delta - the Delta to output
* @return list of String lines of code.
* @author Bill James (tankerbay@gmail.com)
*/
private static List<String> getDeltaText(Delta<String> delta) {
List<String> buffer = new ArrayList<String>();
for (Object line : delta.getOriginal().getLines()) {
buffer.add("-" + line);
}
for (Object line : delta.getRevised().getLines()) {
buffer.add("+" + line);
}
return buffer;
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import difflib.myers.MyersDiff;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static Pattern unifiedDiffChunkRe =
Pattern.compile("^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@$");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static <T> Patch<T> diff(Iterable<T> original, Iterable<T> revised) {
return DiffUtils.diff(original, revised, new MyersDiff<T>());
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static <T> Patch<T> diff(Iterable<T> original, Iterable<T> revised, DiffAlgorithm<T> algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static <T> List<T> patch(List<T> original, Patch<T> patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static <T> List<T> unpatch(List<T> revised, Patch<T> patch) {
return patch.restore(revised);
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch<String> parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch<String> patch = new Patch<String>();
int old_ln = 0, new_ln = 0;
String tag;
String rest;
for (String line : diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line : rawChunk) {
tag = (String) raw_line[0];
rest = (String) raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta<String>(new Chunk<String>(old_ln - 1, oldChunkLines),
new Chunk<String>(new_ln - 1, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[]{tag, rest});
}
} else {
rawChunk.add(new Object[]{" ", ""});
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line : rawChunk) {
tag = (String) raw_line[0];
rest = (String) raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta<String>(new Chunk<String>(old_ln - 1, oldChunkLines), new Chunk<String>(
new_ln - 1, newChunkLines)));
rawChunk.clear();
}
return patch;
}
/**
* generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing the Patch.
*
* @param original - Filename of the original (unrevised file)
* @param revised - Filename of the revised file
* @param originalLines - Lines of the original file
* @param patch - Patch created by the diff() function
* @param contextSize - number of lines of context output around each difference in the file.
* @return List of strings representing the Unified Diff representation of the Patch argument.
* @author Bill James (tankerbay@gmail.com)
*/
public static List<String> generateUnifiedDiff(String original, String revised,
List<String> originalLines, Patch<String> patch, int contextSize) {
if (!patch.getDeltas().isEmpty()) {
List<String> ret = new ArrayList<String>();
ret.add("--- " + original);
ret.add("+++ " + revised);
List<Delta<String>> patchDeltas = new ArrayList<Delta<String>>(patch.getDeltas());
// code outside the if block also works for single-delta issues.
List<Delta<String>> deltas = new ArrayList<Delta<String>>(); // current list of Delta's to process
Delta<String> delta = patchDeltas.get(0);
deltas.add(delta); // add the first Delta to the current set
// if there's more than 1 Delta, we may need to output them together
if (patchDeltas.size() > 1) {
for (int i = 1; i < patchDeltas.size(); i++) {
int position = delta.getOriginal().getPosition(); // store the current position of
// the first Delta
// Check if the next Delta is too close to the current position.
// And if it is, add it to the current set
Delta<String> nextDelta = patchDeltas.get(i);
if ((position + delta.getOriginal().size() + contextSize) >=
(nextDelta.getOriginal().getPosition() - contextSize)) {
deltas.add(nextDelta);
} else {
// if it isn't, output the current set,
// then create a new set and add the current Delta to it.
List<String> curBlock = processDeltas(originalLines, deltas, contextSize);
ret.addAll(curBlock);
deltas.clear();
deltas.add(nextDelta);
}
delta = nextDelta;
}
}
// don't forget to process the last set of Deltas
List<String> curBlock = processDeltas(originalLines, deltas, contextSize);
ret.addAll(curBlock);
return ret;
}
return new ArrayList<String>();
}
/**
* processDeltas takes a list of Deltas and outputs them together in a single block of Unified-Diff-format text.
*
* @param origLines - the lines of the original file
* @param deltas - the Deltas to be output as a single block
* @param contextSize - the number of lines of context to place around block
* @return
* @author Bill James (tankerbay@gmail.com)
*/
private static List<String> processDeltas(List<String> origLines, List<Delta<String>> deltas,
int contextSize) {
List<String> buffer = new ArrayList<String>();
int origTotal = 0; // counter for total lines output from Original
int revTotal = 0; // counter for total lines output from Original
int line;
Delta<String> curDelta = deltas.get(0);
// NOTE: +1 to overcome the 0-offset Position
int origStart = curDelta.getOriginal().getPosition() + 1 - contextSize;
if (origStart < 1) {
origStart = 1;
}
int revStart = curDelta.getRevised().getPosition() + 1 - contextSize;
if (revStart < 1) {
revStart = 1;
}
// find the start of the wrapper context code
int contextStart = curDelta.getOriginal().getPosition() - contextSize;
if (contextStart < 0) {
contextStart = 0; // clamp to the start of the file
}
// output the context before the first Delta
for (line = contextStart; line < curDelta.getOriginal().getPosition(); line++) { //
buffer.add(" " + origLines.get(line));
origTotal++;
revTotal++;
}
// output the first Delta
buffer.addAll(getDeltaText(curDelta));
origTotal += curDelta.getOriginal().getLines().size();
revTotal += curDelta.getRevised().getLines().size();
int deltaIndex = 1;
while (deltaIndex < deltas.size()) { // for each of the other Deltas
Delta<String> nextDelta = deltas.get(deltaIndex);
int intermediateStart = curDelta.getOriginal().getPosition()
+ curDelta.getOriginal().getLines().size();
for (line = intermediateStart; line < nextDelta.getOriginal().getPosition(); line++) {
// output the code between the last Delta and this one
buffer.add(" " + origLines.get(line));
origTotal++;
revTotal++;
}
buffer.addAll(getDeltaText(nextDelta)); // output the Delta
origTotal += nextDelta.getOriginal().getLines().size();
revTotal += nextDelta.getRevised().getLines().size();
curDelta = nextDelta;
deltaIndex++;
}
// Now output the post-Delta context code, clamping the end of the file
contextStart = curDelta.getOriginal().getPosition()
+ curDelta.getOriginal().getLines().size();
for (line = contextStart; (line < (contextStart + contextSize))
&& (line < origLines.size()); line++) {
buffer.add(" " + origLines.get(line));
origTotal++;
revTotal++;
}
// Create and insert the block header, conforming to the Unified Diff standard
StringBuffer header = new StringBuffer();
header.append("@@ -");
header.append(origStart);
header.append(",");
header.append(origTotal);
header.append(" +");
header.append(revStart);
header.append(",");
header.append(revTotal);
header.append(" @@");
buffer.add(0, header.toString());
return buffer;
}
/**
* getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter
*
* @param delta - the Delta to output
* @return list of String lines of code.
* @author Bill James (tankerbay@gmail.com)
*/
private static List<String> getDeltaText(Delta<String> delta) {
List<String> buffer = new ArrayList<String>();
for (Object line : delta.getOriginal().getLines()) {
buffer.add("-" + line);
}
for (Object line : delta.getRevised().getLines()) {
buffer.add("+" + line);
}
return buffer;
}
}
@@ -1,78 +1,78 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.List;
/**
* Describes the add-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class InsertDelta<T> extends Delta<T> {
/**
* {@inheritDoc}
*/
public InsertDelta(Chunk<T> original, Chunk<T> revised) {
super(original, revised);
}
/**
* {@inheritDoc}
* @throws PatchFailedException
*/
@Override
public void applyTo(List<T> target) throws PatchFailedException {
verify(target);
int position = this.getOriginal().getPosition();
List<T> lines = this.getRevised().getLines();
for (int i = 0; i < lines.size(); i++) {
target.add(position + i, lines.get(i));
}
}
/**
* {@inheritDoc}
*/
@Override
public void restore(List<T> target) {
int position = getRevised().getPosition();
int size = getRevised().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
}
@Override
public void verify(List<T> target) throws PatchFailedException {
if (getOriginal().getPosition() > target.size()) {
throw new PatchFailedException("Incorrect patch for delta: "
+ "delta original position > target size");
}
}
public TYPE getType() {
return Delta.TYPE.INSERT;
}
@Override
public String toString() {
return "[InsertDelta, position: " + getOriginal().getPosition() + ", lines: "
+ getRevised().getLines() + "]";
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.List;
/**
* Describes the add-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class InsertDelta<T> extends Delta<T> {
/**
* {@inheritDoc}
*/
public InsertDelta(Chunk<T> original, Chunk<T> revised) {
super(original, revised);
}
/**
* {@inheritDoc}
* @throws PatchFailedException
*/
@Override
public void applyTo(List<T> target) throws PatchFailedException {
verify(target);
int position = this.getOriginal().getPosition();
List<T> lines = this.getRevised().getLines();
for (int i = 0; i < lines.size(); i++) {
target.add(position + i, lines.get(i));
}
}
/**
* {@inheritDoc}
*/
@Override
public void restore(List<T> target) {
int position = getRevised().getPosition();
int size = getRevised().size();
for (int i = 0; i < size; i++) {
target.remove(position);
}
}
@Override
public void verify(List<T> target) throws PatchFailedException {
if (getOriginal().getPosition() > target.size()) {
throw new PatchFailedException("Incorrect patch for delta: "
+ "delta original position > target size");
}
}
public TYPE getType() {
return Delta.TYPE.INSERT;
}
@Override
public String toString() {
return "[InsertDelta, position: " + getOriginal().getPosition() + ", lines: "
+ getRevised().getLines() + "]";
}
}
@@ -1,113 +1,113 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
/**
* Describes the patch holding all deltas between the original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class Patch<T> {
private List<Delta<T>> deltas = new LinkedList<Delta<T>>();
/**
* Apply this patch to the given target, producing a new list as result
* @return the patched text
* @throws PatchFailedException if can't apply patch
*/
public List<T> applyTo(List<T> target) throws PatchFailedException {
List<T> result = new LinkedList<T>(target);
ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size());
while (it.hasPrevious()) {
Delta<T> delta = it.previous();
delta.applyTo(result);
}
return result;
}
public boolean isEmpty() {
return deltas.isEmpty();
}
/**
* Apply this patch to the given target in-place, updating the <code>target</code> list
* @return the patched text
* @throws PatchFailedException if can't apply patch
*/
public List<T> applyToInPlace(List<T> target) throws PatchFailedException {
List<T> result = target;
ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size());
while (it.hasPrevious()) {
Delta<T> delta = it.previous();
delta.applyTo(result);
}
return result;
}
/**
* Restore the text to original. Opposite to applyTo() method.
* @param target the given target
* @return the restored text
*/
public List<T> restore(List<T> target) {
List<T> result = new LinkedList<T>(target);
ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size());
while (it.hasPrevious()) {
Delta<T> delta = it.previous();
delta.restore(result);
}
return result;
}
/**
* Add the given delta to this patch
* @param delta the given delta
*/
public void addDelta(Delta<T> delta) {
deltas.add(delta);
}
/**
* Get the list of computed deltas
* @return the deltas
*/
public List<Delta<T>> getDeltas() {
Collections.sort(deltas, new DeltaComparator<T>());
return deltas;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
result.append('[');
boolean first = true;
for (Delta<T> delta : getDeltas()) {
if (first) {
first = false;
} else {
result.append(", ");
}
result.append(delta);
}
result.append(']');
return result.toString();
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
/**
* Describes the patch holding all deltas between the original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class Patch<T> {
private List<Delta<T>> deltas = new LinkedList<Delta<T>>();
/**
* Apply this patch to the given target, producing a new list as result
* @return the patched text
* @throws PatchFailedException if can't apply patch
*/
public List<T> applyTo(List<T> target) throws PatchFailedException {
List<T> result = new LinkedList<T>(target);
ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size());
while (it.hasPrevious()) {
Delta<T> delta = it.previous();
delta.applyTo(result);
}
return result;
}
public boolean isEmpty() {
return deltas.isEmpty();
}
/**
* Apply this patch to the given target in-place, updating the <code>target</code> list
* @return the patched text
* @throws PatchFailedException if can't apply patch
*/
public List<T> applyToInPlace(List<T> target) throws PatchFailedException {
List<T> result = target;
ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size());
while (it.hasPrevious()) {
Delta<T> delta = it.previous();
delta.applyTo(result);
}
return result;
}
/**
* Restore the text to original. Opposite to applyTo() method.
* @param target the given target
* @return the restored text
*/
public List<T> restore(List<T> target) {
List<T> result = new LinkedList<T>(target);
ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size());
while (it.hasPrevious()) {
Delta<T> delta = it.previous();
delta.restore(result);
}
return result;
}
/**
* Add the given delta to this patch
* @param delta the given delta
*/
public void addDelta(Delta<T> delta) {
deltas.add(delta);
}
/**
* Get the list of computed deltas
* @return the deltas
*/
public List<Delta<T>> getDeltas() {
Collections.sort(deltas, new DeltaComparator<T>());
return deltas;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
result.append('[');
boolean first = true;
for (Delta<T> delta : getDeltas()) {
if (first) {
first = false;
} else {
result.append(", ");
}
result.append(delta);
}
result.append(']');
return result.toString();
}
}
@@ -1,33 +1,33 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
/**
* Thrown whenever a delta cannot be applied as a patch to a given text.
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*/
public class PatchFailedException extends DiffException {
private static final long serialVersionUID = 1L;
public PatchFailedException() {
}
public PatchFailedException(String msg) {
super(msg);
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
/**
* Thrown whenever a delta cannot be applied as a patch to a given text.
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*/
public class PatchFailedException extends DiffException {
private static final long serialVersionUID = 1L;
public PatchFailedException() {
}
public PatchFailedException(String msg) {
super(msg);
}
}
@@ -1,83 +1,83 @@
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class StringUtills {
public static <T> String join(final Iterable<T> objs, final String delimiter) {
Iterator<T> iter = objs.iterator();
if (!iter.hasNext()) {
return "";
}
StringBuffer buffer = new StringBuffer(String.valueOf(iter.next()));
while (iter.hasNext()) {
buffer.append(delimiter).append(String.valueOf(iter.next()));
}
return buffer.toString();
}
public static String expandTabs(String str) {
return str.replace("\t", " ");
}
public static String htmlEntites(String str) {
return str.replace("<", "&lt;").replace(">", "&gt;");
}
public static String normalize(String str) {
return expandTabs(htmlEntites(str));
}
public static List<String> normalize(List<String> list) {
List<String> result = new LinkedList<String>();
for (String line : list) {
result.add(normalize(line));
}
return result;
}
public static List<String> wrapText(List<String> list, int columnWidth) {
List<String> result = new LinkedList<String>();
for (String line : list) {
result.add(wrapText(line, columnWidth));
}
return result;
}
/**
* Wrap the text with the given column width
* @param line the text
* @param columnWidth the given column
* @return the wrapped text
*/
public static String wrapText(String line, int columnWidth) {
int lenght = line.length();
int delimiter = "<br>".length();
int widthIndex = columnWidth;
for (int count = 0; lenght > widthIndex; count++) {
line = line.subSequence(0, widthIndex + delimiter * count) + "<br>"
+ line.substring(widthIndex + delimiter * count);
widthIndex += columnWidth;
}
return line;
}
}
/*
Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package difflib;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class StringUtills {
public static <T> String join(final Iterable<T> objs, final String delimiter) {
Iterator<T> iter = objs.iterator();
if (!iter.hasNext()) {
return "";
}
StringBuffer buffer = new StringBuffer(String.valueOf(iter.next()));
while (iter.hasNext()) {
buffer.append(delimiter).append(String.valueOf(iter.next()));
}
return buffer.toString();
}
public static String expandTabs(String str) {
return str.replace("\t", " ");
}
public static String htmlEntites(String str) {
return str.replace("<", "&lt;").replace(">", "&gt;");
}
public static String normalize(String str) {
return expandTabs(htmlEntites(str));
}
public static List<String> normalize(List<String> list) {
List<String> result = new LinkedList<String>();
for (String line : list) {
result.add(normalize(line));
}
return result;
}
public static List<String> wrapText(List<String> list, int columnWidth) {
List<String> result = new LinkedList<String>();
for (String line : list) {
result.add(wrapText(line, columnWidth));
}
return result;
}
/**
* Wrap the text with the given column width
* @param line the text
* @param columnWidth the given column
* @return the wrapped text
*/
public static String wrapText(String line, int columnWidth) {
int lenght = line.length();
int delimiter = "<br>".length();
int widthIndex = columnWidth;
for (int count = 0; lenght > widthIndex; count++) {
line = line.subSequence(0, widthIndex + delimiter * count) + "<br>"
+ line.substring(widthIndex + delimiter * count);
widthIndex += columnWidth;
}
return line;
}
}
@@ -1,77 +1,77 @@
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
/**
* Base class for all exceptions emanating from this package.
*
* @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*/
public class DiffException extends Exception {
private static final long serialVersionUID = 1L;
public DiffException() {
}
public DiffException(String msg) {
super(msg);
}
}
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
/**
* Base class for all exceptions emanating from this package.
*
* @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*/
public class DiffException extends Exception {
private static final long serialVersionUID = 1L;
public DiffException() {
}
public DiffException(String msg) {
super(msg);
}
}
@@ -1,53 +1,53 @@
package difflib.myers;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
/**
* A diffnode in a diffpath.
* <p>
* A DiffNode and its previous node mark a delta between
* two input sequences, that is, two differing subsequences
* between (possibly zero length) matching sequences.
*
* {@link DiffNode DiffNodes} and {@link Snake Snakes} allow for compression
* of diffpaths, as each snake is represented by a single {@link Snake Snake}
* node and each contiguous series of insertions and deletions is represented
* by a single {@link DiffNode DiffNodes}.
*
* @version $Revision: 60 $ $Date: 2003-05-10 21:56:10 +0300 (Суб, 10 Май 2003) $
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*
*/
public final class DiffNode extends PathNode {
/**
* Constructs a DiffNode.
* <p>
* DiffNodes are compressed. That means that
* the path pointed to by the <code>prev</code> parameter
* will be followed using {@link PathNode#previousSnake}
* until a non-diff node is found.
*
* @param the position in the original sequence
* @param the position in the revised sequence
* @param prev the previous node in the path.
*/
public DiffNode(int i, int j, PathNode prev) {
super(i, j, (prev == null ? null : prev.previousSnake()));
}
/**
* {@inheritDoc}
* @return false, always
*/
public boolean isSnake() {
return false;
}
package difflib.myers;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
/**
* A diffnode in a diffpath.
* <p>
* A DiffNode and its previous node mark a delta between
* two input sequences, that is, two differing subsequences
* between (possibly zero length) matching sequences.
*
* {@link DiffNode DiffNodes} and {@link Snake Snakes} allow for compression
* of diffpaths, as each snake is represented by a single {@link Snake Snake}
* node and each contiguous series of insertions and deletions is represented
* by a single {@link DiffNode DiffNodes}.
*
* @version $Revision: 60 $ $Date: 2003-05-10 21:56:10 +0300 (Суб, 10 Май 2003) $
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*
*/
public final class DiffNode extends PathNode {
/**
* Constructs a DiffNode.
* <p>
* DiffNodes are compressed. That means that
* the path pointed to by the <code>prev</code> parameter
* will be followed using {@link PathNode#previousSnake}
* until a non-diff node is found.
*
* @param the position in the original sequence
* @param the position in the revised sequence
* @param prev the previous node in the path.
*/
public DiffNode(int i, int j, PathNode prev) {
super(i, j, (prev == null ? null : prev.previousSnake()));
}
/**
* {@inheritDoc}
* @return false, always
*/
public boolean isSnake() {
return false;
}
}
@@ -1,79 +1,79 @@
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
/**
* Thrown whenever the differencing engine cannot produce the differences
* between two revisions of ta text.
*
* @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
* @see MyersDiff
* @see difflib.DiffAlgorithm
*/
public class DifferentiationFailedException extends DiffException {
private static final long serialVersionUID = 1L;
public DifferentiationFailedException() {
}
public DifferentiationFailedException(String msg) {
super(msg);
}
}
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
/**
* Thrown whenever the differencing engine cannot produce the differences
* between two revisions of ta text.
*
* @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
* @see MyersDiff
* @see difflib.DiffAlgorithm
*/
public class DifferentiationFailedException extends DiffException {
private static final long serialVersionUID = 1L;
public DifferentiationFailedException() {
}
public DifferentiationFailedException(String msg) {
super(msg);
}
}
@@ -1,263 +1,263 @@
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import difflib.ChangeDelta;
import difflib.Chunk;
import difflib.DeleteDelta;
import difflib.Delta;
import difflib.DiffAlgorithm;
import difflib.InsertDelta;
import difflib.Patch;
/**
* A clean-room implementation of <a href="http://www.cs.arizona.edu/people/gene/">
* Eugene Myers</a> differencing algorithm.
*
* <p> See the paper at <a href="http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps">
* http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps</a></p>
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*/
public class MyersDiff<T> implements DiffAlgorithm<T> {
/**
* Constructs an instance of the Myers differencing algorithm.
*/
public MyersDiff() {
}
/**
* {@inheritDoc}
*
* Return empty diff if get the error while procession the difference.
*/
public Patch<T> diff(Iterable<T> original, Iterable<T> revised) {
List<T> originalList = new ArrayList<T>();
for (T o : original) {
originalList.add(o);
}
@SuppressWarnings("unchecked")
T[] originalArray = (T[]) originalList.toArray();
List<T> revisedList = new ArrayList<T>();
for (T o : revised) {
revisedList.add(o);
}
@SuppressWarnings("unchecked")
T[] revisedArray = (T[]) revisedList.toArray();
return diff(originalArray, revisedArray);
}
/**
* {@inheritDoc}
*
* Return empty diff if get the error while procession the difference.
*/
public Patch<T> diff(T[] orig, T[] rev) {
PathNode path;
try {
path = buildPath(orig, rev);
return buildRevision(path, orig, rev);
} catch (DifferentiationFailedException e) {
e.printStackTrace();
}
return new Patch<T>();
}
/**
* Computes the minimum diffpath that expresses the differences
* between the original and revised sequences, according
* to Gene Myers differencing algorithm.
*
* @param orig The original sequence.
* @param rev The revised sequence.
* @return A minimum {@link PathNode Path} accross the differences graph.
* @throws DifferentiationFailedException if a diff path could not be found.
*/
public static PathNode buildPath(Object[] orig, Object[] rev)
throws DifferentiationFailedException {
if (orig == null)
throw new IllegalArgumentException("original sequence is null");
if (rev == null)
throw new IllegalArgumentException("revised sequence is null");
// these are local constants
final int N = orig.length;
final int M = rev.length;
final int MAX = N + M + 1;
final int size = 1 + 2 * MAX;
final int middle = size / 2;
final PathNode diagonal[] = new PathNode[size];
diagonal[middle + 1] = new Snake(0, -1, null);
for (int d = 0; d < MAX; d++) {
for (int k = -d; k <= d; k += 2) {
final int kmiddle = middle + k;
final int kplus = kmiddle + 1;
final int kminus = kmiddle - 1;
PathNode prev = null;
int i;
if ((k == -d) || (k != d && diagonal[kminus].i < diagonal[kplus].i)) {
i = diagonal[kplus].i;
prev = diagonal[kplus];
} else {
i = diagonal[kminus].i + 1;
prev = diagonal[kminus];
}
diagonal[kminus] = null; // no longer used
int j = i - k;
PathNode node = new DiffNode(i, j, prev);
// orig and rev are zero-based
// but the algorithm is one-based
// that's why there's no +1 when indexing the sequences
while (i < N && j < M && orig[i].equals(rev[j])) {
i++;
j++;
}
if (i > node.i) {
node = new Snake(i, j, node);
}
diagonal[kmiddle] = node;
if (i >= N && j >= M) {
return diagonal[kmiddle];
}
}
diagonal[middle + d - 1] = null;
}
// According to Myers, this cannot happen
throw new DifferentiationFailedException("could not find a diff path");
}
/**
* Constructs a {@link Patch} from a difference path.
*
* @param path The path.
* @param orig The original sequence.
* @param rev The revised sequence.
* @return A {@link Patch} script corresponding to the path.
* @throws DifferentiationFailedException if a {@link Patch} could
* not be built from the given path.
*/
public static <T> Patch<T> buildRevision(PathNode path, T[] orig, T[] rev) {
if (path == null)
throw new IllegalArgumentException("path is null");
if (orig == null)
throw new IllegalArgumentException("original sequence is null");
if (rev == null)
throw new IllegalArgumentException("revised sequence is null");
Patch<T> patch = new Patch<T>();
if (path.isSnake())
path = path.prev;
while (path != null && path.prev != null && path.prev.j >= 0) {
if (path.isSnake())
throw new IllegalStateException("bad diffpath: found snake when looking for diff");
int i = path.i;
int j = path.j;
path = path.prev;
int ianchor = path.i;
int janchor = path.j;
Chunk<T> original = new Chunk<T>(ianchor, copyOfRange(orig, ianchor, i));
Chunk<T> revised = new Chunk<T>(janchor, copyOfRange(rev, janchor, j));
Delta<T> delta = null;
if (original.size() == 0 && revised.size() != 0) {
delta = new InsertDelta<T>(original, revised);
} else if (original.size() > 0 && revised.size() == 0) {
delta = new DeleteDelta<T>(original, revised);
} else {
delta = new ChangeDelta<T>(original, revised);
}
patch.addDelta(delta);
if (path.isSnake())
path = path.prev;
}
return patch;
}
/**
* Copied here from JDK 1.6
*/
@SuppressWarnings("unchecked")
public static <T> T[] copyOfRange(T[] original, int from, int to) {
return copyOfRange(original, from, to, (Class<T[]>) original.getClass());
}
/**
* Copied here from JDK 1.6
*/
@SuppressWarnings("unchecked")
public static <T, U> T[] copyOfRange(U[] original, int from, int to,
Class<? extends T[]> newType) {
int newLength = to - from;
if (newLength < 0)
throw new IllegalArgumentException(from + " > " + to);
T[] copy = ((Object) newType == (Object) Object[].class) ? (T[]) new Object[newLength]
: (T[]) Array.newInstance(newType.getComponentType(), newLength);
System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength));
return copy;
}
}
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import difflib.ChangeDelta;
import difflib.Chunk;
import difflib.DeleteDelta;
import difflib.Delta;
import difflib.DiffAlgorithm;
import difflib.InsertDelta;
import difflib.Patch;
/**
* A clean-room implementation of <a href="http://www.cs.arizona.edu/people/gene/">
* Eugene Myers</a> differencing algorithm.
*
* <p> See the paper at <a href="http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps">
* http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps</a></p>
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*/
public class MyersDiff<T> implements DiffAlgorithm<T> {
/**
* Constructs an instance of the Myers differencing algorithm.
*/
public MyersDiff() {
}
/**
* {@inheritDoc}
*
* Return empty diff if get the error while procession the difference.
*/
public Patch<T> diff(Iterable<T> original, Iterable<T> revised) {
List<T> originalList = new ArrayList<T>();
for (T o : original) {
originalList.add(o);
}
@SuppressWarnings("unchecked")
T[] originalArray = (T[]) originalList.toArray();
List<T> revisedList = new ArrayList<T>();
for (T o : revised) {
revisedList.add(o);
}
@SuppressWarnings("unchecked")
T[] revisedArray = (T[]) revisedList.toArray();
return diff(originalArray, revisedArray);
}
/**
* {@inheritDoc}
*
* Return empty diff if get the error while procession the difference.
*/
public Patch<T> diff(T[] orig, T[] rev) {
PathNode path;
try {
path = buildPath(orig, rev);
return buildRevision(path, orig, rev);
} catch (DifferentiationFailedException e) {
e.printStackTrace();
}
return new Patch<T>();
}
/**
* Computes the minimum diffpath that expresses the differences
* between the original and revised sequences, according
* to Gene Myers differencing algorithm.
*
* @param orig The original sequence.
* @param rev The revised sequence.
* @return A minimum {@link PathNode Path} accross the differences graph.
* @throws DifferentiationFailedException if a diff path could not be found.
*/
public static PathNode buildPath(Object[] orig, Object[] rev)
throws DifferentiationFailedException {
if (orig == null)
throw new IllegalArgumentException("original sequence is null");
if (rev == null)
throw new IllegalArgumentException("revised sequence is null");
// these are local constants
final int N = orig.length;
final int M = rev.length;
final int MAX = N + M + 1;
final int size = 1 + 2 * MAX;
final int middle = size / 2;
final PathNode diagonal[] = new PathNode[size];
diagonal[middle + 1] = new Snake(0, -1, null);
for (int d = 0; d < MAX; d++) {
for (int k = -d; k <= d; k += 2) {
final int kmiddle = middle + k;
final int kplus = kmiddle + 1;
final int kminus = kmiddle - 1;
PathNode prev = null;
int i;
if ((k == -d) || (k != d && diagonal[kminus].i < diagonal[kplus].i)) {
i = diagonal[kplus].i;
prev = diagonal[kplus];
} else {
i = diagonal[kminus].i + 1;
prev = diagonal[kminus];
}
diagonal[kminus] = null; // no longer used
int j = i - k;
PathNode node = new DiffNode(i, j, prev);
// orig and rev are zero-based
// but the algorithm is one-based
// that's why there's no +1 when indexing the sequences
while (i < N && j < M && orig[i].equals(rev[j])) {
i++;
j++;
}
if (i > node.i) {
node = new Snake(i, j, node);
}
diagonal[kmiddle] = node;
if (i >= N && j >= M) {
return diagonal[kmiddle];
}
}
diagonal[middle + d - 1] = null;
}
// According to Myers, this cannot happen
throw new DifferentiationFailedException("could not find a diff path");
}
/**
* Constructs a {@link Patch} from a difference path.
*
* @param path The path.
* @param orig The original sequence.
* @param rev The revised sequence.
* @return A {@link Patch} script corresponding to the path.
* @throws DifferentiationFailedException if a {@link Patch} could
* not be built from the given path.
*/
public static <T> Patch<T> buildRevision(PathNode path, T[] orig, T[] rev) {
if (path == null)
throw new IllegalArgumentException("path is null");
if (orig == null)
throw new IllegalArgumentException("original sequence is null");
if (rev == null)
throw new IllegalArgumentException("revised sequence is null");
Patch<T> patch = new Patch<T>();
if (path.isSnake())
path = path.prev;
while (path != null && path.prev != null && path.prev.j >= 0) {
if (path.isSnake())
throw new IllegalStateException("bad diffpath: found snake when looking for diff");
int i = path.i;
int j = path.j;
path = path.prev;
int ianchor = path.i;
int janchor = path.j;
Chunk<T> original = new Chunk<T>(ianchor, copyOfRange(orig, ianchor, i));
Chunk<T> revised = new Chunk<T>(janchor, copyOfRange(rev, janchor, j));
Delta<T> delta = null;
if (original.size() == 0 && revised.size() != 0) {
delta = new InsertDelta<T>(original, revised);
} else if (original.size() > 0 && revised.size() == 0) {
delta = new DeleteDelta<T>(original, revised);
} else {
delta = new ChangeDelta<T>(original, revised);
}
patch.addDelta(delta);
if (path.isSnake())
path = path.prev;
}
return patch;
}
/**
* Copied here from JDK 1.6
*/
@SuppressWarnings("unchecked")
public static <T> T[] copyOfRange(T[] original, int from, int to) {
return copyOfRange(original, from, to, (Class<T[]>) original.getClass());
}
/**
* Copied here from JDK 1.6
*/
@SuppressWarnings("unchecked")
public static <T, U> T[] copyOfRange(U[] original, int from, int to,
Class<? extends T[]> newType) {
int newLength = to - from;
if (newLength < 0)
throw new IllegalArgumentException(from + " > " + to);
T[] copy = ((Object) newType == (Object) Object[].class) ? (T[]) new Object[newLength]
: (T[]) Array.newInstance(newType.getComponentType(), newLength);
System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength));
return copy;
}
}
@@ -1,140 +1,140 @@
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
/**
* A node in a diffpath.
*
* @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*
* @see DiffNode
* @see Snake
*
*/
public abstract class PathNode {
/** Position in the original sequence. */
public final int i;
/** Position in the revised sequence. */
public final int j;
/** The previous node in the path. */
public final PathNode prev;
/**
* Concatenates a new path node with an existing diffpath.
* @param i The position in the original sequence for the new node.
* @param j The position in the revised sequence for the new node.
* @param prev The previous node in the path.
*/
public PathNode(int i, int j, PathNode prev) {
this.i = i;
this.j = j;
this.prev = prev;
}
/**
* Is this node a {@link Snake Snake node}?
* @return true if this is a {@link Snake Snake node}
*/
public abstract boolean isSnake();
/**
* Is this a bootstrap node?
* <p>
* In bottstrap nodes one of the two corrdinates is
* less than zero.
* @return tru if this is a bootstrap node.
*/
public boolean isBootstrap() {
return i < 0 || j < 0;
}
/**
* Skips sequences of {@link DiffNode DiffNodes} until a
* {@link Snake} or bootstrap node is found, or the end
* of the path is reached.
* @return The next first {@link Snake} or bootstrap node in the path, or
* <code>null</code>
* if none found.
*/
public final PathNode previousSnake() {
if (isBootstrap())
return null;
if (!isSnake() && prev != null)
return prev.previousSnake();
return this;
}
/**
* {@inheritDoc}
*/
public String toString() {
StringBuffer buf = new StringBuffer("[");
PathNode node = this;
while (node != null) {
buf.append("(");
buf.append(Integer.toString(node.i));
buf.append(",");
buf.append(Integer.toString(node.j));
buf.append(")");
node = node.prev;
}
buf.append("]");
return buf.toString();
}
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
/**
* A node in a diffpath.
*
* @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*
* @see DiffNode
* @see Snake
*
*/
public abstract class PathNode {
/** Position in the original sequence. */
public final int i;
/** Position in the revised sequence. */
public final int j;
/** The previous node in the path. */
public final PathNode prev;
/**
* Concatenates a new path node with an existing diffpath.
* @param i The position in the original sequence for the new node.
* @param j The position in the revised sequence for the new node.
* @param prev The previous node in the path.
*/
public PathNode(int i, int j, PathNode prev) {
this.i = i;
this.j = j;
this.prev = prev;
}
/**
* Is this node a {@link Snake Snake node}?
* @return true if this is a {@link Snake Snake node}
*/
public abstract boolean isSnake();
/**
* Is this a bootstrap node?
* <p>
* In bottstrap nodes one of the two corrdinates is
* less than zero.
* @return tru if this is a bootstrap node.
*/
public boolean isBootstrap() {
return i < 0 || j < 0;
}
/**
* Skips sequences of {@link DiffNode DiffNodes} until a
* {@link Snake} or bootstrap node is found, or the end
* of the path is reached.
* @return The next first {@link Snake} or bootstrap node in the path, or
* <code>null</code>
* if none found.
*/
public final PathNode previousSnake() {
if (isBootstrap())
return null;
if (!isSnake() && prev != null)
return prev.previousSnake();
return this;
}
/**
* {@inheritDoc}
*/
public String toString() {
StringBuffer buf = new StringBuffer("[");
PathNode node = this;
while (node != null) {
buf.append("(");
buf.append(Integer.toString(node.i));
buf.append(",");
buf.append(Integer.toString(node.j));
buf.append(")");
node = node.prev;
}
buf.append("]");
return buf.toString();
}
}
@@ -1,93 +1,93 @@
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
/**
* Represents a snake in a diffpath.
* <p>
*
* {@link DiffNode DiffNodes} and {@link Snake Snakes} allow for compression
* of diffpaths, as each snake is represented by a single {@link Snake Snake}
* node and each contiguous series of insertions and deletions is represented
* by a single {@link DiffNode DiffNodes}.
*
* @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*
*/
public final class Snake extends PathNode {
/**
* Constructs a snake node.
*
* @param the position in the original sequence
* @param the position in the revised sequence
* @param prev the previous node in the path.
*/
public Snake(int i, int j, PathNode prev) {
super(i, j, prev);
}
/**
* {@inheritDoc}
* @return true always
*/
public boolean isSnake() {
return true;
}
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package difflib.myers;
/**
* Represents a snake in a diffpath.
* <p>
*
* {@link DiffNode DiffNodes} and {@link Snake Snakes} allow for compression
* of diffpaths, as each snake is represented by a single {@link Snake Snake}
* node and each contiguous series of insertions and deletions is represented
* by a single {@link DiffNode DiffNodes}.
*
* @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*
*/
public final class Snake extends PathNode {
/**
* Constructs a snake node.
*
* @param the position in the original sequence
* @param the position in the revised sequence
* @param prev the previous node in the path.
*/
public Snake(int i, int j, PathNode prev) {
super(i, j, prev);
}
/**
* {@inheritDoc}
* @return true always
*/
public boolean isSnake() {
return true;
}
}
@@ -1,42 +1,42 @@
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utills Library.
Java Diff Utills Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utills Library 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utills Library. If not, see <http://www.gnu.org/licenses/>.
*/
-->
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Cygwin (vers 1st February 2003), see www.w3.org">
<title></title>
</head>
<body>
<p>
The {@link difflib.myers diff.myers} package
implements <a href=
"http://www.cs.arizona.edu/people/gene/">Gene Myers</a>'
differencing algorithm.
</p>
<p>
Myer's algorithm produces optimum results (minimum diffs), but
consumes considerably more memory than SimpleDiff, so its not
suitable for very large files.
</p>
@author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
</body>
</html>
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utills Library.
Java Diff Utills Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utills Library 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utills Library. If not, see <http://www.gnu.org/licenses/>.
*/
-->
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Cygwin (vers 1st February 2003), see www.w3.org">
<title></title>
</head>
<body>
<p>
The {@link difflib.myers diff.myers} package
implements <a href=
"http://www.cs.arizona.edu/people/gene/">Gene Myers</a>'
differencing algorithm.
</p>
<p>
Myer's algorithm produces optimum results (minimum diffs), but
consumes considerably more memory than SimpleDiff, so its not
suitable for very large files.
</p>
@author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
</body>
</html>
@@ -1,70 +1,70 @@
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-->
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Cygwin (vers 1st February 2003), see www.w3.org">
<title></title>
</head>
<body>
<p>
The {@link difflib difflib} package
implements general operation with diff files.
</p>
@author <a href="mailto:dm.naumenko@gmail.com">Dmitry Naumenko</a>
</body>
</html>
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-->
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Cygwin (vers 1st February 2003), see www.w3.org">
<title></title>
</head>
<body>
<p>
The {@link difflib difflib} package
implements general operation with diff files.
</p>
@author <a href="mailto:dm.naumenko@gmail.com">Dmitry Naumenko</a>
</body>
</html>
+7 -7
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/mgwt-2.0.0.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/mgwt-2.0.0.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -1,31 +1,31 @@
<<<<<<< HEAD:java/com.googlecode.mgwt/.settings/org.eclipse.jdt.core.prefs
#Thu Jan 19 09:46:08 CET 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
||||||| merged common ancestors
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
=======
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
>>>>>>> origin/master:java/com.sap.sailing.datamining.test/.settings/org.eclipse.jdt.core.prefs
<<<<<<< HEAD:java/com.googlecode.mgwt/.settings/org.eclipse.jdt.core.prefs
#Thu Jan 19 09:46:08 CET 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
||||||| merged common ancestors
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
=======
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
>>>>>>> origin/master:java/com.sap.sailing.datamining.test/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
#Mon Jul 04 13:02:58 CEST 2011
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
#Mon Jul 04 13:02:58 CEST 2011
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
+3 -3
View File
@@ -1,3 +1,3 @@
bin.includes = META-INF/,\
.,\
lib/mgwt-2.0.0.jar
bin.includes = META-INF/,\
.,\
lib/mgwt-2.0.0.jar
+13 -13
View File
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>root</artifactId>
<groupId>com.sap.sailing</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.googlecode.mgwt</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>root</artifactId>
<groupId>com.sap.sailing</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.googlecode.mgwt</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
@@ -1,157 +1,157 @@
package com.sap.sailing.barbados.resultimport.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import com.sap.sailing.barbados.resultimport.impl.BarbadosResultSpreadsheet;
import com.sap.sailing.barbados.resultimport.impl.ScoreCorrectionProviderImpl;
import com.sap.sailing.domain.common.MaxPointsReason;
import com.sap.sailing.domain.common.RegattaScoreCorrections;
import com.sap.sailing.domain.common.RegattaScoreCorrections.ScoreCorrectionsForRace;
import com.sap.sailing.resultimport.RegattaResults;
import com.sap.sailing.resultimport.ResultDocumentDescriptor;
import com.sap.sailing.resultimport.ResultDocumentProvider;
import com.sap.sailing.resultimport.impl.ResultDocumentDescriptorImpl;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class BarbadosResultImportTest {
private static final TimePoint NOW = MillisecondsTimePoint.now();
private static final String SAMPLE_INPUT_NAME_EMPTY_RESULTS = "RESULTS-505Barbados.xlsx";
private static final String SAMPLE_INPUT_NAME_SOME_RESULTS = "RESULTS2.xlsx";
private static final String RESOURCES = "resources/";
private BarbadosResultSpreadsheet spreadsheet;
private ScoreCorrectionProviderImpl scp;
private InputStream getInputStream(String filename) throws FileNotFoundException, IOException {
return new FileInputStream(getFile(filename));
}
private File getFile(String filename) {
return new File(RESOURCES + filename);
}
@Before
public void setUp() throws FileNotFoundException, IOException, Exception {
spreadsheet = new BarbadosResultSpreadsheet(getInputStream(SAMPLE_INPUT_NAME_EMPTY_RESULTS));
scp = new ScoreCorrectionProviderImpl(new ResultDocumentProvider() {
@Override
public Iterable<ResultDocumentDescriptor> getResultDocumentDescriptors() throws IOException {
List<ResultDocumentDescriptor> result = new ArrayList<>();
result.add(new ResultDocumentDescriptorImpl(getInputStream(SAMPLE_INPUT_NAME_EMPTY_RESULTS),
SAMPLE_INPUT_NAME_EMPTY_RESULTS, NOW));
return result;
}
});
}
@Test
public void testOpenDocument() {
assertNotNull(spreadsheet);
RegattaResults regattaResults = spreadsheet.getRegattaResults();
assertNotNull(regattaResults);
assertEquals("505", regattaResults.getMetadata().get(ScoreCorrectionProviderImpl.BOATCLASS_NAME_METADATA_PROPERTY));
}
@Test
public void testHasResultsThroughScoreCorrectionProvider() throws Exception {
Map<String, Set<Util.Pair<String, TimePoint>>> hasResultsFor = scp.getHasResultsForBoatClassFromDateByEventName();
assertNotNull(hasResultsFor);
assertEquals(1, hasResultsFor.size());
Entry<String, Set<Util.Pair<String, TimePoint>>> entry = hasResultsFor.entrySet().iterator().next();
assertEquals("505", entry.getValue().iterator().next().getA());
}
@Test
public void testResultsThroughScoreCorrectionProvider() throws Exception {
Map<String, Set<Util.Pair<String, TimePoint>>> hasResultsFor = scp.getHasResultsForBoatClassFromDateByEventName();
String eventName = hasResultsFor.entrySet().iterator().next().getKey();
String boatClassName = hasResultsFor.entrySet().iterator().next().getValue().iterator().next().getA();
TimePoint timePoint = hasResultsFor.entrySet().iterator().next().getValue().iterator().next().getB();
RegattaScoreCorrections result = scp.getScoreCorrections(eventName, boatClassName, timePoint);
Iterator<ScoreCorrectionsForRace> scfr = result.getScoreCorrectionsForRaces().iterator();
ScoreCorrectionsForRace scfr1 = scfr.next();
assertEquals("1", scfr1.getRaceNameOrNumber());
ScoreCorrectionsForRace scfr2 = scfr.next();
assertEquals("2", scfr2.getRaceNameOrNumber());
ScoreCorrectionsForRace scfr3 = scfr.next();
assertEquals("3", scfr3.getRaceNameOrNumber());
assertTrue(scfr1.getSailIDs().contains("GER 9113"));
assertTrue(scfr1.getSailIDs().contains("GER 9112"));
assertTrue(scfr1.getSailIDs().contains("GER 9110"));
assertEquals(3, scfr1.getScoreCorrectionForCompetitor("GER 9113").getPoints(), 0.0000000001);
assertEquals(7, scfr2.getScoreCorrectionForCompetitor("GER 9113").getPoints(), 0.0000000001);
assertEquals(78, scfr3.getScoreCorrectionForCompetitor("GER 9113").getPoints(), 0.0000000001);
assertSame(MaxPointsReason.DNF, scfr3.getScoreCorrectionForCompetitor("GER 9113").getMaxPointsReason());
assertEquals(2, scfr1.getScoreCorrectionForCompetitor("GER 9112").getPoints(), 0.0000000001);
assertEquals(9, scfr2.getScoreCorrectionForCompetitor("GER 9112").getPoints(), 0.0000000001);
assertEquals(9, scfr3.getScoreCorrectionForCompetitor("GER 9112").getPoints(), 0.0000000001);
assertNull(scfr3.getScoreCorrectionForCompetitor("GER 9112").getMaxPointsReason());
assertEquals(5, scfr1.getScoreCorrectionForCompetitor("GER 9110").getPoints(), 0.0000000001);
assertEquals(7, scfr2.getScoreCorrectionForCompetitor("GER 9110").getPoints(), 0.0000000001);
assertEquals(78, scfr3.getScoreCorrectionForCompetitor("GER 9110").getPoints(), 0.0000000001);
assertSame(MaxPointsReason.OCS, scfr3.getScoreCorrectionForCompetitor("GER 9110").getMaxPointsReason());
}
@Test
public void testResultsThroughScoreCorrectionProviderWithSomeExperimentalResults() throws Exception {
ScoreCorrectionProviderImpl scp2 = new ScoreCorrectionProviderImpl(new ResultDocumentProvider() {
@Override
public Iterable<ResultDocumentDescriptor> getResultDocumentDescriptors() throws IOException {
List<ResultDocumentDescriptor> result = new ArrayList<>();
result.add(new ResultDocumentDescriptorImpl(getInputStream(SAMPLE_INPUT_NAME_SOME_RESULTS),
SAMPLE_INPUT_NAME_SOME_RESULTS, NOW));
return result;
}
});
Map<String, Set<Util.Pair<String, TimePoint>>> hasResultsFor = scp2.getHasResultsForBoatClassFromDateByEventName();
String eventName = hasResultsFor.entrySet().iterator().next().getKey();
String boatClassName = hasResultsFor.entrySet().iterator().next().getValue().iterator().next().getA();
TimePoint timePoint = hasResultsFor.entrySet().iterator().next().getValue().iterator().next().getB();
RegattaScoreCorrections result = scp2.getScoreCorrections(eventName, boatClassName, timePoint);
Iterator<ScoreCorrectionsForRace> scfr = result.getScoreCorrectionsForRaces().iterator();
ScoreCorrectionsForRace scfr1 = scfr.next();
assertEquals("1", scfr1.getRaceNameOrNumber());
ScoreCorrectionsForRace scfr2 = scfr.next();
assertEquals("2", scfr2.getRaceNameOrNumber());
ScoreCorrectionsForRace scfr3 = scfr.next();
assertEquals("3", scfr3.getRaceNameOrNumber());
assertTrue(scfr1.getSailIDs().contains("FRA 9067"));
assertTrue(scfr1.getSailIDs().contains("GER 9071"));
assertTrue(scfr1.getSailIDs().contains("GBR 9079"));
assertEquals(18, scfr1.getScoreCorrectionForCompetitor("FRA 9067").getPoints(), 0.0000000001);
assertEquals(2, scfr2.getScoreCorrectionForCompetitor("FRA 9067").getPoints(), 0.0000000001);
assertEquals(18, scfr3.getScoreCorrectionForCompetitor("FRA 9067").getPoints(), 0.0000000001);
assertNull(scfr3.getScoreCorrectionForCompetitor("FRA 9067").getMaxPointsReason());
assertEquals(17, scfr1.getScoreCorrectionForCompetitor("GER 9071").getPoints(), 0.0000000001);
assertEquals(79, scfr2.getScoreCorrectionForCompetitor("GER 9071").getPoints(), 0.0000000001);
assertEquals(17, scfr3.getScoreCorrectionForCompetitor("GER 9071").getPoints(), 0.0000000001);
assertSame(MaxPointsReason.DNF, scfr2.getScoreCorrectionForCompetitor("GER 9071").getMaxPointsReason());
assertEquals(16, scfr1.getScoreCorrectionForCompetitor("GBR 9079").getPoints(), 0.0000000001);
assertEquals(6, scfr2.getScoreCorrectionForCompetitor("GBR 9079").getPoints(), 0.0000000001);
assertEquals(14, scfr3.getScoreCorrectionForCompetitor("GBR 9079").getPoints(), 0.0000000001);
}
}
package com.sap.sailing.barbados.resultimport.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import com.sap.sailing.barbados.resultimport.impl.BarbadosResultSpreadsheet;
import com.sap.sailing.barbados.resultimport.impl.ScoreCorrectionProviderImpl;
import com.sap.sailing.domain.common.MaxPointsReason;
import com.sap.sailing.domain.common.RegattaScoreCorrections;
import com.sap.sailing.domain.common.RegattaScoreCorrections.ScoreCorrectionsForRace;
import com.sap.sailing.resultimport.RegattaResults;
import com.sap.sailing.resultimport.ResultDocumentDescriptor;
import com.sap.sailing.resultimport.ResultDocumentProvider;
import com.sap.sailing.resultimport.impl.ResultDocumentDescriptorImpl;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class BarbadosResultImportTest {
private static final TimePoint NOW = MillisecondsTimePoint.now();
private static final String SAMPLE_INPUT_NAME_EMPTY_RESULTS = "RESULTS-505Barbados.xlsx";
private static final String SAMPLE_INPUT_NAME_SOME_RESULTS = "RESULTS2.xlsx";
private static final String RESOURCES = "resources/";
private BarbadosResultSpreadsheet spreadsheet;
private ScoreCorrectionProviderImpl scp;
private InputStream getInputStream(String filename) throws FileNotFoundException, IOException {
return new FileInputStream(getFile(filename));
}
private File getFile(String filename) {
return new File(RESOURCES + filename);
}
@Before
public void setUp() throws FileNotFoundException, IOException, Exception {
spreadsheet = new BarbadosResultSpreadsheet(getInputStream(SAMPLE_INPUT_NAME_EMPTY_RESULTS));
scp = new ScoreCorrectionProviderImpl(new ResultDocumentProvider() {
@Override
public Iterable<ResultDocumentDescriptor> getResultDocumentDescriptors() throws IOException {
List<ResultDocumentDescriptor> result = new ArrayList<>();
result.add(new ResultDocumentDescriptorImpl(getInputStream(SAMPLE_INPUT_NAME_EMPTY_RESULTS),
SAMPLE_INPUT_NAME_EMPTY_RESULTS, NOW));
return result;
}
});
}
@Test
public void testOpenDocument() {
assertNotNull(spreadsheet);
RegattaResults regattaResults = spreadsheet.getRegattaResults();
assertNotNull(regattaResults);
assertEquals("505", regattaResults.getMetadata().get(ScoreCorrectionProviderImpl.BOATCLASS_NAME_METADATA_PROPERTY));
}
@Test
public void testHasResultsThroughScoreCorrectionProvider() throws Exception {
Map<String, Set<Util.Pair<String, TimePoint>>> hasResultsFor = scp.getHasResultsForBoatClassFromDateByEventName();
assertNotNull(hasResultsFor);
assertEquals(1, hasResultsFor.size());
Entry<String, Set<Util.Pair<String, TimePoint>>> entry = hasResultsFor.entrySet().iterator().next();
assertEquals("505", entry.getValue().iterator().next().getA());
}
@Test
public void testResultsThroughScoreCorrectionProvider() throws Exception {
Map<String, Set<Util.Pair<String, TimePoint>>> hasResultsFor = scp.getHasResultsForBoatClassFromDateByEventName();
String eventName = hasResultsFor.entrySet().iterator().next().getKey();
String boatClassName = hasResultsFor.entrySet().iterator().next().getValue().iterator().next().getA();
TimePoint timePoint = hasResultsFor.entrySet().iterator().next().getValue().iterator().next().getB();
RegattaScoreCorrections result = scp.getScoreCorrections(eventName, boatClassName, timePoint);
Iterator<ScoreCorrectionsForRace> scfr = result.getScoreCorrectionsForRaces().iterator();
ScoreCorrectionsForRace scfr1 = scfr.next();
assertEquals("1", scfr1.getRaceNameOrNumber());
ScoreCorrectionsForRace scfr2 = scfr.next();
assertEquals("2", scfr2.getRaceNameOrNumber());
ScoreCorrectionsForRace scfr3 = scfr.next();
assertEquals("3", scfr3.getRaceNameOrNumber());
assertTrue(scfr1.getSailIDs().contains("GER 9113"));
assertTrue(scfr1.getSailIDs().contains("GER 9112"));
assertTrue(scfr1.getSailIDs().contains("GER 9110"));
assertEquals(3, scfr1.getScoreCorrectionForCompetitor("GER 9113").getPoints(), 0.0000000001);
assertEquals(7, scfr2.getScoreCorrectionForCompetitor("GER 9113").getPoints(), 0.0000000001);
assertEquals(78, scfr3.getScoreCorrectionForCompetitor("GER 9113").getPoints(), 0.0000000001);
assertSame(MaxPointsReason.DNF, scfr3.getScoreCorrectionForCompetitor("GER 9113").getMaxPointsReason());
assertEquals(2, scfr1.getScoreCorrectionForCompetitor("GER 9112").getPoints(), 0.0000000001);
assertEquals(9, scfr2.getScoreCorrectionForCompetitor("GER 9112").getPoints(), 0.0000000001);
assertEquals(9, scfr3.getScoreCorrectionForCompetitor("GER 9112").getPoints(), 0.0000000001);
assertNull(scfr3.getScoreCorrectionForCompetitor("GER 9112").getMaxPointsReason());
assertEquals(5, scfr1.getScoreCorrectionForCompetitor("GER 9110").getPoints(), 0.0000000001);
assertEquals(7, scfr2.getScoreCorrectionForCompetitor("GER 9110").getPoints(), 0.0000000001);
assertEquals(78, scfr3.getScoreCorrectionForCompetitor("GER 9110").getPoints(), 0.0000000001);
assertSame(MaxPointsReason.OCS, scfr3.getScoreCorrectionForCompetitor("GER 9110").getMaxPointsReason());
}
@Test
public void testResultsThroughScoreCorrectionProviderWithSomeExperimentalResults() throws Exception {
ScoreCorrectionProviderImpl scp2 = new ScoreCorrectionProviderImpl(new ResultDocumentProvider() {
@Override
public Iterable<ResultDocumentDescriptor> getResultDocumentDescriptors() throws IOException {
List<ResultDocumentDescriptor> result = new ArrayList<>();
result.add(new ResultDocumentDescriptorImpl(getInputStream(SAMPLE_INPUT_NAME_SOME_RESULTS),
SAMPLE_INPUT_NAME_SOME_RESULTS, NOW));
return result;
}
});
Map<String, Set<Util.Pair<String, TimePoint>>> hasResultsFor = scp2.getHasResultsForBoatClassFromDateByEventName();
String eventName = hasResultsFor.entrySet().iterator().next().getKey();
String boatClassName = hasResultsFor.entrySet().iterator().next().getValue().iterator().next().getA();
TimePoint timePoint = hasResultsFor.entrySet().iterator().next().getValue().iterator().next().getB();
RegattaScoreCorrections result = scp2.getScoreCorrections(eventName, boatClassName, timePoint);
Iterator<ScoreCorrectionsForRace> scfr = result.getScoreCorrectionsForRaces().iterator();
ScoreCorrectionsForRace scfr1 = scfr.next();
assertEquals("1", scfr1.getRaceNameOrNumber());
ScoreCorrectionsForRace scfr2 = scfr.next();
assertEquals("2", scfr2.getRaceNameOrNumber());
ScoreCorrectionsForRace scfr3 = scfr.next();
assertEquals("3", scfr3.getRaceNameOrNumber());
assertTrue(scfr1.getSailIDs().contains("FRA 9067"));
assertTrue(scfr1.getSailIDs().contains("GER 9071"));
assertTrue(scfr1.getSailIDs().contains("GBR 9079"));
assertEquals(18, scfr1.getScoreCorrectionForCompetitor("FRA 9067").getPoints(), 0.0000000001);
assertEquals(2, scfr2.getScoreCorrectionForCompetitor("FRA 9067").getPoints(), 0.0000000001);
assertEquals(18, scfr3.getScoreCorrectionForCompetitor("FRA 9067").getPoints(), 0.0000000001);
assertNull(scfr3.getScoreCorrectionForCompetitor("FRA 9067").getMaxPointsReason());
assertEquals(17, scfr1.getScoreCorrectionForCompetitor("GER 9071").getPoints(), 0.0000000001);
assertEquals(79, scfr2.getScoreCorrectionForCompetitor("GER 9071").getPoints(), 0.0000000001);
assertEquals(17, scfr3.getScoreCorrectionForCompetitor("GER 9071").getPoints(), 0.0000000001);
assertSame(MaxPointsReason.DNF, scfr2.getScoreCorrectionForCompetitor("GER 9071").getMaxPointsReason());
assertEquals(16, scfr1.getScoreCorrectionForCompetitor("GBR 9079").getPoints(), 0.0000000001);
assertEquals(6, scfr2.getScoreCorrectionForCompetitor("GBR 9079").getPoints(), 0.0000000001);
assertEquals(14, scfr3.getScoreCorrectionForCompetitor("GBR 9079").getPoints(), 0.0000000001);
}
}
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -1,101 +1,101 @@
package com.sap.sailing.barbados.resultimport.impl;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import com.sap.sailing.resultimport.CompetitorEntry;
import com.sap.sailing.resultimport.CompetitorRow;
import com.sap.sailing.resultimport.RegattaResults;
import com.sap.sailing.resultimport.impl.CompetitorRowImpl;
import com.sap.sailing.resultimport.impl.DefaultCompetitorEntryImpl;
public class BarbadosResultSpreadsheet {
private static final int COLUMN_NUMBER_OF_FIRST_RACE_RANK = 5;
private static final String RACE_SCORE_COLUMN_NAME = "TOTAL SCORE";
private static final String OVERALL_RESULTS_SHEET_NAME = "OVERALL RESULTS";
private Sheet overallResultsSheet;
public BarbadosResultSpreadsheet(InputStream is) throws Exception {
Workbook wb = WorkbookFactory.create(is);
overallResultsSheet = wb.getSheet(OVERALL_RESULTS_SHEET_NAME);
}
public RegattaResults getRegattaResults() {
final List<CompetitorRow> competitorRows = new ArrayList<>();
Row header = overallResultsSheet.getRow(0);
int i=COLUMN_NUMBER_OF_FIRST_RACE_RANK;
while (i<=header.getLastCellNum() && !header.getCell(i).getStringCellValue().equals(RACE_SCORE_COLUMN_NAME)) {
i++;
}
if (i>header.getLastCellNum() || !header.getCell(i).getStringCellValue().equals(RACE_SCORE_COLUMN_NAME)) {
throw new IllegalArgumentException("Didn't find "+RACE_SCORE_COLUMN_NAME+" column");
}
final int numberOfRaces = i-COLUMN_NUMBER_OF_FIRST_RACE_RANK;
final int columnNumberOfTotalScore = i;
final int columnNumberOfNetScore = columnNumberOfTotalScore+1;
final int columnNumberOfFirstRaceScore = columnNumberOfNetScore+2;
int rowIndex = 1;
Row row;
String iocCountryCode;
while ((row=overallResultsSheet.getRow(rowIndex)) != null && (iocCountryCode = row.getCell(1).getStringCellValue()) != null && !iocCountryCode.isEmpty()) {
Integer totalRank = row.getCell(0) == null ? null : (int) row.getCell(0).getNumericCellValue();
String sailID = iocCountryCode.trim() + " " + ((int) row.getCell(2).getNumericCellValue());
String helm = row.getCell(3).getStringCellValue();
String crew = row.getCell(4).getStringCellValue();
Iterable<String> names = Arrays.asList(new String[] { helm, crew });
double scoreAfterDiscarding = row.getCell(columnNumberOfNetScore).getNumericCellValue();
final Cell cellValue = row.getCell(columnNumberOfTotalScore);
double totalPointsBeforeDiscarding = cellValue == null ? null : cellValue.getNumericCellValue();
List<CompetitorEntry> rankAndMaxPointsReasonAndPointsAndDiscarded = new ArrayList<>();
for (int raceNumber=0; raceNumber<numberOfRaces; raceNumber++) {
final Cell rankOrMaxPointReasonCell = row.getCell(COLUMN_NUMBER_OF_FIRST_RACE_RANK+raceNumber);
Integer rank;
String maxPointsReason;
try {
rank = (int) rankOrMaxPointReasonCell.getNumericCellValue();
maxPointsReason = null;
} catch (IllegalStateException e) {
// not a numeric value; try to parse text / IRM / MaxPointsReason
rank = null;
maxPointsReason = rankOrMaxPointReasonCell.getStringCellValue();
}
final Cell scoreCellContents = row.getCell(columnNumberOfFirstRaceScore+raceNumber);
double score = scoreCellContents == null ? 0.0 : scoreCellContents.getNumericCellValue();
if (score != 0.0) {
CompetitorEntry entry = new DefaultCompetitorEntryImpl(rank,
maxPointsReason, score, /* discarded */ false);
rankAndMaxPointsReasonAndPointsAndDiscarded.add(entry);
} else {
rankAndMaxPointsReasonAndPointsAndDiscarded.add(null);
}
}
CompetitorRow competitorRow = new CompetitorRowImpl(totalRank, sailID, names, scoreAfterDiscarding,
totalPointsBeforeDiscarding, rankAndMaxPointsReasonAndPointsAndDiscarded);
competitorRows.add(competitorRow);
rowIndex++;
}
return new RegattaResults() {
@Override
public Map<String, String> getMetadata() {
Map<String, String> result = new HashMap<>();
result.put(ScoreCorrectionProviderImpl.BOATCLASS_NAME_METADATA_PROPERTY, "505");
return result;
}
@Override
public List<CompetitorRow> getCompetitorResults() {
return competitorRows;
}
};
}
}
package com.sap.sailing.barbados.resultimport.impl;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import com.sap.sailing.resultimport.CompetitorEntry;
import com.sap.sailing.resultimport.CompetitorRow;
import com.sap.sailing.resultimport.RegattaResults;
import com.sap.sailing.resultimport.impl.CompetitorRowImpl;
import com.sap.sailing.resultimport.impl.DefaultCompetitorEntryImpl;
public class BarbadosResultSpreadsheet {
private static final int COLUMN_NUMBER_OF_FIRST_RACE_RANK = 5;
private static final String RACE_SCORE_COLUMN_NAME = "TOTAL SCORE";
private static final String OVERALL_RESULTS_SHEET_NAME = "OVERALL RESULTS";
private Sheet overallResultsSheet;
public BarbadosResultSpreadsheet(InputStream is) throws Exception {
Workbook wb = WorkbookFactory.create(is);
overallResultsSheet = wb.getSheet(OVERALL_RESULTS_SHEET_NAME);
}
public RegattaResults getRegattaResults() {
final List<CompetitorRow> competitorRows = new ArrayList<>();
Row header = overallResultsSheet.getRow(0);
int i=COLUMN_NUMBER_OF_FIRST_RACE_RANK;
while (i<=header.getLastCellNum() && !header.getCell(i).getStringCellValue().equals(RACE_SCORE_COLUMN_NAME)) {
i++;
}
if (i>header.getLastCellNum() || !header.getCell(i).getStringCellValue().equals(RACE_SCORE_COLUMN_NAME)) {
throw new IllegalArgumentException("Didn't find "+RACE_SCORE_COLUMN_NAME+" column");
}
final int numberOfRaces = i-COLUMN_NUMBER_OF_FIRST_RACE_RANK;
final int columnNumberOfTotalScore = i;
final int columnNumberOfNetScore = columnNumberOfTotalScore+1;
final int columnNumberOfFirstRaceScore = columnNumberOfNetScore+2;
int rowIndex = 1;
Row row;
String iocCountryCode;
while ((row=overallResultsSheet.getRow(rowIndex)) != null && (iocCountryCode = row.getCell(1).getStringCellValue()) != null && !iocCountryCode.isEmpty()) {
Integer totalRank = row.getCell(0) == null ? null : (int) row.getCell(0).getNumericCellValue();
String sailID = iocCountryCode.trim() + " " + ((int) row.getCell(2).getNumericCellValue());
String helm = row.getCell(3).getStringCellValue();
String crew = row.getCell(4).getStringCellValue();
Iterable<String> names = Arrays.asList(new String[] { helm, crew });
double scoreAfterDiscarding = row.getCell(columnNumberOfNetScore).getNumericCellValue();
final Cell cellValue = row.getCell(columnNumberOfTotalScore);
double totalPointsBeforeDiscarding = cellValue == null ? null : cellValue.getNumericCellValue();
List<CompetitorEntry> rankAndMaxPointsReasonAndPointsAndDiscarded = new ArrayList<>();
for (int raceNumber=0; raceNumber<numberOfRaces; raceNumber++) {
final Cell rankOrMaxPointReasonCell = row.getCell(COLUMN_NUMBER_OF_FIRST_RACE_RANK+raceNumber);
Integer rank;
String maxPointsReason;
try {
rank = (int) rankOrMaxPointReasonCell.getNumericCellValue();
maxPointsReason = null;
} catch (IllegalStateException e) {
// not a numeric value; try to parse text / IRM / MaxPointsReason
rank = null;
maxPointsReason = rankOrMaxPointReasonCell.getStringCellValue();
}
final Cell scoreCellContents = row.getCell(columnNumberOfFirstRaceScore+raceNumber);
double score = scoreCellContents == null ? 0.0 : scoreCellContents.getNumericCellValue();
if (score != 0.0) {
CompetitorEntry entry = new DefaultCompetitorEntryImpl(rank,
maxPointsReason, score, /* discarded */ false);
rankAndMaxPointsReasonAndPointsAndDiscarded.add(entry);
} else {
rankAndMaxPointsReasonAndPointsAndDiscarded.add(null);
}
}
CompetitorRow competitorRow = new CompetitorRowImpl(totalRank, sailID, names, scoreAfterDiscarding,
totalPointsBeforeDiscarding, rankAndMaxPointsReasonAndPointsAndDiscarded);
competitorRows.add(competitorRow);
rowIndex++;
}
return new RegattaResults() {
@Override
public Map<String, String> getMetadata() {
Map<String, String> result = new HashMap<>();
result.put(ScoreCorrectionProviderImpl.BOATCLASS_NAME_METADATA_PROPERTY, "505");
return result;
}
@Override
public List<CompetitorRow> getCompetitorResults() {
return competitorRows;
}
};
}
}
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+28 -28
View File
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.sap.sailing.competitorimport</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.sap.sailing.competitorimport</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
@@ -1,3 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
@@ -1,4 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -1,47 +1,47 @@
package com.sap.sailing.competitorimport;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.JAXBException;
import com.sap.sailing.domain.common.CompetitorDescriptor;
import com.sap.sse.common.Named;
/**
* Competitor data may come from various sources, such as external regatta management systems (RMS),
* CSV files, Excel spreadsheets and the like. When creating a regatta that uses "RaceLog Tracking"
* (also known as Smartphone Tracking)---and be it only in order to manage results for the regatta
* with the race committee app---it is tedious having to enter all competitor data manually when
* that data is already available in electronic form.<p>
*
* In its simplest form, a provider will just produce an otherwise unstructured list of competitor
* entries with no hint as to the event, regatta or race that the competitor pertains to. More
* sophisticated providers may structure competitor data into events, regattas or even individual
* races so that importing these competitors into a single fleet of one race column becomes possible.
* This will be particularly useful for split-fleet racing.
*
* @author Axel Uhl (d043530)
*
*/
public interface CompetitorProvider extends Named {
/**
* @return keys are event names, values are the names of the regatta in the event for which the connector has
* competitor names. Should the value for a key be <code>null</code>, competitors for the event may still
* be available, only they may not be keyed per regatta in that case.
*/
Map<String, Set<String>> getHasCompetitorsForRegattasInEvent() throws IOException;
/**
* Obtains competitor records from the source of import
*
* @param eventName
* an event name as obtained as a key in {@link #getHasCompetitorsForRegattasInEvent()}'s result
* @param regattaName
* <code>null</code> to get the competitors for all regattas in the event specified by
* <code>eventName</code>, or a regatta name as provided in the value set for the key
* <code>eventName</code> as returned by {@link #getHasCompetitorsForRegattasInEvent()}.
*/
Iterable<CompetitorDescriptor> getCompetitorDescriptors(String eventName, String regattaName) throws JAXBException, IOException;
}
package com.sap.sailing.competitorimport;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.JAXBException;
import com.sap.sailing.domain.common.CompetitorDescriptor;
import com.sap.sse.common.Named;
/**
* Competitor data may come from various sources, such as external regatta management systems (RMS),
* CSV files, Excel spreadsheets and the like. When creating a regatta that uses "RaceLog Tracking"
* (also known as Smartphone Tracking)---and be it only in order to manage results for the regatta
* with the race committee app---it is tedious having to enter all competitor data manually when
* that data is already available in electronic form.<p>
*
* In its simplest form, a provider will just produce an otherwise unstructured list of competitor
* entries with no hint as to the event, regatta or race that the competitor pertains to. More
* sophisticated providers may structure competitor data into events, regattas or even individual
* races so that importing these competitors into a single fleet of one race column becomes possible.
* This will be particularly useful for split-fleet racing.
*
* @author Axel Uhl (d043530)
*
*/
public interface CompetitorProvider extends Named {
/**
* @return keys are event names, values are the names of the regatta in the event for which the connector has
* competitor names. Should the value for a key be <code>null</code>, competitors for the event may still
* be available, only they may not be keyed per regatta in that case.
*/
Map<String, Set<String>> getHasCompetitorsForRegattasInEvent() throws IOException;
/**
* Obtains competitor records from the source of import
*
* @param eventName
* an event name as obtained as a key in {@link #getHasCompetitorsForRegattasInEvent()}'s result
* @param regattaName
* <code>null</code> to get the competitors for all regattas in the event specified by
* <code>eventName</code>, or a regatta name as provided in the value set for the key
* <code>eventName</code> as returned by {@link #getHasCompetitorsForRegattasInEvent()}.
*/
Iterable<CompetitorDescriptor> getCompetitorDescriptors(String eventName, String regattaName) throws JAXBException, IOException;
}
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
@@ -1,3 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
@@ -1,4 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -1,166 +1,166 @@
package com.sap.sailing.datamining;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.osgi.framework.BundleContext;
import com.sap.sailing.datamining.data.HasBravoFixContext;
import com.sap.sailing.datamining.data.HasBravoFixTrackContext;
import com.sap.sailing.datamining.data.HasFoilingSegmentContext;
import com.sap.sailing.datamining.data.HasGPSFixContext;
import com.sap.sailing.datamining.data.HasLeaderboardContext;
import com.sap.sailing.datamining.data.HasLeaderboardGroupContext;
import com.sap.sailing.datamining.data.HasManeuverContext;
import com.sap.sailing.datamining.data.HasMarkPassingContext;
import com.sap.sailing.datamining.data.HasRaceOfCompetitorContext;
import com.sap.sailing.datamining.data.HasRaceResultOfCompetitorContext;
import com.sap.sailing.datamining.data.HasTrackedLegContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.datamining.data.HasTrackedRaceContext;
import com.sap.sailing.datamining.data.HasWindFixContext;
import com.sap.sailing.datamining.data.HasWindTrackContext;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelBearingAverageDegreesAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelBearingMaxAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelBearingMinAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelBoolSumAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceAverageAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceMaxAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceMedianAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceMinAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceSumAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDurationAverageAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDurationMaxAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDurationMinAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDurationSumAggregationProcessor;
import com.sap.sailing.datamining.provider.RacingEventServiceProvider;
import com.sap.sse.datamining.DataSourceProvider;
import com.sap.sse.datamining.components.AggregationProcessorDefinition;
import com.sap.sse.datamining.components.DataRetrieverChainDefinition;
import com.sap.sse.datamining.impl.AbstractDataMiningActivatorWithPredefinedQueries;
import com.sap.sse.datamining.shared.dto.StatisticQueryDefinitionDTO;
import com.sap.sse.datamining.shared.impl.PredefinedQueryIdentifier;
import com.sap.sse.i18n.ResourceBundleStringMessages;
import com.sap.sse.i18n.impl.ResourceBundleStringMessagesImpl;
public class Activator extends AbstractDataMiningActivatorWithPredefinedQueries {
private static final String STRING_MESSAGES_BASE_NAME = "stringmessages/Sailing_StringMessages";
private static final SailingClusterGroups clusterGroups = new SailingClusterGroups();
private static Activator INSTANCE;
private BundleContext context = null;
private final ResourceBundleStringMessages sailingServerStringMessages;
private final SailingDataRetrievalChainDefinitions dataRetrieverChainDefinitions;
private final SailingPredefinedQueries predefinedQueries;
private Collection<DataSourceProvider<?>> dataSourceProviders;
private boolean dataSourceProvidersHaveBeenInitialized;
public Activator() {
sailingServerStringMessages = new ResourceBundleStringMessagesImpl(STRING_MESSAGES_BASE_NAME, getClassLoader(),
StandardCharsets.UTF_8.name());
dataRetrieverChainDefinitions = new SailingDataRetrievalChainDefinitions();
predefinedQueries = new SailingPredefinedQueries();
}
@Override
public void start(BundleContext context) throws Exception {
INSTANCE = this;
this.context = context;
dataSourceProvidersHaveBeenInitialized = false;
super.start(context);
}
@Override
public void stop(BundleContext context) throws Exception {
this.context = null;
INSTANCE = null;
super.stop(context);
}
@Override
public ResourceBundleStringMessages getStringMessages() {
return sailingServerStringMessages;
}
@Override
public Iterable<Class<?>> getClassesWithMarkedMethods() {
Set<Class<?>> internalClasses = new HashSet<>();
internalClasses.add(HasTrackedRaceContext.class);
internalClasses.add(HasRaceResultOfCompetitorContext.class);
internalClasses.add(HasTrackedLegContext.class);
internalClasses.add(HasTrackedLegOfCompetitorContext.class);
internalClasses.add(HasGPSFixContext.class);
internalClasses.add(HasWindTrackContext.class);
internalClasses.add(HasWindFixContext.class);
internalClasses.add(HasBravoFixContext.class);
internalClasses.add(HasBravoFixTrackContext.class);
internalClasses.add(HasFoilingSegmentContext.class);
internalClasses.add(HasManeuverContext.class);
internalClasses.add(HasMarkPassingContext.class);
internalClasses.add(HasRaceOfCompetitorContext.class);
internalClasses.add(HasLeaderboardGroupContext.class);
internalClasses.add(HasLeaderboardContext.class);
return internalClasses;
}
@Override
public Iterable<DataRetrieverChainDefinition<?, ?>> getDataRetrieverChainDefinitions() {
return dataRetrieverChainDefinitions.get();
}
@Override
public Iterable<DataSourceProvider<?>> getDataSourceProviders() {
if (!dataSourceProvidersHaveBeenInitialized) {
initializeDataSourceProviders();
dataSourceProvidersHaveBeenInitialized = true;
}
return dataSourceProviders;
}
@Override
public Iterable<AggregationProcessorDefinition<?, ?>> getAggregationProcessorDefinitions() {
HashSet<AggregationProcessorDefinition<?, ?>> aggregators = new HashSet<>();
aggregators.add(ParallelBoolSumAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceSumAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceAverageAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceMaxAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceMinAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceMedianAggregationProcessor.getDefinition());
aggregators.add(ParallelDurationSumAggregationProcessor.getDefinition());
aggregators.add(ParallelDurationAverageAggregationProcessor.getDefinition());
aggregators.add(ParallelDurationMaxAggregationProcessor.getDefinition());
aggregators.add(ParallelDurationMinAggregationProcessor.getDefinition());
aggregators.add(ParallelBearingAverageDegreesAggregationProcessor.getDefinition());
aggregators.add(ParallelBearingMaxAggregationProcessor.getDefinition());
aggregators.add(ParallelBearingMinAggregationProcessor.getDefinition());
return aggregators;
}
@Override
public Map<PredefinedQueryIdentifier, StatisticQueryDefinitionDTO> getPredefinedQueries() {
return predefinedQueries.getQueries();
}
private void initializeDataSourceProviders() {
dataSourceProviders = new HashSet<>();
dataSourceProviders.add(new RacingEventServiceProvider(context));
}
public static SailingClusterGroups getClusterGroups() {
return clusterGroups;
}
public static Activator getDefault() {
if (INSTANCE == null) {
INSTANCE = new Activator(); // probably non-OSGi case, as in test execution
}
return INSTANCE;
}
}
package com.sap.sailing.datamining;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.osgi.framework.BundleContext;
import com.sap.sailing.datamining.data.HasBravoFixContext;
import com.sap.sailing.datamining.data.HasBravoFixTrackContext;
import com.sap.sailing.datamining.data.HasFoilingSegmentContext;
import com.sap.sailing.datamining.data.HasGPSFixContext;
import com.sap.sailing.datamining.data.HasLeaderboardContext;
import com.sap.sailing.datamining.data.HasLeaderboardGroupContext;
import com.sap.sailing.datamining.data.HasManeuverContext;
import com.sap.sailing.datamining.data.HasMarkPassingContext;
import com.sap.sailing.datamining.data.HasRaceOfCompetitorContext;
import com.sap.sailing.datamining.data.HasRaceResultOfCompetitorContext;
import com.sap.sailing.datamining.data.HasTrackedLegContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.datamining.data.HasTrackedRaceContext;
import com.sap.sailing.datamining.data.HasWindFixContext;
import com.sap.sailing.datamining.data.HasWindTrackContext;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelBearingAverageDegreesAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelBearingMaxAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelBearingMinAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelBoolSumAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceAverageAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceMaxAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceMedianAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceMinAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDistanceSumAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDurationAverageAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDurationMaxAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDurationMinAggregationProcessor;
import com.sap.sailing.datamining.impl.components.aggregators.ParallelDurationSumAggregationProcessor;
import com.sap.sailing.datamining.provider.RacingEventServiceProvider;
import com.sap.sse.datamining.DataSourceProvider;
import com.sap.sse.datamining.components.AggregationProcessorDefinition;
import com.sap.sse.datamining.components.DataRetrieverChainDefinition;
import com.sap.sse.datamining.impl.AbstractDataMiningActivatorWithPredefinedQueries;
import com.sap.sse.datamining.shared.dto.StatisticQueryDefinitionDTO;
import com.sap.sse.datamining.shared.impl.PredefinedQueryIdentifier;
import com.sap.sse.i18n.ResourceBundleStringMessages;
import com.sap.sse.i18n.impl.ResourceBundleStringMessagesImpl;
public class Activator extends AbstractDataMiningActivatorWithPredefinedQueries {
private static final String STRING_MESSAGES_BASE_NAME = "stringmessages/Sailing_StringMessages";
private static final SailingClusterGroups clusterGroups = new SailingClusterGroups();
private static Activator INSTANCE;
private BundleContext context = null;
private final ResourceBundleStringMessages sailingServerStringMessages;
private final SailingDataRetrievalChainDefinitions dataRetrieverChainDefinitions;
private final SailingPredefinedQueries predefinedQueries;
private Collection<DataSourceProvider<?>> dataSourceProviders;
private boolean dataSourceProvidersHaveBeenInitialized;
public Activator() {
sailingServerStringMessages = new ResourceBundleStringMessagesImpl(STRING_MESSAGES_BASE_NAME, getClassLoader(),
StandardCharsets.UTF_8.name());
dataRetrieverChainDefinitions = new SailingDataRetrievalChainDefinitions();
predefinedQueries = new SailingPredefinedQueries();
}
@Override
public void start(BundleContext context) throws Exception {
INSTANCE = this;
this.context = context;
dataSourceProvidersHaveBeenInitialized = false;
super.start(context);
}
@Override
public void stop(BundleContext context) throws Exception {
this.context = null;
INSTANCE = null;
super.stop(context);
}
@Override
public ResourceBundleStringMessages getStringMessages() {
return sailingServerStringMessages;
}
@Override
public Iterable<Class<?>> getClassesWithMarkedMethods() {
Set<Class<?>> internalClasses = new HashSet<>();
internalClasses.add(HasTrackedRaceContext.class);
internalClasses.add(HasRaceResultOfCompetitorContext.class);
internalClasses.add(HasTrackedLegContext.class);
internalClasses.add(HasTrackedLegOfCompetitorContext.class);
internalClasses.add(HasGPSFixContext.class);
internalClasses.add(HasWindTrackContext.class);
internalClasses.add(HasWindFixContext.class);
internalClasses.add(HasBravoFixContext.class);
internalClasses.add(HasBravoFixTrackContext.class);
internalClasses.add(HasFoilingSegmentContext.class);
internalClasses.add(HasManeuverContext.class);
internalClasses.add(HasMarkPassingContext.class);
internalClasses.add(HasRaceOfCompetitorContext.class);
internalClasses.add(HasLeaderboardGroupContext.class);
internalClasses.add(HasLeaderboardContext.class);
return internalClasses;
}
@Override
public Iterable<DataRetrieverChainDefinition<?, ?>> getDataRetrieverChainDefinitions() {
return dataRetrieverChainDefinitions.get();
}
@Override
public Iterable<DataSourceProvider<?>> getDataSourceProviders() {
if (!dataSourceProvidersHaveBeenInitialized) {
initializeDataSourceProviders();
dataSourceProvidersHaveBeenInitialized = true;
}
return dataSourceProviders;
}
@Override
public Iterable<AggregationProcessorDefinition<?, ?>> getAggregationProcessorDefinitions() {
HashSet<AggregationProcessorDefinition<?, ?>> aggregators = new HashSet<>();
aggregators.add(ParallelBoolSumAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceSumAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceAverageAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceMaxAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceMinAggregationProcessor.getDefinition());
aggregators.add(ParallelDistanceMedianAggregationProcessor.getDefinition());
aggregators.add(ParallelDurationSumAggregationProcessor.getDefinition());
aggregators.add(ParallelDurationAverageAggregationProcessor.getDefinition());
aggregators.add(ParallelDurationMaxAggregationProcessor.getDefinition());
aggregators.add(ParallelDurationMinAggregationProcessor.getDefinition());
aggregators.add(ParallelBearingAverageDegreesAggregationProcessor.getDefinition());
aggregators.add(ParallelBearingMaxAggregationProcessor.getDefinition());
aggregators.add(ParallelBearingMinAggregationProcessor.getDefinition());
return aggregators;
}
@Override
public Map<PredefinedQueryIdentifier, StatisticQueryDefinitionDTO> getPredefinedQueries() {
return predefinedQueries.getQueries();
}
private void initializeDataSourceProviders() {
dataSourceProviders = new HashSet<>();
dataSourceProviders.add(new RacingEventServiceProvider(context));
}
public static SailingClusterGroups getClusterGroups() {
return clusterGroups;
}
public static Activator getDefault() {
if (INSTANCE == null) {
INSTANCE = new Activator(); // probably non-OSGi case, as in test execution
}
return INSTANCE;
}
}
@@ -1,194 +1,194 @@
package com.sap.sailing.datamining;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.sap.sailing.datamining.data.HasGPSFixContext;
import com.sap.sailing.datamining.data.HasLeaderboardContext;
import com.sap.sailing.datamining.data.HasRaceOfCompetitorContext;
import com.sap.sailing.datamining.data.HasTrackedLegContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.datamining.data.HasTrackedRaceContext;
import com.sap.sailing.datamining.impl.components.GPSFixRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.LeaderboardGroupRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.LeaderboardRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.RaceOfCompetitorRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.TrackedLegOfCompetitorRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.TrackedLegRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.TrackedRaceRetrievalProcessor;
import com.sap.sailing.datamining.impl.data.LeaderboardGroupWithContext;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.LegType;
import com.sap.sailing.server.RacingEventService;
import com.sap.sse.datamining.shared.dto.StatisticQueryDefinitionDTO;
import com.sap.sse.datamining.shared.impl.PredefinedQueryIdentifier;
import com.sap.sse.datamining.shared.impl.dto.AggregationProcessorDefinitionDTO;
import com.sap.sse.datamining.shared.impl.dto.DataRetrieverChainDefinitionDTO;
import com.sap.sse.datamining.shared.impl.dto.DataRetrieverLevelDTO;
import com.sap.sse.datamining.shared.impl.dto.FunctionDTO;
import com.sap.sse.datamining.shared.impl.dto.LocalizedTypeDTO;
import com.sap.sse.datamining.shared.impl.dto.ModifiableStatisticQueryDefinitionDTO;
public class SailingPredefinedQueries {
private final Map<PredefinedQueryIdentifier, StatisticQueryDefinitionDTO> predefinedQueries;
public final static String QUERY_AVERAGE_SPEED_PER_REGATTA_RACE = "AvgSpeed_Per_Regatta-Race";
public final static String QUERY_AVERAGE_SPEED_PER_COMPETITOR_LEGTYPE = "AvgSpeed_Per_Competitor-LegType";
public final static String QUERY_AVERAGE_SPEED_PER_COMPETITOR = "AvgSpeed_Per_Competitor";
public final static String QUERY_DISTANCE_TRAVELED_PER_COMPETITOR_LEGTYPE = "DistanceTraveled_Per_Competitor-LegType";
public final static String QUERY_DISTANCE_TRAVELED_PER_COMPETITOR = "DistanceTraveled_Per_Competitor";
public final static String QUERY_MANEUVERS_PER_COMPETITOR = "Maneuvers_Per_Competitor";
public SailingPredefinedQueries() {
predefinedQueries = new HashMap<>();
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_AVERAGE_SPEED_PER_REGATTA_RACE, "Average Speed grouped by regatta name and race name"),
create_AvgSpeed_Per_Regatta_Race());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_AVERAGE_SPEED_PER_COMPETITOR_LEGTYPE, "Average speed grouped by competitor/team name and leg type"),
create_AvgSpeed_Per_Competitor_LegType());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_AVERAGE_SPEED_PER_COMPETITOR, "Average speed grouped by competitor/team name"),
create_AvgSpeed_Per_Competitor());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_DISTANCE_TRAVELED_PER_COMPETITOR_LEGTYPE, "Distance traveled grouped by competitor/team name and leg type"),
create_SumTraveledDistance_Per_Competitor_LegType());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_DISTANCE_TRAVELED_PER_COMPETITOR, "Distance traveled grouped by competitor/team name and leg type"),
create_SumTraveledDistance_Per_Competitor());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_MANEUVERS_PER_COMPETITOR, "Maneuvers grouped by competitor/team name"),
create_SumManeuvers_Per_Competitor());
}
private StatisticQueryDefinitionDTO create_AvgSpeed_Per_Regatta_Race() {
FunctionDTO statistic = new FunctionDTO(false, "getGPSFix().getSpeed().getKnots()", HasGPSFixContext.class.getName(), double.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Average", Number.class.getName(), Number.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(5, GPSFixRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasGPSFixContext.class.getName(), "GPS-Fix"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getTrackedLegContext().getTrackedRaceContext().getRegatta().getName()", HasGPSFixContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
FunctionDTO dimensionToGroupBy1 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getTrackedLegContext().getTrackedRaceContext().getRace().getName()", HasGPSFixContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy1);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_AvgSpeed_Per_Competitor_LegType() {
FunctionDTO statistic = new FunctionDTO(false, "getGPSFix().getSpeed().getKnots()", HasGPSFixContext.class.getName(), double.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Average", Number.class.getName(), Number.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(5, GPSFixRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasGPSFixContext.class.getName(), "GPS-Fix"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getCompetitor().getName()", HasGPSFixContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
FunctionDTO dimensionToGroupBy1 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getTrackedLegContext().getLegType()", HasGPSFixContext.class.getName(), LegType.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy1);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_SumTraveledDistance_Per_Competitor_LegType() {
FunctionDTO statistic = new FunctionDTO(false, "getDistanceTraveled()", HasTrackedLegOfCompetitorContext.class.getName(), Distance.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Sum", Distance.class.getName(), Distance.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getCompetitor().getName()", HasTrackedLegOfCompetitorContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
FunctionDTO dimensionToGroupBy1 = new FunctionDTO(true, "getTrackedLegContext().getLegType()", HasTrackedLegOfCompetitorContext.class.getName(), LegType.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy1);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_AvgSpeed_Per_Competitor() {
FunctionDTO statistic = new FunctionDTO(false, "getGPSFix().getSpeed().getKnots()", HasGPSFixContext.class.getName(), double.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Average", Number.class.getName(), Number.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(5, GPSFixRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasGPSFixContext.class.getName(), "GPS-Fix"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getCompetitor().getName()", HasGPSFixContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_SumTraveledDistance_Per_Competitor() {
FunctionDTO statistic = new FunctionDTO(false, "getDistanceTraveled()", HasTrackedLegOfCompetitorContext.class.getName(), Distance.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Sum", Distance.class.getName(), Distance.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getCompetitor().getName()", HasTrackedLegOfCompetitorContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_SumManeuvers_Per_Competitor() {
FunctionDTO statistic = new FunctionDTO(false, "getNumberOfManeuvers()", HasRaceOfCompetitorContext.class.getName(), int.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Sum", Number.class.getName(), Number.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, RaceOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasRaceOfCompetitorContext.class.getName(), "Competitor"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getCompetitor().getName()", HasRaceOfCompetitorContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
return queryDefinition;
}
public Map<PredefinedQueryIdentifier, StatisticQueryDefinitionDTO> getQueries() {
return predefinedQueries;
}
}
package com.sap.sailing.datamining;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.sap.sailing.datamining.data.HasGPSFixContext;
import com.sap.sailing.datamining.data.HasLeaderboardContext;
import com.sap.sailing.datamining.data.HasRaceOfCompetitorContext;
import com.sap.sailing.datamining.data.HasTrackedLegContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.datamining.data.HasTrackedRaceContext;
import com.sap.sailing.datamining.impl.components.GPSFixRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.LeaderboardGroupRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.LeaderboardRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.RaceOfCompetitorRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.TrackedLegOfCompetitorRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.TrackedLegRetrievalProcessor;
import com.sap.sailing.datamining.impl.components.TrackedRaceRetrievalProcessor;
import com.sap.sailing.datamining.impl.data.LeaderboardGroupWithContext;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.LegType;
import com.sap.sailing.server.RacingEventService;
import com.sap.sse.datamining.shared.dto.StatisticQueryDefinitionDTO;
import com.sap.sse.datamining.shared.impl.PredefinedQueryIdentifier;
import com.sap.sse.datamining.shared.impl.dto.AggregationProcessorDefinitionDTO;
import com.sap.sse.datamining.shared.impl.dto.DataRetrieverChainDefinitionDTO;
import com.sap.sse.datamining.shared.impl.dto.DataRetrieverLevelDTO;
import com.sap.sse.datamining.shared.impl.dto.FunctionDTO;
import com.sap.sse.datamining.shared.impl.dto.LocalizedTypeDTO;
import com.sap.sse.datamining.shared.impl.dto.ModifiableStatisticQueryDefinitionDTO;
public class SailingPredefinedQueries {
private final Map<PredefinedQueryIdentifier, StatisticQueryDefinitionDTO> predefinedQueries;
public final static String QUERY_AVERAGE_SPEED_PER_REGATTA_RACE = "AvgSpeed_Per_Regatta-Race";
public final static String QUERY_AVERAGE_SPEED_PER_COMPETITOR_LEGTYPE = "AvgSpeed_Per_Competitor-LegType";
public final static String QUERY_AVERAGE_SPEED_PER_COMPETITOR = "AvgSpeed_Per_Competitor";
public final static String QUERY_DISTANCE_TRAVELED_PER_COMPETITOR_LEGTYPE = "DistanceTraveled_Per_Competitor-LegType";
public final static String QUERY_DISTANCE_TRAVELED_PER_COMPETITOR = "DistanceTraveled_Per_Competitor";
public final static String QUERY_MANEUVERS_PER_COMPETITOR = "Maneuvers_Per_Competitor";
public SailingPredefinedQueries() {
predefinedQueries = new HashMap<>();
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_AVERAGE_SPEED_PER_REGATTA_RACE, "Average Speed grouped by regatta name and race name"),
create_AvgSpeed_Per_Regatta_Race());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_AVERAGE_SPEED_PER_COMPETITOR_LEGTYPE, "Average speed grouped by competitor/team name and leg type"),
create_AvgSpeed_Per_Competitor_LegType());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_AVERAGE_SPEED_PER_COMPETITOR, "Average speed grouped by competitor/team name"),
create_AvgSpeed_Per_Competitor());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_DISTANCE_TRAVELED_PER_COMPETITOR_LEGTYPE, "Distance traveled grouped by competitor/team name and leg type"),
create_SumTraveledDistance_Per_Competitor_LegType());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_DISTANCE_TRAVELED_PER_COMPETITOR, "Distance traveled grouped by competitor/team name and leg type"),
create_SumTraveledDistance_Per_Competitor());
predefinedQueries.put(new PredefinedQueryIdentifier(QUERY_MANEUVERS_PER_COMPETITOR, "Maneuvers grouped by competitor/team name"),
create_SumManeuvers_Per_Competitor());
}
private StatisticQueryDefinitionDTO create_AvgSpeed_Per_Regatta_Race() {
FunctionDTO statistic = new FunctionDTO(false, "getGPSFix().getSpeed().getKnots()", HasGPSFixContext.class.getName(), double.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Average", Number.class.getName(), Number.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(5, GPSFixRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasGPSFixContext.class.getName(), "GPS-Fix"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getTrackedLegContext().getTrackedRaceContext().getRegatta().getName()", HasGPSFixContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
FunctionDTO dimensionToGroupBy1 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getTrackedLegContext().getTrackedRaceContext().getRace().getName()", HasGPSFixContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy1);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_AvgSpeed_Per_Competitor_LegType() {
FunctionDTO statistic = new FunctionDTO(false, "getGPSFix().getSpeed().getKnots()", HasGPSFixContext.class.getName(), double.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Average", Number.class.getName(), Number.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(5, GPSFixRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasGPSFixContext.class.getName(), "GPS-Fix"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getCompetitor().getName()", HasGPSFixContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
FunctionDTO dimensionToGroupBy1 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getTrackedLegContext().getLegType()", HasGPSFixContext.class.getName(), LegType.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy1);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_SumTraveledDistance_Per_Competitor_LegType() {
FunctionDTO statistic = new FunctionDTO(false, "getDistanceTraveled()", HasTrackedLegOfCompetitorContext.class.getName(), Distance.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Sum", Distance.class.getName(), Distance.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getCompetitor().getName()", HasTrackedLegOfCompetitorContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
FunctionDTO dimensionToGroupBy1 = new FunctionDTO(true, "getTrackedLegContext().getLegType()", HasTrackedLegOfCompetitorContext.class.getName(), LegType.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy1);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_AvgSpeed_Per_Competitor() {
FunctionDTO statistic = new FunctionDTO(false, "getGPSFix().getSpeed().getKnots()", HasGPSFixContext.class.getName(), double.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Average", Number.class.getName(), Number.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(5, GPSFixRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasGPSFixContext.class.getName(), "GPS-Fix"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getTrackedLegOfCompetitorContext().getCompetitor().getName()", HasGPSFixContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_SumTraveledDistance_Per_Competitor() {
FunctionDTO statistic = new FunctionDTO(false, "getDistanceTraveled()", HasTrackedLegOfCompetitorContext.class.getName(), Distance.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Sum", Distance.class.getName(), Distance.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, TrackedLegRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegContext.class.getName(), "Leg"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(4, TrackedLegOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedLegOfCompetitorContext.class.getName(), "Leg of competitor"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getCompetitor().getName()", HasTrackedLegOfCompetitorContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
return queryDefinition;
}
private StatisticQueryDefinitionDTO create_SumManeuvers_Per_Competitor() {
FunctionDTO statistic = new FunctionDTO(false, "getNumberOfManeuvers()", HasRaceOfCompetitorContext.class.getName(), int.class.getName(), new ArrayList<String>(), "", 0);
AggregationProcessorDefinitionDTO aggregator = new AggregationProcessorDefinitionDTO("Sum", Number.class.getName(), Number.class.getName(), "");
ArrayList<DataRetrieverLevelDTO> retrieverLevels = new ArrayList<>();
retrieverLevels.add(new DataRetrieverLevelDTO(0, LeaderboardGroupRetrievalProcessor.class.getName(), new LocalizedTypeDTO(LeaderboardGroupWithContext.class.getName(), "Leaderboard Group"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(1, LeaderboardRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasLeaderboardContext.class.getName(), "Leaderboard"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(2, TrackedRaceRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasTrackedRaceContext.class.getName(), "Race"), null));
retrieverLevels.add(new DataRetrieverLevelDTO(3, RaceOfCompetitorRetrievalProcessor.class.getName(), new LocalizedTypeDTO(HasRaceOfCompetitorContext.class.getName(), "Competitor"), null));
DataRetrieverChainDefinitionDTO retrieverChain = new DataRetrieverChainDefinitionDTO("", RacingEventService.class.getName(), retrieverLevels);
ModifiableStatisticQueryDefinitionDTO queryDefinition = new ModifiableStatisticQueryDefinitionDTO("default", statistic, aggregator, retrieverChain);
FunctionDTO dimensionToGroupBy0 = new FunctionDTO(true, "getCompetitor().getName()", HasRaceOfCompetitorContext.class.getName(), String.class.getName(), new ArrayList<String>(), "", 0);
queryDefinition.appendDimensionToGroupBy(dimensionToGroupBy0);
return queryDefinition;
}
public Map<PredefinedQueryIdentifier, StatisticQueryDefinitionDTO> getQueries() {
return predefinedQueries;
}
}
@@ -1,17 +1,17 @@
package com.sap.sailing.datamining.data;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.tracking.BravoFixTrack;
import com.sap.sse.common.Duration;
import com.sap.sse.datamining.annotations.Connector;
import com.sap.sse.datamining.annotations.Statistic;
public interface HasBravoFixTrackContext {
@Connector(scanForStatistics=false)
HasRaceOfCompetitorContext getRaceOfCompetitorContext();
BravoFixTrack<Competitor> getBravoFixTrack();
@Statistic(messageKey="timeSpentFoiling", resultDecimals=1)
Duration getTimeSpentFoiling();
}
package com.sap.sailing.datamining.data;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.tracking.BravoFixTrack;
import com.sap.sse.common.Duration;
import com.sap.sse.datamining.annotations.Connector;
import com.sap.sse.datamining.annotations.Statistic;
public interface HasBravoFixTrackContext {
@Connector(scanForStatistics=false)
HasRaceOfCompetitorContext getRaceOfCompetitorContext();
BravoFixTrack<Competitor> getBravoFixTrack();
@Statistic(messageKey="timeSpentFoiling", resultDecimals=1)
Duration getTimeSpentFoiling();
}
@@ -1,64 +1,64 @@
package com.sap.sailing.datamining.data;
import java.util.Locale;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.LegType;
import com.sap.sailing.domain.common.NoWindException;
import com.sap.sailing.domain.common.Wind;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.datamining.annotations.Connector;
import com.sap.sse.datamining.annotations.Dimension;
import com.sap.sse.datamining.annotations.Statistic;
import com.sap.sse.datamining.shared.impl.dto.ClusterDTO;
import com.sap.sse.i18n.ResourceBundleStringMessages;
public interface HasFoilingSegmentContext {
@Connector(scanForStatistics=false)
HasBravoFixTrackContext getBravoFixTrackContext();
TimePoint getStartOfFoilingSegment();
TimePoint getEndOfFoilingSegment();
@Statistic(messageKey="FoilingDuration")
Duration getDuration();
@Statistic(messageKey="FoilingDistance")
Distance getDistance();
@Statistic(messageKey="TakeoffSpeedInKnotsInKnots", resultDecimals=1)
Double getTakeoffSpeedInKnots();
@Statistic(messageKey="LandingSpeedInKnots", resultDecimals=1)
Double getLandingSpeedInKnots();
@Statistic(messageKey="AbsoluteTrueWindAngleAtTakeoff", resultDecimals=1)
Bearing getAbsoluteTrueWindAngleAtTakeoffInDegrees() throws NoWindException;
@Statistic(messageKey="AbsoluteTrueWindAngleAtLanding", resultDecimals=1)
Bearing getAbsoluteTrueWindAngleAtLandingInDegrees() throws NoWindException;
@Statistic(messageKey="AverageAbsoluteTrueWindAngle", resultDecimals=1)
Bearing getAverageAbsoluteTrueWindAngle() throws NoWindException;
@Dimension(messageKey="WindStrengthInBeaufortAtTakeoff")
ClusterDTO getWindStrengthAsBeaufortClusterAtTakeoff(Locale locale, ResourceBundleStringMessages stringMessages);
@Dimension(messageKey="WindStrengthInBeaufortAtLanding")
ClusterDTO getWindStrengthAsBeaufortClusterAtLanding(Locale locale, ResourceBundleStringMessages stringMessages);
@Connector(messageKey="WindAtTakeoff")
Wind getWindAtTakeoff();
@Connector(messageKey="WindAtLanding")
Wind getWindAtLanding();
@Dimension(messageKey="StartsOnLegType")
LegType getStartsOnLegType() throws NoWindException;
@Dimension(messageKey="EndsOnLegType")
LegType getEndsOnLegType() throws NoWindException;
}
package com.sap.sailing.datamining.data;
import java.util.Locale;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.LegType;
import com.sap.sailing.domain.common.NoWindException;
import com.sap.sailing.domain.common.Wind;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.datamining.annotations.Connector;
import com.sap.sse.datamining.annotations.Dimension;
import com.sap.sse.datamining.annotations.Statistic;
import com.sap.sse.datamining.shared.impl.dto.ClusterDTO;
import com.sap.sse.i18n.ResourceBundleStringMessages;
public interface HasFoilingSegmentContext {
@Connector(scanForStatistics=false)
HasBravoFixTrackContext getBravoFixTrackContext();
TimePoint getStartOfFoilingSegment();
TimePoint getEndOfFoilingSegment();
@Statistic(messageKey="FoilingDuration")
Duration getDuration();
@Statistic(messageKey="FoilingDistance")
Distance getDistance();
@Statistic(messageKey="TakeoffSpeedInKnotsInKnots", resultDecimals=1)
Double getTakeoffSpeedInKnots();
@Statistic(messageKey="LandingSpeedInKnots", resultDecimals=1)
Double getLandingSpeedInKnots();
@Statistic(messageKey="AbsoluteTrueWindAngleAtTakeoff", resultDecimals=1)
Bearing getAbsoluteTrueWindAngleAtTakeoffInDegrees() throws NoWindException;
@Statistic(messageKey="AbsoluteTrueWindAngleAtLanding", resultDecimals=1)
Bearing getAbsoluteTrueWindAngleAtLandingInDegrees() throws NoWindException;
@Statistic(messageKey="AverageAbsoluteTrueWindAngle", resultDecimals=1)
Bearing getAverageAbsoluteTrueWindAngle() throws NoWindException;
@Dimension(messageKey="WindStrengthInBeaufortAtTakeoff")
ClusterDTO getWindStrengthAsBeaufortClusterAtTakeoff(Locale locale, ResourceBundleStringMessages stringMessages);
@Dimension(messageKey="WindStrengthInBeaufortAtLanding")
ClusterDTO getWindStrengthAsBeaufortClusterAtLanding(Locale locale, ResourceBundleStringMessages stringMessages);
@Connector(messageKey="WindAtTakeoff")
Wind getWindAtTakeoff();
@Connector(messageKey="WindAtLanding")
Wind getWindAtLanding();
@Dimension(messageKey="StartsOnLegType")
LegType getStartsOnLegType() throws NoWindException;
@Dimension(messageKey="EndsOnLegType")
LegType getEndsOnLegType() throws NoWindException;
}
@@ -1,24 +1,24 @@
package com.sap.sailing.datamining.data;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.Positioned;
import com.sap.sailing.domain.tracking.Maneuver;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Timed;
import com.sap.sse.datamining.annotations.Connector;
public interface HasManeuver extends Positioned, Timed {
@Connector
Maneuver getManeuver();
@Override
default TimePoint getTimePoint() {
return getManeuver().getTimePoint();
}
@Override
default Position getPosition() {
return getManeuver().getPosition();
}
}
package com.sap.sailing.datamining.data;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.Positioned;
import com.sap.sailing.domain.tracking.Maneuver;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Timed;
import com.sap.sse.datamining.annotations.Connector;
public interface HasManeuver extends Positioned, Timed {
@Connector
Maneuver getManeuver();
@Override
default TimePoint getTimePoint() {
return getManeuver().getTimePoint();
}
@Override
default Position getPosition() {
return getManeuver().getPosition();
}
}
@@ -1,5 +1,5 @@
package com.sap.sailing.datamining.data;
public interface HasTrackedLegOfCompetitor {
HasTrackedLegOfCompetitorContext getTrackedLegOfCompetitorContext();
}
package com.sap.sailing.datamining.data;
public interface HasTrackedLegOfCompetitor {
HasTrackedLegOfCompetitorContext getTrackedLegOfCompetitorContext();
}
@@ -1,23 +1,23 @@
package com.sap.sailing.datamining.data;
import java.util.Locale;
import com.sap.sailing.datamining.Activator;
import com.sap.sailing.domain.common.Positioned;
import com.sap.sailing.domain.common.Wind;
import com.sap.sse.common.Timed;
import com.sap.sse.datamining.annotations.Dimension;
import com.sap.sse.datamining.data.Cluster;
import com.sap.sse.datamining.shared.impl.dto.ClusterDTO;
import com.sap.sse.i18n.ResourceBundleStringMessages;
public interface HasWind extends Positioned, Timed {
Wind getWind();
@Dimension(messageKey="WindStrengthInBeaufort", ordinal=11)
default ClusterDTO getWindStrengthAsBeaufortCluster(Locale locale, ResourceBundleStringMessages stringMessages) {
Wind wind = getWind();
final Cluster<?> cluster = Activator.getClusterGroups().getWindStrengthInBeaufortClusterGroup().getClusterFor(wind);
return new ClusterDTO(cluster.toString(), ()->cluster.asLocalizedString(locale, stringMessages));
}
}
package com.sap.sailing.datamining.data;
import java.util.Locale;
import com.sap.sailing.datamining.Activator;
import com.sap.sailing.domain.common.Positioned;
import com.sap.sailing.domain.common.Wind;
import com.sap.sse.common.Timed;
import com.sap.sse.datamining.annotations.Dimension;
import com.sap.sse.datamining.data.Cluster;
import com.sap.sse.datamining.shared.impl.dto.ClusterDTO;
import com.sap.sse.i18n.ResourceBundleStringMessages;
public interface HasWind extends Positioned, Timed {
Wind getWind();
@Dimension(messageKey="WindStrengthInBeaufort", ordinal=11)
default ClusterDTO getWindStrengthAsBeaufortCluster(Locale locale, ResourceBundleStringMessages stringMessages) {
Wind wind = getWind();
final Cluster<?> cluster = Activator.getClusterGroups().getWindStrengthInBeaufortClusterGroup().getClusterFor(wind);
return new ClusterDTO(cluster.toString(), ()->cluster.asLocalizedString(locale, stringMessages));
}
}
@@ -1,35 +1,35 @@
package com.sap.sailing.datamining.data;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.Wind;
import com.sap.sse.common.TimePoint;
import com.sap.sse.datamining.annotations.Connector;
import com.sap.sse.datamining.annotations.Dimension;
import com.sap.sse.datamining.annotations.Statistic;
public interface HasWindFixContext extends HasWind {
@Connector(scanForStatistics=false)
public HasTrackedRaceContext getTrackedRaceContext();
@Statistic(messageKey="", ordinal=0)
public Wind getWind();
@Statistic(messageKey="windFrom", resultDecimals=1, ordinal=1)
double getWindFromDegrees();
@Statistic(messageKey="windSpeedKnots", resultDecimals=1, ordinal=2)
double getWindSpeedInKnots();
@Override
default TimePoint getTimePoint() {
return getWind().getTimePoint();
}
@Override
default Position getPosition() {
return getWind().getPosition();
}
@Dimension(messageKey="WindSourceType")
String getWindSourceType();
}
package com.sap.sailing.datamining.data;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.Wind;
import com.sap.sse.common.TimePoint;
import com.sap.sse.datamining.annotations.Connector;
import com.sap.sse.datamining.annotations.Dimension;
import com.sap.sse.datamining.annotations.Statistic;
public interface HasWindFixContext extends HasWind {
@Connector(scanForStatistics=false)
public HasTrackedRaceContext getTrackedRaceContext();
@Statistic(messageKey="", ordinal=0)
public Wind getWind();
@Statistic(messageKey="windFrom", resultDecimals=1, ordinal=1)
double getWindFromDegrees();
@Statistic(messageKey="windSpeedKnots", resultDecimals=1, ordinal=2)
double getWindSpeedInKnots();
@Override
default TimePoint getTimePoint() {
return getWind().getTimePoint();
}
@Override
default Position getPosition() {
return getWind().getPosition();
}
@Dimension(messageKey="WindSourceType")
String getWindSourceType();
}
@@ -1,18 +1,18 @@
package com.sap.sailing.datamining.data;
import com.sap.sailing.domain.tracking.WindTrack;
import com.sap.sse.datamining.annotations.Connector;
import com.sap.sse.datamining.annotations.Dimension;
public interface HasWindTrackContext {
@Connector(scanForStatistics=false)
public HasTrackedRaceContext getTrackedRaceContext();
@Dimension(messageKey="WindSourceType")
String getWindSourceType();
@Dimension(messageKey="WindSourceName")
String getWindSourceName();
WindTrack getWindTrack();
}
package com.sap.sailing.datamining.data;
import com.sap.sailing.domain.tracking.WindTrack;
import com.sap.sse.datamining.annotations.Connector;
import com.sap.sse.datamining.annotations.Dimension;
public interface HasWindTrackContext {
@Connector(scanForStatistics=false)
public HasTrackedRaceContext getTrackedRaceContext();
@Dimension(messageKey="WindSourceType")
String getWindSourceType();
@Dimension(messageKey="WindSourceName")
String getWindSourceName();
WindTrack getWindTrack();
}
@@ -1,46 +1,46 @@
package com.sap.sailing.datamining.impl.data;
import com.sap.sailing.datamining.data.HasBravoFixTrackContext;
import com.sap.sailing.datamining.data.HasRaceOfCompetitorContext;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.tracking.BravoFixTrack;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class BravoFixTrackWithContext implements HasBravoFixTrackContext {
private final HasRaceOfCompetitorContext raceOfCompetitorContext;
private final BravoFixTrack<Competitor> bravoFixTrack;
public BravoFixTrackWithContext(HasRaceOfCompetitorContext raceOfCompetitorContext, BravoFixTrack<Competitor> bravoFixTrack) {
this.raceOfCompetitorContext = raceOfCompetitorContext;
this.bravoFixTrack = bravoFixTrack;
}
@Override
public HasRaceOfCompetitorContext getRaceOfCompetitorContext() {
return raceOfCompetitorContext;
}
@Override
public BravoFixTrack<Competitor> getBravoFixTrack() {
return bravoFixTrack;
}
@Override
public Duration getTimeSpentFoiling() {
final TimePoint endOfRace = getRaceOfCompetitorContext().getTrackedRaceContext().getTrackedRace().getEndOfRace();
final TimePoint startOfRace = getRaceOfCompetitorContext().getTrackedRaceContext().getTrackedRace().getStartOfRace();
final TimePoint end;
if (endOfRace == null) {
final TimePoint endOfTracking = getRaceOfCompetitorContext().getTrackedRaceContext().getTrackedRace().getEndOfTracking();
end = endOfTracking == null ? MillisecondsTimePoint.now() : endOfTracking;
} else {
end = endOfRace;
}
return bravoFixTrack.getTimeSpentFoiling(startOfRace, end);
}
}
package com.sap.sailing.datamining.impl.data;
import com.sap.sailing.datamining.data.HasBravoFixTrackContext;
import com.sap.sailing.datamining.data.HasRaceOfCompetitorContext;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.tracking.BravoFixTrack;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class BravoFixTrackWithContext implements HasBravoFixTrackContext {
private final HasRaceOfCompetitorContext raceOfCompetitorContext;
private final BravoFixTrack<Competitor> bravoFixTrack;
public BravoFixTrackWithContext(HasRaceOfCompetitorContext raceOfCompetitorContext, BravoFixTrack<Competitor> bravoFixTrack) {
this.raceOfCompetitorContext = raceOfCompetitorContext;
this.bravoFixTrack = bravoFixTrack;
}
@Override
public HasRaceOfCompetitorContext getRaceOfCompetitorContext() {
return raceOfCompetitorContext;
}
@Override
public BravoFixTrack<Competitor> getBravoFixTrack() {
return bravoFixTrack;
}
@Override
public Duration getTimeSpentFoiling() {
final TimePoint endOfRace = getRaceOfCompetitorContext().getTrackedRaceContext().getTrackedRace().getEndOfRace();
final TimePoint startOfRace = getRaceOfCompetitorContext().getTrackedRaceContext().getTrackedRace().getStartOfRace();
final TimePoint end;
if (endOfRace == null) {
final TimePoint endOfTracking = getRaceOfCompetitorContext().getTrackedRaceContext().getTrackedRace().getEndOfTracking();
end = endOfTracking == null ? MillisecondsTimePoint.now() : endOfTracking;
} else {
end = endOfRace;
}
return bravoFixTrack.getTimeSpentFoiling(startOfRace, end);
}
}
@@ -1,87 +1,87 @@
package com.sap.sailing.datamining.impl.data;
import com.sap.sailing.datamining.data.HasBravoFixContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.NoWindException;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.Speed;
import com.sap.sailing.domain.common.SpeedWithBearing;
import com.sap.sailing.domain.common.Wind;
import com.sap.sailing.domain.common.tracking.BravoFix;
import com.sap.sailing.domain.common.tracking.GPSFixMoving;
import com.sap.sailing.domain.tracking.GPSFixTrack;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sailing.domain.tracking.WindPositionMode;
public class BravoFixWithContext implements HasBravoFixContext {
private static final long serialVersionUID = -4537126043228674949L;
private final HasTrackedLegOfCompetitorContext trackedLegOfCompetitorContext;
private final BravoFix bravoFix;
private Wind wind;
public BravoFixWithContext(HasTrackedLegOfCompetitorContext trackedLegOfCompetitorContext, BravoFix bravoFix) {
this.trackedLegOfCompetitorContext = trackedLegOfCompetitorContext;
this.bravoFix = bravoFix;
}
@Override
public HasTrackedLegOfCompetitorContext getTrackedLegOfCompetitorContext() {
return trackedLegOfCompetitorContext;
}
@Override
public BravoFix getBravoFix() {
return bravoFix;
}
@Override
public Wind getWindInternal() {
return wind;
}
@Override
public void setWindInternal(Wind wind) {
this.wind = wind;
}
@Override
public SpeedWithBearing getSpeed() {
return getGpsFixTrack().getEstimatedSpeed(getTimePoint());
}
@Override
public Speed getVelocityMadeGood() {
return getTrackedLegOfCompetitorContext().getTrackedLegOfCompetitor().getVelocityMadeGood(getTimePoint(), WindPositionMode.EXACT);
}
@Override
public Wind getWind() {
return getTrackedRace().getWind(getGpsFixTrack().getEstimatedPosition(getTimePoint(), /* extrapolate */ true), getTimePoint());
}
@Override
public Bearing getAbsoluteTrueWindAngle() throws NoWindException {
return getTrackedRace().getTrackedLeg(getCompetitor(), getTimePoint()).getBeatAngle(getTimePoint()).abs();
}
private Competitor getCompetitor() {
return getTrackedLegOfCompetitorContext().getCompetitor();
}
@Override
public Position getPosition() {
return getGpsFixTrack().getEstimatedPosition(getTimePoint(), /* extrapolate */ true);
}
private GPSFixTrack<Competitor, GPSFixMoving> getGpsFixTrack() {
return getTrackedRace().getTrack(getTrackedLegOfCompetitorContext().getCompetitor());
}
private TrackedRace getTrackedRace() {
return getTrackedLegOfCompetitorContext().getTrackedLegOfCompetitor().getTrackedLeg().getTrackedRace();
}
}
package com.sap.sailing.datamining.impl.data;
import com.sap.sailing.datamining.data.HasBravoFixContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.NoWindException;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.Speed;
import com.sap.sailing.domain.common.SpeedWithBearing;
import com.sap.sailing.domain.common.Wind;
import com.sap.sailing.domain.common.tracking.BravoFix;
import com.sap.sailing.domain.common.tracking.GPSFixMoving;
import com.sap.sailing.domain.tracking.GPSFixTrack;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sailing.domain.tracking.WindPositionMode;
public class BravoFixWithContext implements HasBravoFixContext {
private static final long serialVersionUID = -4537126043228674949L;
private final HasTrackedLegOfCompetitorContext trackedLegOfCompetitorContext;
private final BravoFix bravoFix;
private Wind wind;
public BravoFixWithContext(HasTrackedLegOfCompetitorContext trackedLegOfCompetitorContext, BravoFix bravoFix) {
this.trackedLegOfCompetitorContext = trackedLegOfCompetitorContext;
this.bravoFix = bravoFix;
}
@Override
public HasTrackedLegOfCompetitorContext getTrackedLegOfCompetitorContext() {
return trackedLegOfCompetitorContext;
}
@Override
public BravoFix getBravoFix() {
return bravoFix;
}
@Override
public Wind getWindInternal() {
return wind;
}
@Override
public void setWindInternal(Wind wind) {
this.wind = wind;
}
@Override
public SpeedWithBearing getSpeed() {
return getGpsFixTrack().getEstimatedSpeed(getTimePoint());
}
@Override
public Speed getVelocityMadeGood() {
return getTrackedLegOfCompetitorContext().getTrackedLegOfCompetitor().getVelocityMadeGood(getTimePoint(), WindPositionMode.EXACT);
}
@Override
public Wind getWind() {
return getTrackedRace().getWind(getGpsFixTrack().getEstimatedPosition(getTimePoint(), /* extrapolate */ true), getTimePoint());
}
@Override
public Bearing getAbsoluteTrueWindAngle() throws NoWindException {
return getTrackedRace().getTrackedLeg(getCompetitor(), getTimePoint()).getBeatAngle(getTimePoint()).abs();
}
private Competitor getCompetitor() {
return getTrackedLegOfCompetitorContext().getCompetitor();
}
@Override
public Position getPosition() {
return getGpsFixTrack().getEstimatedPosition(getTimePoint(), /* extrapolate */ true);
}
private GPSFixTrack<Competitor, GPSFixMoving> getGpsFixTrack() {
return getTrackedRace().getTrack(getTrackedLegOfCompetitorContext().getCompetitor());
}
private TrackedRace getTrackedRace() {
return getTrackedLegOfCompetitorContext().getTrackedLegOfCompetitor().getTrackedLeg().getTrackedRace();
}
}

Some files were not shown because too many files have changed in this diff Show More