id
int64 22
34.9k
| comment_id
int64 0
328
| comment
stringlengths 2
2.55k
| code
stringlengths 31
107k
| classification
stringclasses 6
values | isFinished
bool 1
class | code_context_2
stringlengths 21
27.3k
| code_context_10
stringlengths 29
27.3k
| code_context_20
stringlengths 29
27.3k
|
---|---|---|---|---|---|---|---|---|
15,539 | 0 | /** TODO: generated by FrameWeb. Should be documented. */ | @Override
protected EntityManager getEntityManager() {
return entityManager;
} | DOCUMENTATION | true | @Override
protected EntityManager getEntityManager() {
return entityManager;
} | @Override
protected EntityManager getEntityManager() {
return entityManager;
} | @Override
protected EntityManager getEntityManager() {
return entityManager;
} |
15,540 | 0 | /** TODO: generated by FrameWeb. Should be documented. */ | @Override
public List<Book> getBookByTitle(String title) {
// FIXME: auto-generated method stub
return null;
} | DOCUMENTATION | true | @Override
public List<Book> getBookByTitle(String title) {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookByTitle(String title) {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookByTitle(String title) {
// FIXME: auto-generated method stub
return null;
} |
15,540 | 1 | // FIXME: auto-generated method stub | @Override
public List<Book> getBookByTitle(String title) {
// FIXME: auto-generated method stub
return null;
} | DESIGN | true | @Override
public List<Book> getBookByTitle(String title) {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookByTitle(String title) {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookByTitle(String title) {
// FIXME: auto-generated method stub
return null;
} |
15,541 | 0 | /** TODO: generated by FrameWeb. Should be documented. */ | @Override
public List<Book> getBookByAuthor(String author) {
// FIXME: auto-generated method stub
return null;
} | DOCUMENTATION | true | @Override
public List<Book> getBookByAuthor(String author) {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookByAuthor(String author) {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookByAuthor(String author) {
// FIXME: auto-generated method stub
return null;
} |
15,541 | 1 | // FIXME: auto-generated method stub | @Override
public List<Book> getBookByAuthor(String author) {
// FIXME: auto-generated method stub
return null;
} | IMPLEMENTATION | true | @Override
public List<Book> getBookByAuthor(String author) {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookByAuthor(String author) {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookByAuthor(String author) {
// FIXME: auto-generated method stub
return null;
} |
15,542 | 0 | /** TODO: generated by FrameWeb. Should be documented. */ | @Override
public List<Book> getBookList() {
// FIXME: auto-generated method stub
return null;
} | DOCUMENTATION | true | @Override
public List<Book> getBookList() {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookList() {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookList() {
// FIXME: auto-generated method stub
return null;
} |
15,542 | 1 | // FIXME: auto-generated method stub | @Override
public List<Book> getBookList() {
// FIXME: auto-generated method stub
return null;
} | IMPLEMENTATION | true | @Override
public List<Book> getBookList() {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookList() {
// FIXME: auto-generated method stub
return null;
} | @Override
public List<Book> getBookList() {
// FIXME: auto-generated method stub
return null;
} |
23,738 | 0 | // TODO Implement a method | @Override
public void validateStatusOnUpdate(Post post) {
// TODO Implement a method
} | IMPLEMENTATION | true | @Override
public void validateStatusOnUpdate(Post post) {
// TODO Implement a method
} | @Override
public void validateStatusOnUpdate(Post post) {
// TODO Implement a method
} | @Override
public void validateStatusOnUpdate(Post post) {
// TODO Implement a method
} |
15,556 | 0 | // !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted | @Test
public void testDeleteBuildDefinition()
throws ContinuumStoreException
{
Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
BuildDefinition buildDefinition = project.getBuildDefinitions().get( 1 );
project.getBuildDefinitions().remove( 0 );
projectDao.updateProject( project );
project = projectDao.getProjectWithAllDetails( testProject1.getId() );
assertEquals( "check size is now 1", 1, project.getBuildDefinitions().size() );
BuildDefinition retrievedBuildDefinition = project.getBuildDefinitions().get( 0 );
assertBuildDefinitionEquals( buildDefinition, retrievedBuildDefinition );
assertScheduleEquals( testSchedule2, retrievedBuildDefinition.getSchedule() );
assertProfileEquals( testProfile2, retrievedBuildDefinition.getProfile() );
// !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted
} | TEST | true | assertScheduleEquals( testSchedule2, retrievedBuildDefinition.getSchedule() );
assertProfileEquals( testProfile2, retrievedBuildDefinition.getProfile() );
// !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted
} | Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
BuildDefinition buildDefinition = project.getBuildDefinitions().get( 1 );
project.getBuildDefinitions().remove( 0 );
projectDao.updateProject( project );
project = projectDao.getProjectWithAllDetails( testProject1.getId() );
assertEquals( "check size is now 1", 1, project.getBuildDefinitions().size() );
BuildDefinition retrievedBuildDefinition = project.getBuildDefinitions().get( 0 );
assertBuildDefinitionEquals( buildDefinition, retrievedBuildDefinition );
assertScheduleEquals( testSchedule2, retrievedBuildDefinition.getSchedule() );
assertProfileEquals( testProfile2, retrievedBuildDefinition.getProfile() );
// !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted
} | @Test
public void testDeleteBuildDefinition()
throws ContinuumStoreException
{
Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
BuildDefinition buildDefinition = project.getBuildDefinitions().get( 1 );
project.getBuildDefinitions().remove( 0 );
projectDao.updateProject( project );
project = projectDao.getProjectWithAllDetails( testProject1.getId() );
assertEquals( "check size is now 1", 1, project.getBuildDefinitions().size() );
BuildDefinition retrievedBuildDefinition = project.getBuildDefinitions().get( 0 );
assertBuildDefinitionEquals( buildDefinition, retrievedBuildDefinition );
assertScheduleEquals( testSchedule2, retrievedBuildDefinition.getSchedule() );
assertProfileEquals( testProfile2, retrievedBuildDefinition.getProfile() );
// !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted
} |
15,558 | 0 | // !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted | @Test
public void testDeleteGroupBuildDefinition()
throws ContinuumStoreException
{
ProjectGroup projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId(
defaultProjectGroup.getId() );
projectGroup.getBuildDefinitions().remove( 0 );
projectGroupDao.updateProjectGroup( projectGroup );
projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( defaultProjectGroup.getId() );
assertEquals( "check size is now 0", 0, projectGroup.getBuildDefinitions().size() );
// !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted
} | TEST | true | projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( defaultProjectGroup.getId() );
assertEquals( "check size is now 0", 0, projectGroup.getBuildDefinitions().size() );
// !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted
} | @Test
public void testDeleteGroupBuildDefinition()
throws ContinuumStoreException
{
ProjectGroup projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId(
defaultProjectGroup.getId() );
projectGroup.getBuildDefinitions().remove( 0 );
projectGroupDao.updateProjectGroup( projectGroup );
projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( defaultProjectGroup.getId() );
assertEquals( "check size is now 0", 0, projectGroup.getBuildDefinitions().size() );
// !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted
} | @Test
public void testDeleteGroupBuildDefinition()
throws ContinuumStoreException
{
ProjectGroup projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId(
defaultProjectGroup.getId() );
projectGroup.getBuildDefinitions().remove( 0 );
projectGroupDao.updateProjectGroup( projectGroup );
projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( defaultProjectGroup.getId() );
assertEquals( "check size is now 0", 0, projectGroup.getBuildDefinitions().size() );
// !! These actually aren't happening !!
// TODO: test the def was physically deleted
// TODO: test the schedule/profile was NOT physically deleted
} |
23,785 | 0 | // TODO insert preface | private static void replaceParagraphWithPreface(final Context context, final XWPFParagraph paragraph) {
try (final CursorHelper cursorHelper = context.newCursorHelper(paragraph)) {
// TODO insert preface
} finally {
context.getDocument().removeBodyElement(context.getDocument().getPosOfParagraph(paragraph));
}
} | IMPLEMENTATION | true | private static void replaceParagraphWithPreface(final Context context, final XWPFParagraph paragraph) {
try (final CursorHelper cursorHelper = context.newCursorHelper(paragraph)) {
// TODO insert preface
} finally {
context.getDocument().removeBodyElement(context.getDocument().getPosOfParagraph(paragraph)); | private static void replaceParagraphWithPreface(final Context context, final XWPFParagraph paragraph) {
try (final CursorHelper cursorHelper = context.newCursorHelper(paragraph)) {
// TODO insert preface
} finally {
context.getDocument().removeBodyElement(context.getDocument().getPosOfParagraph(paragraph));
}
} | private static void replaceParagraphWithPreface(final Context context, final XWPFParagraph paragraph) {
try (final CursorHelper cursorHelper = context.newCursorHelper(paragraph)) {
// TODO insert preface
} finally {
context.getDocument().removeBodyElement(context.getDocument().getPosOfParagraph(paragraph));
}
} |
15,595 | 0 | // TODO: how to identify the correct device if there are several devices in the
// list? | public static List<KNXComObject> retrieveComObjectListByDatapointId(final KNXProject knxProject,
final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(0);
// TODO: maybe create a map from datapoint id to ComObject????
final List<KNXComObject> knxComObjects = knxDeviceInstance.getComObjects().values().stream()
.filter(c -> c.getNumber() == dataPointId).filter(c -> c.isGroupObject()).collect(Collectors.toList());
return knxComObjects;
} | DESIGN | true | public static List<KNXComObject> retrieveComObjectListByDatapointId(final KNXProject knxProject,
final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(0);
// TODO: maybe create a map from datapoint id to ComObject???? | public static List<KNXComObject> retrieveComObjectListByDatapointId(final KNXProject knxProject,
final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(0);
// TODO: maybe create a map from datapoint id to ComObject????
final List<KNXComObject> knxComObjects = knxDeviceInstance.getComObjects().values().stream()
.filter(c -> c.getNumber() == dataPointId).filter(c -> c.isGroupObject()).collect(Collectors.toList());
return knxComObjects;
} | public static List<KNXComObject> retrieveComObjectListByDatapointId(final KNXProject knxProject,
final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(0);
// TODO: maybe create a map from datapoint id to ComObject????
final List<KNXComObject> knxComObjects = knxDeviceInstance.getComObjects().values().stream()
.filter(c -> c.getNumber() == dataPointId).filter(c -> c.isGroupObject()).collect(Collectors.toList());
return knxComObjects;
} |
15,595 | 1 | // TODO: maybe create a map from datapoint id to ComObject???? | public static List<KNXComObject> retrieveComObjectListByDatapointId(final KNXProject knxProject,
final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(0);
// TODO: maybe create a map from datapoint id to ComObject????
final List<KNXComObject> knxComObjects = knxDeviceInstance.getComObjects().values().stream()
.filter(c -> c.getNumber() == dataPointId).filter(c -> c.isGroupObject()).collect(Collectors.toList());
return knxComObjects;
} | DESIGN | true | // list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(0);
// TODO: maybe create a map from datapoint id to ComObject????
final List<KNXComObject> knxComObjects = knxDeviceInstance.getComObjects().values().stream()
.filter(c -> c.getNumber() == dataPointId).filter(c -> c.isGroupObject()).collect(Collectors.toList()); | public static List<KNXComObject> retrieveComObjectListByDatapointId(final KNXProject knxProject,
final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(0);
// TODO: maybe create a map from datapoint id to ComObject????
final List<KNXComObject> knxComObjects = knxDeviceInstance.getComObjects().values().stream()
.filter(c -> c.getNumber() == dataPointId).filter(c -> c.isGroupObject()).collect(Collectors.toList());
return knxComObjects;
} | public static List<KNXComObject> retrieveComObjectListByDatapointId(final KNXProject knxProject,
final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(0);
// TODO: maybe create a map from datapoint id to ComObject????
final List<KNXComObject> knxComObjects = knxDeviceInstance.getComObjects().values().stream()
.filter(c -> c.getNumber() == dataPointId).filter(c -> c.isGroupObject()).collect(Collectors.toList());
return knxComObjects;
} |
15,596 | 0 | // TODO: how to identify the correct device if there are several devices in the
// list? | public static Optional<KNXComObject> retrieveComObjectByDatapointId(final KNXProject knxProject,
final int deviceIndex, final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects()
.values()
.stream()
.filter(c -> c.getNumber() == dataPointId)
.filter(c -> c.isGroupObject())
.findFirst();
// @formatter:on
} | DESIGN | true | public static Optional<KNXComObject> retrieveComObjectByDatapointId(final KNXProject knxProject,
final int deviceIndex, final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject???? | public static Optional<KNXComObject> retrieveComObjectByDatapointId(final KNXProject knxProject,
final int deviceIndex, final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects()
.values()
.stream()
.filter(c -> c.getNumber() == dataPointId)
.filter(c -> c.isGroupObject())
.findFirst(); | public static Optional<KNXComObject> retrieveComObjectByDatapointId(final KNXProject knxProject,
final int deviceIndex, final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects()
.values()
.stream()
.filter(c -> c.getNumber() == dataPointId)
.filter(c -> c.isGroupObject())
.findFirst();
// @formatter:on
} |
15,596 | 1 | // TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off | public static Optional<KNXComObject> retrieveComObjectByDatapointId(final KNXProject knxProject,
final int deviceIndex, final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects()
.values()
.stream()
.filter(c -> c.getNumber() == dataPointId)
.filter(c -> c.isGroupObject())
.findFirst();
// @formatter:on
} | DESIGN | true | // list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects() | public static Optional<KNXComObject> retrieveComObjectByDatapointId(final KNXProject knxProject,
final int deviceIndex, final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects()
.values()
.stream()
.filter(c -> c.getNumber() == dataPointId)
.filter(c -> c.isGroupObject())
.findFirst();
// @formatter:on
} | public static Optional<KNXComObject> retrieveComObjectByDatapointId(final KNXProject knxProject,
final int deviceIndex, final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects()
.values()
.stream()
.filter(c -> c.getNumber() == dataPointId)
.filter(c -> c.isGroupObject())
.findFirst();
// @formatter:on
} |
15,596 | 2 | // @formatter:on | public static Optional<KNXComObject> retrieveComObjectByDatapointId(final KNXProject knxProject,
final int deviceIndex, final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects()
.values()
.stream()
.filter(c -> c.getNumber() == dataPointId)
.filter(c -> c.isGroupObject())
.findFirst();
// @formatter:on
} | NONSATD | true | .filter(c -> c.isGroupObject())
.findFirst();
// @formatter:on
} | final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects()
.values()
.stream()
.filter(c -> c.getNumber() == dataPointId)
.filter(c -> c.isGroupObject())
.findFirst();
// @formatter:on
} | public static Optional<KNXComObject> retrieveComObjectByDatapointId(final KNXProject knxProject,
final int deviceIndex, final int dataPointId) {
// TODO: how to identify the correct device if there are several devices in the
// list?
final KNXDeviceInstance knxDeviceInstance = knxProject.getDeviceInstances().get(deviceIndex);
// TODO: maybe create a map from datapoint id to ComObject????
// @formatter:off
return knxDeviceInstance
.getComObjects()
.values()
.stream()
.filter(c -> c.getNumber() == dataPointId)
.filter(c -> c.isGroupObject())
.findFirst();
// @formatter:on
} |
31,979 | 0 | /**
* Returns an argument map fitting the given value key set (using defined types).
* @param arguments input arguments to test arguments against
* @return argument map with correct value types
*/ | public Map<SkbShellArgument, Object> getArgMap(SkbShellArgument[] arguments){
Map<SkbShellArgument, Object> ret = new LinkedHashMap<SkbShellArgument, Object>();
if(arguments!=null){
for(Entry<String, String> entry : this.getArgMap().entrySet()){
for(SkbShellArgument ssa : arguments){
if(ssa.getKey().equals(entry.getKey())){
switch(ssa.getType()){
case Boolean:
ret.put(ssa, Boolean.valueOf(entry.getValue()));
break;
case Double:
ret.put(ssa, Double.valueOf(entry.getValue()));
break;
case Integer:
ret.put(ssa, Integer.valueOf(entry.getValue()));
break;
case String:
ret.put(ssa, entry.getValue());
break;
case ListString:
String[] ar = StringUtils.split(entry.getValue(), ';');
if(ar!=null){
List<String> val = new ArrayList<>();
for(String s : ar){
val.add(s);
}
ret.put(ssa, val);
}
break;
case ListInteger:
String[] arInt = StringUtils.split(entry.getValue(), ';');
if(arInt!=null){
List<Integer> valInt = new ArrayList<>();
for(String s : arInt){
valInt.add(Integer.valueOf(s));
}
ret.put(ssa, valInt);
}
break;
default:
System.err.println("parser.getArgMap --> argument type not yet supported: " + ssa.getType());//TODO do not use syserr prints
break;
}
}
}
}
}
return ret;
} | NONSATD | true | public Map<SkbShellArgument, Object> getArgMap(SkbShellArgument[] arguments){
Map<SkbShellArgument, Object> ret = new LinkedHashMap<SkbShellArgument, Object>();
if(arguments!=null){
for(Entry<String, String> entry : this.getArgMap().entrySet()){
for(SkbShellArgument ssa : arguments){
if(ssa.getKey().equals(entry.getKey())){
switch(ssa.getType()){
case Boolean:
ret.put(ssa, Boolean.valueOf(entry.getValue()));
break;
case Double:
ret.put(ssa, Double.valueOf(entry.getValue()));
break;
case Integer:
ret.put(ssa, Integer.valueOf(entry.getValue()));
break;
case String:
ret.put(ssa, entry.getValue());
break;
case ListString:
String[] ar = StringUtils.split(entry.getValue(), ';');
if(ar!=null){
List<String> val = new ArrayList<>();
for(String s : ar){
val.add(s);
}
ret.put(ssa, val);
}
break;
case ListInteger:
String[] arInt = StringUtils.split(entry.getValue(), ';');
if(arInt!=null){
List<Integer> valInt = new ArrayList<>();
for(String s : arInt){
valInt.add(Integer.valueOf(s));
}
ret.put(ssa, valInt);
}
break;
default:
System.err.println("parser.getArgMap --> argument type not yet supported: " + ssa.getType());//TODO do not use syserr prints
break;
}
}
}
}
}
return ret;
} | public Map<SkbShellArgument, Object> getArgMap(SkbShellArgument[] arguments){
Map<SkbShellArgument, Object> ret = new LinkedHashMap<SkbShellArgument, Object>();
if(arguments!=null){
for(Entry<String, String> entry : this.getArgMap().entrySet()){
for(SkbShellArgument ssa : arguments){
if(ssa.getKey().equals(entry.getKey())){
switch(ssa.getType()){
case Boolean:
ret.put(ssa, Boolean.valueOf(entry.getValue()));
break;
case Double:
ret.put(ssa, Double.valueOf(entry.getValue()));
break;
case Integer:
ret.put(ssa, Integer.valueOf(entry.getValue()));
break;
case String:
ret.put(ssa, entry.getValue());
break;
case ListString:
String[] ar = StringUtils.split(entry.getValue(), ';');
if(ar!=null){
List<String> val = new ArrayList<>();
for(String s : ar){
val.add(s);
}
ret.put(ssa, val);
}
break;
case ListInteger:
String[] arInt = StringUtils.split(entry.getValue(), ';');
if(arInt!=null){
List<Integer> valInt = new ArrayList<>();
for(String s : arInt){
valInt.add(Integer.valueOf(s));
}
ret.put(ssa, valInt);
}
break;
default:
System.err.println("parser.getArgMap --> argument type not yet supported: " + ssa.getType());//TODO do not use syserr prints
break;
}
}
}
}
}
return ret;
} | public Map<SkbShellArgument, Object> getArgMap(SkbShellArgument[] arguments){
Map<SkbShellArgument, Object> ret = new LinkedHashMap<SkbShellArgument, Object>();
if(arguments!=null){
for(Entry<String, String> entry : this.getArgMap().entrySet()){
for(SkbShellArgument ssa : arguments){
if(ssa.getKey().equals(entry.getKey())){
switch(ssa.getType()){
case Boolean:
ret.put(ssa, Boolean.valueOf(entry.getValue()));
break;
case Double:
ret.put(ssa, Double.valueOf(entry.getValue()));
break;
case Integer:
ret.put(ssa, Integer.valueOf(entry.getValue()));
break;
case String:
ret.put(ssa, entry.getValue());
break;
case ListString:
String[] ar = StringUtils.split(entry.getValue(), ';');
if(ar!=null){
List<String> val = new ArrayList<>();
for(String s : ar){
val.add(s);
}
ret.put(ssa, val);
}
break;
case ListInteger:
String[] arInt = StringUtils.split(entry.getValue(), ';');
if(arInt!=null){
List<Integer> valInt = new ArrayList<>();
for(String s : arInt){
valInt.add(Integer.valueOf(s));
}
ret.put(ssa, valInt);
}
break;
default:
System.err.println("parser.getArgMap --> argument type not yet supported: " + ssa.getType());//TODO do not use syserr prints
break;
}
}
}
}
}
return ret;
} |
31,979 | 1 | //TODO do not use syserr prints | public Map<SkbShellArgument, Object> getArgMap(SkbShellArgument[] arguments){
Map<SkbShellArgument, Object> ret = new LinkedHashMap<SkbShellArgument, Object>();
if(arguments!=null){
for(Entry<String, String> entry : this.getArgMap().entrySet()){
for(SkbShellArgument ssa : arguments){
if(ssa.getKey().equals(entry.getKey())){
switch(ssa.getType()){
case Boolean:
ret.put(ssa, Boolean.valueOf(entry.getValue()));
break;
case Double:
ret.put(ssa, Double.valueOf(entry.getValue()));
break;
case Integer:
ret.put(ssa, Integer.valueOf(entry.getValue()));
break;
case String:
ret.put(ssa, entry.getValue());
break;
case ListString:
String[] ar = StringUtils.split(entry.getValue(), ';');
if(ar!=null){
List<String> val = new ArrayList<>();
for(String s : ar){
val.add(s);
}
ret.put(ssa, val);
}
break;
case ListInteger:
String[] arInt = StringUtils.split(entry.getValue(), ';');
if(arInt!=null){
List<Integer> valInt = new ArrayList<>();
for(String s : arInt){
valInt.add(Integer.valueOf(s));
}
ret.put(ssa, valInt);
}
break;
default:
System.err.println("parser.getArgMap --> argument type not yet supported: " + ssa.getType());//TODO do not use syserr prints
break;
}
}
}
}
}
return ret;
} | DESIGN | true | break;
default:
System.err.println("parser.getArgMap --> argument type not yet supported: " + ssa.getType());//TODO do not use syserr prints
break;
} | String[] arInt = StringUtils.split(entry.getValue(), ';');
if(arInt!=null){
List<Integer> valInt = new ArrayList<>();
for(String s : arInt){
valInt.add(Integer.valueOf(s));
}
ret.put(ssa, valInt);
}
break;
default:
System.err.println("parser.getArgMap --> argument type not yet supported: " + ssa.getType());//TODO do not use syserr prints
break;
}
}
}
}
}
return ret;
} | String[] ar = StringUtils.split(entry.getValue(), ';');
if(ar!=null){
List<String> val = new ArrayList<>();
for(String s : ar){
val.add(s);
}
ret.put(ssa, val);
}
break;
case ListInteger:
String[] arInt = StringUtils.split(entry.getValue(), ';');
if(arInt!=null){
List<Integer> valInt = new ArrayList<>();
for(String s : arInt){
valInt.add(Integer.valueOf(s));
}
ret.put(ssa, valInt);
}
break;
default:
System.err.println("parser.getArgMap --> argument type not yet supported: " + ssa.getType());//TODO do not use syserr prints
break;
}
}
}
}
}
return ret;
} |
15,600 | 0 | /**
* <p>Project a point on the unit sphere stereographically from the north
* pole to complex projective space.</p>
*
* <p><code>(0, 0, 1)</code> is projected to the point with homogeneous
* coordinates <code>(1, 0)</code>.<br> <code>(0, 0, -1)</code> is
* projected to the point with homogenous coordinates <code>(0,
* 1)</code>.</p>
*
* @param cp the {@link ComplexProjective1} used to hand over the
* result. Must not be null.
*
* @throws IllegalArgumentException if {@link #normSquared()} differs from
* <code>1.0</code> by more than {@link #EPSILON}
*/ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | NONSATD | true | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} |
15,600 | 1 | /* Check if the point lies on the sphere. */ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | NONSATD | true | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " + | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result. | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */ |
15,600 | 2 | /* Check if the point lies above or below the xy-plane. */ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | NONSATD | true | "Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad, | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the |
15,600 | 3 | /* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | DESIGN | true | /* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe; | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y; | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm; |
15,600 | 4 | /* Dummy variables */ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | NONSATD | true | * result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm; | throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z; | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe; |
15,600 | 5 | /* Rotate by 180 degree around the x-axis. */ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | NONSATD | true | final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z; | /* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm; |
15,600 | 6 | /* Project that point. Now, z < -EPSILON. */ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | NONSATD | true | y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */ | * numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp); |
15,600 | 7 | /* Rotate back. */ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | NONSATD | true | /* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z; | * result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe; | /* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} |
15,600 | 8 | /* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | DESIGN | true | y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm; | final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
} | "Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} |
15,600 | 9 | /* Point lies below xy-plane so we use */ | public void projectTo(final ComplexProjective1 cp)
throws IllegalArgumentException {
/* Check if the point lies on the sphere. */
if (Math.abs(normSquared() - 1.0) > EPSILON) {
throw new IllegalArgumentException("Norm must be 1.0. " +
"Norm is " + norm() + ". ");
}
/* Check if the point lies above or below the xy-plane. */
if (z > 0.0) {
/* We might be close to the north pole. This would be bad,
* numerically. So perform a 180 degree rotation around the
* x-axis, project that point, and swap the entries of the
* result.
*/
/* Dummy variables */
final double dummyRe;
final double dummyIm;
/* Rotate by 180 degree around the x-axis. */
y = -y;
z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | NONSATD | true | cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
} | * because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} | z = -z;
/* Project that point. Now, z < -EPSILON. */
belowXYProjectTo(cp);
/* Rotate back. */
y = -y;
z = -z;
/* Swap the entries of the result.
*
* TODO: Maybe Complex2 should have a final method that swaps the
* entries. This might speed up dereferencing the fields of cp,
* because dereferencing fiels of other objects might be slower
* than dereferencing fields of the same object. But actually, I
* don't know if that is true or if it matters. */
dummyRe = cp.aRe;
dummyIm = cp.aIm;
cp.aRe = cp.bRe;
cp.aIm = cp.bIm;
cp.bRe = dummyRe;
cp.bIm = dummyIm;
} else {
/* Point lies below xy-plane so we use */
belowXYProjectTo(cp);
}
} |
31,991 | 0 | //## todo: maybe support multiple files here? | public static void doGoTo( String strQualifedType )
{
EditorUtilities.showWaitCursor( true );
try
{
IType type = TypeSystem.getByFullNameIfValid( strQualifedType );
if( type == null )
{
return;
}
IFile[] sourceFiles = type.getSourceFiles();
if( sourceFiles != null && sourceFiles.length > 0 )
{
//## todo: maybe support multiple files here?
IFile sourceFile = sourceFiles[0];
LabFrame.instance().openFile( PathUtil.create( sourceFile.toURI() ) );
}
}
catch( Exception e )
{
throw new RuntimeException( e );
}
finally
{
EditorUtilities.showWaitCursor( false );
}
} | DESIGN | true | if( sourceFiles != null && sourceFiles.length > 0 )
{
//## todo: maybe support multiple files here?
IFile sourceFile = sourceFiles[0];
LabFrame.instance().openFile( PathUtil.create( sourceFile.toURI() ) ); | try
{
IType type = TypeSystem.getByFullNameIfValid( strQualifedType );
if( type == null )
{
return;
}
IFile[] sourceFiles = type.getSourceFiles();
if( sourceFiles != null && sourceFiles.length > 0 )
{
//## todo: maybe support multiple files here?
IFile sourceFile = sourceFiles[0];
LabFrame.instance().openFile( PathUtil.create( sourceFile.toURI() ) );
}
}
catch( Exception e )
{
throw new RuntimeException( e );
}
finally
{ | public static void doGoTo( String strQualifedType )
{
EditorUtilities.showWaitCursor( true );
try
{
IType type = TypeSystem.getByFullNameIfValid( strQualifedType );
if( type == null )
{
return;
}
IFile[] sourceFiles = type.getSourceFiles();
if( sourceFiles != null && sourceFiles.length > 0 )
{
//## todo: maybe support multiple files here?
IFile sourceFile = sourceFiles[0];
LabFrame.instance().openFile( PathUtil.create( sourceFile.toURI() ) );
}
}
catch( Exception e )
{
throw new RuntimeException( e );
}
finally
{
EditorUtilities.showWaitCursor( false );
}
} |
15,621 | 0 | /**
* Initialize the cipher
* @return true if it succeeded false if it did not
*/ | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | NONSATD | true | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} |
15,621 | 1 | //Obtain a cipher instance and configure it with the properties required for fingerprint authentication// | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | NONSATD | true | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance( | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false; | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
} |
15,621 | 2 | // key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed? | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | DESIGN | true | }
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) { | try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed// | this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} |
15,621 | 3 | //Return true if the cipher has been initialized successfully// | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | NONSATD | true | }
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) { | this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false; | e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} |
15,621 | 4 | //Return false if cipher initialization failed// | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | NONSATD | true | return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException | // key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} |
15,621 | 5 | //KeyStoreException | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | NONSATD | true | //Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException | if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} |
15,621 | 6 | //UnrecoverableKeyException | private boolean initCipher() {
try {
//Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
if(this.cipher == null) {
this.cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
}
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
e.printStackTrace();
return false;
}
try {
if(this.secretKey == null) {
this.secretKey = generateKey();
}
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | NONSATD | true | return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) { | this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} | }
if(this.keyStore != null) {
if(!this.keystoreInitialized) {
this.keyStore.load(null);
this.keystoreInitialized = true;
}
}
// key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
if(this.cipher != null) {
if (!this.cipherInitialized) {
this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
this.cipherInitialized = true;
}
}
//Return true if the cipher has been initialized successfully//
return true;
} catch (KeyPermanentlyInvalidatedException e) {
//Return false if cipher initialization failed//
return false;
} catch (CertificateException //KeyStoreException
| IOException //UnrecoverableKeyException
| NullPointerException
| NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
return false;
}
} |
32,006 | 0 | // TODO: improve by stacking events and apply them all at the same time or something in the process method. | @Override
public void handleEvent(Event event) {
List<Entity> entities = entityManager.getEntitiesContainingComponent(VisionComponent.class);
if (entities == null)
return;
EntityCreatedEvent entityCreatedEvent = (EntityCreatedEvent) event;
for (Entity entity : entities) {
VisionComponent visionComponent = (VisionComponent) entityManager.getComponentInEntity(entity, VisionComponent.class);
visionComponent.createEntity(entityCreatedEvent.getEntity());
System.out.println("EntityEvent: " + entityCreatedEvent.getEntity());
}
} | DESIGN | true | @Override
public void handleEvent(Event event) {
List<Entity> entities = entityManager.getEntitiesContainingComponent(VisionComponent.class);
if (entities == null)
return;
EntityCreatedEvent entityCreatedEvent = (EntityCreatedEvent) event;
for (Entity entity : entities) {
VisionComponent visionComponent = (VisionComponent) entityManager.getComponentInEntity(entity, VisionComponent.class);
visionComponent.createEntity(entityCreatedEvent.getEntity());
System.out.println("EntityEvent: " + entityCreatedEvent.getEntity());
}
} | @Override
public void handleEvent(Event event) {
List<Entity> entities = entityManager.getEntitiesContainingComponent(VisionComponent.class);
if (entities == null)
return;
EntityCreatedEvent entityCreatedEvent = (EntityCreatedEvent) event;
for (Entity entity : entities) {
VisionComponent visionComponent = (VisionComponent) entityManager.getComponentInEntity(entity, VisionComponent.class);
visionComponent.createEntity(entityCreatedEvent.getEntity());
System.out.println("EntityEvent: " + entityCreatedEvent.getEntity());
}
} | @Override
public void handleEvent(Event event) {
List<Entity> entities = entityManager.getEntitiesContainingComponent(VisionComponent.class);
if (entities == null)
return;
EntityCreatedEvent entityCreatedEvent = (EntityCreatedEvent) event;
for (Entity entity : entities) {
VisionComponent visionComponent = (VisionComponent) entityManager.getComponentInEntity(entity, VisionComponent.class);
visionComponent.createEntity(entityCreatedEvent.getEntity());
System.out.println("EntityEvent: " + entityCreatedEvent.getEntity());
}
} |
15,624 | 0 | /**
* Add necessary code to the source and necessary build supports to
* enable the requested serializations in 'enabledSerializations'
*/ | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} | NONSATD | true | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} |
15,624 | 1 | // Enable support for proto serialization | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} | NONSATD | true | public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
} | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files. | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet |
15,624 | 2 | // Handle .proto files. | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} | NONSATD | true | }
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator); | // Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} |
15,624 | 3 | // FIXME: Not supported yet | @Override
public void enableSupportForSerializationIfApplicable(CancelIndicator cancelIndicator) {
if (!IterableExtensions.isNullOrEmpty(targetConfig.protoFiles)) {
// Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} | IMPLEMENTATION | true | }
case ROS2: {
// FIXME: Not supported yet
}
} | // Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} | // Enable support for proto serialization
enabledSerializers.add(SupportedSerializers.PROTO);
}
for (SupportedSerializers serialization : enabledSerializers) {
switch (serialization) {
case NATIVE: {
FedNativePythonSerialization pickler = new FedNativePythonSerialization();
code.pr(pickler.generatePreambleForSupport().toString());
}
case PROTO: {
// Handle .proto files.
for (String name : targetConfig.protoFiles) {
this.processProtoFile(name, cancelIndicator);
int dotIndex = name.lastIndexOf(".");
String rootFilename = dotIndex > 0 ? name.substring(0, dotIndex) : name;
pythonPreamble.pr("import "+rootFilename+"_pb2 as "+rootFilename);
protoNames.add(rootFilename);
}
}
case ROS2: {
// FIXME: Not supported yet
}
}
}
} |
15,626 | 0 | /**
* Write a Dockerfile for the current federate as given by filename.
* The file will go into src-gen/filename.Dockerfile.
* If there is no main reactor, then no Dockerfile will be generated
* (it wouldn't be very useful).
* @param The directory where the docker compose file is generated.
* @param The name of the docker file.
* @param The name of the federate.
*/ | @Override
public void writeDockerFile(File dockerComposeDir, String dockerFileName, String federateName) {
if (mainDef == null) {
return;
}
Path srcGenPath = fileConfig.getSrcGenPath();
String dockerFile = srcGenPath + File.separator + dockerFileName;
CodeBuilder contents = new CodeBuilder();
contents.pr(PythonDockerGenerator.generateDockerFileContent(topLevelName, srcGenPath));
try {
// If a dockerfile exists, remove it.
Files.deleteIfExists(srcGenPath.resolve(dockerFileName));
contents.writeToFile(dockerFile);
} catch (IOException e) {
Exceptions.sneakyThrow(e);
}
System.out.println(getDockerBuildCommand(dockerFile, dockerComposeDir, federateName));
} | NONSATD | true | @Override
public void writeDockerFile(File dockerComposeDir, String dockerFileName, String federateName) {
if (mainDef == null) {
return;
}
Path srcGenPath = fileConfig.getSrcGenPath();
String dockerFile = srcGenPath + File.separator + dockerFileName;
CodeBuilder contents = new CodeBuilder();
contents.pr(PythonDockerGenerator.generateDockerFileContent(topLevelName, srcGenPath));
try {
// If a dockerfile exists, remove it.
Files.deleteIfExists(srcGenPath.resolve(dockerFileName));
contents.writeToFile(dockerFile);
} catch (IOException e) {
Exceptions.sneakyThrow(e);
}
System.out.println(getDockerBuildCommand(dockerFile, dockerComposeDir, federateName));
} | @Override
public void writeDockerFile(File dockerComposeDir, String dockerFileName, String federateName) {
if (mainDef == null) {
return;
}
Path srcGenPath = fileConfig.getSrcGenPath();
String dockerFile = srcGenPath + File.separator + dockerFileName;
CodeBuilder contents = new CodeBuilder();
contents.pr(PythonDockerGenerator.generateDockerFileContent(topLevelName, srcGenPath));
try {
// If a dockerfile exists, remove it.
Files.deleteIfExists(srcGenPath.resolve(dockerFileName));
contents.writeToFile(dockerFile);
} catch (IOException e) {
Exceptions.sneakyThrow(e);
}
System.out.println(getDockerBuildCommand(dockerFile, dockerComposeDir, federateName));
} | @Override
public void writeDockerFile(File dockerComposeDir, String dockerFileName, String federateName) {
if (mainDef == null) {
return;
}
Path srcGenPath = fileConfig.getSrcGenPath();
String dockerFile = srcGenPath + File.separator + dockerFileName;
CodeBuilder contents = new CodeBuilder();
contents.pr(PythonDockerGenerator.generateDockerFileContent(topLevelName, srcGenPath));
try {
// If a dockerfile exists, remove it.
Files.deleteIfExists(srcGenPath.resolve(dockerFileName));
contents.writeToFile(dockerFile);
} catch (IOException e) {
Exceptions.sneakyThrow(e);
}
System.out.println(getDockerBuildCommand(dockerFile, dockerComposeDir, federateName));
} |
15,626 | 1 | // If a dockerfile exists, remove it. | @Override
public void writeDockerFile(File dockerComposeDir, String dockerFileName, String federateName) {
if (mainDef == null) {
return;
}
Path srcGenPath = fileConfig.getSrcGenPath();
String dockerFile = srcGenPath + File.separator + dockerFileName;
CodeBuilder contents = new CodeBuilder();
contents.pr(PythonDockerGenerator.generateDockerFileContent(topLevelName, srcGenPath));
try {
// If a dockerfile exists, remove it.
Files.deleteIfExists(srcGenPath.resolve(dockerFileName));
contents.writeToFile(dockerFile);
} catch (IOException e) {
Exceptions.sneakyThrow(e);
}
System.out.println(getDockerBuildCommand(dockerFile, dockerComposeDir, federateName));
} | NONSATD | true | contents.pr(PythonDockerGenerator.generateDockerFileContent(topLevelName, srcGenPath));
try {
// If a dockerfile exists, remove it.
Files.deleteIfExists(srcGenPath.resolve(dockerFileName));
contents.writeToFile(dockerFile); | @Override
public void writeDockerFile(File dockerComposeDir, String dockerFileName, String federateName) {
if (mainDef == null) {
return;
}
Path srcGenPath = fileConfig.getSrcGenPath();
String dockerFile = srcGenPath + File.separator + dockerFileName;
CodeBuilder contents = new CodeBuilder();
contents.pr(PythonDockerGenerator.generateDockerFileContent(topLevelName, srcGenPath));
try {
// If a dockerfile exists, remove it.
Files.deleteIfExists(srcGenPath.resolve(dockerFileName));
contents.writeToFile(dockerFile);
} catch (IOException e) {
Exceptions.sneakyThrow(e);
}
System.out.println(getDockerBuildCommand(dockerFile, dockerComposeDir, federateName));
} | @Override
public void writeDockerFile(File dockerComposeDir, String dockerFileName, String federateName) {
if (mainDef == null) {
return;
}
Path srcGenPath = fileConfig.getSrcGenPath();
String dockerFile = srcGenPath + File.separator + dockerFileName;
CodeBuilder contents = new CodeBuilder();
contents.pr(PythonDockerGenerator.generateDockerFileContent(topLevelName, srcGenPath));
try {
// If a dockerfile exists, remove it.
Files.deleteIfExists(srcGenPath.resolve(dockerFileName));
contents.writeToFile(dockerFile);
} catch (IOException e) {
Exceptions.sneakyThrow(e);
}
System.out.println(getDockerBuildCommand(dockerFile, dockerComposeDir, federateName));
} |
15,630 | 0 | // #7086 - (nf.exists() && !nf.equals(of)) instead of nf.exists() - fix for Win32 | protected void rename(String oldName, String newName) throws IOException {
File of = getFile (oldName);
File nf = getFile (newName);
// #7086 - (nf.exists() && !nf.equals(of)) instead of nf.exists() - fix for Win32
if ((nf.exists() && !nf.equals(of)) || !of.renameTo (nf)) {
FSException.io ("EXC_CannotRename", oldName, getDisplayName (), newName); // NOI18N
}
} | NONSATD | true | File of = getFile (oldName);
File nf = getFile (newName);
// #7086 - (nf.exists() && !nf.equals(of)) instead of nf.exists() - fix for Win32
if ((nf.exists() && !nf.equals(of)) || !of.renameTo (nf)) {
FSException.io ("EXC_CannotRename", oldName, getDisplayName (), newName); // NOI18N | protected void rename(String oldName, String newName) throws IOException {
File of = getFile (oldName);
File nf = getFile (newName);
// #7086 - (nf.exists() && !nf.equals(of)) instead of nf.exists() - fix for Win32
if ((nf.exists() && !nf.equals(of)) || !of.renameTo (nf)) {
FSException.io ("EXC_CannotRename", oldName, getDisplayName (), newName); // NOI18N
}
} | protected void rename(String oldName, String newName) throws IOException {
File of = getFile (oldName);
File nf = getFile (newName);
// #7086 - (nf.exists() && !nf.equals(of)) instead of nf.exists() - fix for Win32
if ((nf.exists() && !nf.equals(of)) || !of.renameTo (nf)) {
FSException.io ("EXC_CannotRename", oldName, getDisplayName (), newName); // NOI18N
}
} |
15,630 | 1 | // NOI18N | protected void rename(String oldName, String newName) throws IOException {
File of = getFile (oldName);
File nf = getFile (newName);
// #7086 - (nf.exists() && !nf.equals(of)) instead of nf.exists() - fix for Win32
if ((nf.exists() && !nf.equals(of)) || !of.renameTo (nf)) {
FSException.io ("EXC_CannotRename", oldName, getDisplayName (), newName); // NOI18N
}
} | NONSATD | true | // #7086 - (nf.exists() && !nf.equals(of)) instead of nf.exists() - fix for Win32
if ((nf.exists() && !nf.equals(of)) || !of.renameTo (nf)) {
FSException.io ("EXC_CannotRename", oldName, getDisplayName (), newName); // NOI18N
}
} | protected void rename(String oldName, String newName) throws IOException {
File of = getFile (oldName);
File nf = getFile (newName);
// #7086 - (nf.exists() && !nf.equals(of)) instead of nf.exists() - fix for Win32
if ((nf.exists() && !nf.equals(of)) || !of.renameTo (nf)) {
FSException.io ("EXC_CannotRename", oldName, getDisplayName (), newName); // NOI18N
}
} | protected void rename(String oldName, String newName) throws IOException {
File of = getFile (oldName);
File nf = getFile (newName);
// #7086 - (nf.exists() && !nf.equals(of)) instead of nf.exists() - fix for Win32
if ((nf.exists() && !nf.equals(of)) || !of.renameTo (nf)) {
FSException.io ("EXC_CannotRename", oldName, getDisplayName (), newName); // NOI18N
}
} |
15,634 | 0 | /*
* When 'node' has been created under 'parent' (by the sessionContext user) this will send a
* notification to foreign servers. This call returns immediately and delegates the actuall
* proccessing to a daemon thread.
*
* For concurrency reasons, note that we pass in the nodeId to this method rather than the node even
* if we do have the node, because we want to make sure there's no concurrent access.
*
* IMPORTANT: This method ONLY sends notifications to users who ARE in the 'acl' which means these
* can only be users ALREADY imported into the system, however this is ok, because we will have
* called saveMentionsToNodeACL() right before calling this method so the 'acl' should completely
* contain all the mentions that exist in the text of the message.
*
* todo-0: we should probably extract OUT of this method the actual construction of the 'message'
* itself and then pass the message in as a parameter, and we'd be passing in without setting the
* 'cc + to' properties on the message and then the message would have those added inside here
* insead of building the entire message from scratch.
*/ | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | DESIGN | true | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} |
15,634 | 1 | // Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is. | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null; | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else { | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames' |
15,634 | 2 | // toUserNames will hold ALL usernames in the ACL list (both local and foreign user names) | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true; | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) { | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
} |
15,634 | 3 | /*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/ | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | } else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) { | APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
} | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) { |
15,634 | 4 | // get username off this node and add to 'toUserNames' | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | } else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER)); | } else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser); | // what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save |
15,634 | 5 | // String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s()); | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | }
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser); | } else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else { | if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else { |
15,634 | 6 | // construct the Update-type wrapper around teh Person object, and send | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message)); | }
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage); | for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>(); |
15,634 | 7 | // if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?) | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | DESIGN | true | log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); | String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
} | SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them |
15,634 | 8 | // else send out as a note. | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType, | log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) { | }
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above. |
15,634 | 9 | // for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | }
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here | ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF); | APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e); |
15,634 | 10 | // When posting a public message we send out to all unique sharedInboxes here | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | // individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>(); | }
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue | message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
}); |
15,634 | 11 | // loads ONLY foreign user's inboxes into the two sets. | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them | message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes); | // if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} |
15,634 | 12 | // merge both sets of inboxes into allInboxes and send to them | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | // loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes); | }
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} // | // that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} |
15,634 | 13 | // Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above. | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes); | // When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | }
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} |
15,634 | 14 | // | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId);
// get username off this node and add to 'toUserNames'
if (ok(accntNode)) {
toUserNames.add(accntNode.getStr(NodeProp.USER));
}
}
}
}
}
// String apId = parent.getStringProp(NodeProp.ACT_PUB_ID.s());
String fromUser = ThreadLocals.getSC().getUserName();
String fromActor = apUtil.makeActorUrlForUserName(fromUser);
String privateKey = apCrypto.getPrivateKey(ms, fromUser);
String objUrl = snUtil.getIdBasedUrl(node);
APObj message = null;
if (node.getType().equals(NodeType.ACCOUNT.s())) {
// construct the Update-type wrapper around teh Person object, and send
message = apFactory.newUpdateForPerson(fromUser, toUserNames, fromActor, privateMessage, node);
log.debug("Sending updated Person outbound: " + XString.prettyPrint(message));
} else {
// if this node has a boostTarget, we know it's an Announce so we send out the announce
// todo-0: we should probably rely on if there's an ActPub TYPE itself that's "Announce" (we save
// that right?)
if (!StringUtils.isEmpty(boostTarget)) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
message =
apFactory.newAnnounce(fromUser, fromActor, objUrl, toUserNames, boostTarget, now, privateMessage);
}
// else send out as a note.
else {
message = apFactory.newCreateForNote(fromUser, toUserNames, fromActor, inReplyTo, replyToType,
node.getContent(), objUrl, privateMessage, attachments);
}
}
// for users that don't have a sharedInbox we collect their inboxes here to send to them
// individually
HashSet<String> userInboxes = new HashSet<>();
// When posting a public message we send out to all unique sharedInboxes here
if (!privateMessage) {
HashSet<String> sharedInboxes = new HashSet<>();
// loads ONLY foreign user's inboxes into the two sets.
getSharedInboxesOfFollowers(fromUser, sharedInboxes, userInboxes);
// merge both sets of inboxes into allInboxes and send to them
HashSet<String> allInboxes = new HashSet<>(userInboxes);
allInboxes.addAll(sharedInboxes);
apUtil.securePostEx(allInboxes, fromActor, privateKey, fromActor, message, APConst.MTYPE_LD_JSON_PROF);
}
// Post message to all foreign usernames found in 'toUserNames', but skip all in userInboxes becasue
// we just sent to those above.
if (toUserNames.size() > 0) {
sendMessageToUsers(ms, toUserNames, fromUser, message, privateMessage, userInboxes);
}
} //
catch (Exception e) {
log.error("sendNote failed", e);
throw new RuntimeException(e);
}
});
} | NONSATD | true | try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null; | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false; | public void sendObjOutbound(MongoSession ms, SubNode parent, SubNode node, boolean forceSendToPublic) {
exec.run(() -> {
try {
boolean isAccnt = NodeType.ACCOUNT.s().equals(node.getType());
// Get the inReplyTo from the parent property (foreign node) or if not found generate one based on
// what the local server version of it is.
String inReplyTo = !isAccnt ? apUtil.buildUrlForReplyTo(ms, parent) : null;
APList attachments = !isAccnt ? apub.createAttachmentsList(node) : null;
String replyToType = parent.getStr(NodeProp.ACT_PUB_OBJ_TYPE);
String boostTarget = parent.getStr(NodeProp.BOOST);
// toUserNames will hold ALL usernames in the ACL list (both local and foreign user names)
HashSet<String> toUserNames = new HashSet<>();
boolean privateMessage = true;
if (forceSendToPublic) {
privateMessage = false;
} else {
if (ok(node.getAc())) {
/*
* Lookup all userNames from the ACL info, to add them all to 'toUserNames'
*/
for (String accntId : node.getAc().keySet()) {
if (PrincipalName.PUBLIC.s().equals(accntId)) {
privateMessage = false;
} else {
SubNode accntNode = cachedGetAccntNodeById(ms, accntId); |
23,837 | 0 | /**
* Writes the runner project out.
*
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws ParseException
* If the source code has parser errors.
* @throws XmlException
* If an XML related exception occurs.
*/ | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} |
23,837 | 1 | // TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | DESIGN | true | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted() | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type |
23,837 | 2 | // copy snippets | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | // TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath()); | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) { | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported"); |
23,837 | 3 | // create INFO file | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file); | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer) |
23,837 | 4 | // remove SETTE annotations and imports from file | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | // create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath()) | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!) |
23,837 | 5 | // parse source with JavaParser | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | .collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file); | PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
} | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath()); |
23,837 | 6 | // extract type | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) { | // remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!) | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette")); |
23,837 | 7 | // NOTE better exception type | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported"); | .filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) { | // TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) { |
23,837 | 8 | // skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!) | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | }
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations); | CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette")); | // create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports |
23,837 | 9 | // remove SETTE annotations from the class | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette")); | // skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs"); | CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false; |
23,837 | 10 | // remove SETTE annotations from the members | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | .startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation); | JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString(); | if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) { |
23,837 | 11 | // TODO enhance | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | DESIGN | true | member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs"); | PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
} | }
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
} |
23,837 | 12 | // remove SETTE imports | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString(); | .startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code | // generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries |
23,837 | 13 | // save edited source code | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) { | // remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries | .startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} |
23,837 | 14 | // FIXME remove after javaparser bug is fixed | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | DEFECT | true | String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {"); | for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath()); | for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} |
23,837 | 15 | // copy libraries | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | }
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(), | // save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | // remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} |
23,837 | 16 | // create project | private void writeRunnerProject() throws IOException, XmlException, ParseException {
// TODO revise whole method
// TODO now using a newer JAPA (suuports java 8), -> maybe ANTLR supports better
PathUtils.createDir(getRunnerProjectSettings().getBaseDir().toPath());
// copy snippets
PathUtils.copy(getSnippetProject().getSourceDir(),
getRunnerProjectSettings().getSnippetSourceDirectory().toPath());
// create INFO file
writeInfoFile();
// remove SETTE annotations and imports from file
Collection<File> filesWritten = Files
.walk(getRunnerProjectSettings().getSnippetSourceDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).sorted()
.collect(Collectors.toList());
for (File file : filesWritten) {
// parse source with JavaParser
log.debug("Parsing with JavaParser: {}", file);
CompilationUnit compilationUnit = JavaParser.parse(file);
log.debug("Parsed with JavaParser: {}", file);
// extract type
List<TypeDeclaration> types = compilationUnit.getTypes();
if (types.size() != 1) {
// NOTE better exception type
throw new RuntimeException(
"Java source files containing more that one types are not supported");
}
TypeDeclaration type = types.get(0);
// skip file if Java version is not supported by the tool (@SetteSnippetContainer)
// NOTE it can be also done with snippet containers... (and also done in CATG
// generator!)
List<AnnotationExpr> classAnnotations = type.getAnnotations();
JavaVersion reqJavaVer = getRequiredJavaVersion(classAnnotations);
if (reqJavaVer != null && !getTool().supportsJavaVersion(reqJavaVer)) {
System.err.println(
"Skipping file: " + file + " (required Java version: " + reqJavaVer + ")");
PathUtils.delete(file.toPath());
} else {
// remove SETTE annotations from the class
Predicate<AnnotationExpr> isSetteAnnotation = (a -> a.getName().getName()
.startsWith("Sette"));
classAnnotations.removeIf(isSetteAnnotation);
// remove SETTE annotations from the members
for (BodyDeclaration member : type.getMembers()) {
member.getAnnotations().removeIf(isSetteAnnotation);
}
// TODO enhance
List<String> toRemovePrefixes = new ArrayList<>();
toRemovePrefixes.add("hu.bme.mit.sette.snippets.inputs");
toRemovePrefixes.add("hu.bme.mit.sette.common");
// remove SETTE imports
compilationUnit.getImports().removeIf(importDeclaration -> {
String impDecl = importDeclaration.getName().toString();
for (String prefix : toRemovePrefixes) {
if (impDecl.startsWith(prefix)) {
return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | NONSATD | true | getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} | return true;
}
}
return false;
});
// save edited source code
String source = compilationUnit.toString();
if (type instanceof EnumDeclaration) {
// FIXME remove after javaparser bug is fixed
source = source.replaceFirst(type.getName() + "\\s+implements\\s*\\{",
type.getName() + " {");
}
PathUtils.write(file.toPath(), source.getBytes());
}
}
// copy libraries
if (getSnippetProject().getLibDir().toFile().exists()) {
PathUtils.copy(getSnippetProject().getLibDir(),
getRunnerProjectSettings().getSnippetLibraryDirectory().toPath());
}
// create project
this.eclipseProject.save(getRunnerProjectSettings().getBaseDir().toPath());
} |
32,041 | 0 | // create a rev with an attachment, then update it keeping attachment
// TODO we need to somehow check the attachment wasn't re-downloaded | @Test
public void dontPullAttachmentAlreadyPulled() {
try {
// create a rev with an attachment, then update it keeping attachment
// TODO we need to somehow check the attachment wasn't re-downloaded
createRevisionAndBigTextAttachment();
pull();
DocumentRevision docRev1 = datastore.getDocument(id, rev);
Attachment a1 = datastore.getAttachment(docRev1, bigTextAttachmentName);
updateRevisionAndKeepAttachment();
updateRevisionAndKeepAttachment();
pull();
DocumentRevision docRev2 = datastore.getDocument(id, rev);
Attachment a2 = datastore.getAttachment(docRev2, bigTextAttachmentName);
Assert.assertNotNull(a2);
} catch (Exception e) {
Assert.fail("Create/pull error " + e);
}
} | DESIGN | true | public void dontPullAttachmentAlreadyPulled() {
try {
// create a rev with an attachment, then update it keeping attachment
// TODO we need to somehow check the attachment wasn't re-downloaded
createRevisionAndBigTextAttachment();
pull(); | @Test
public void dontPullAttachmentAlreadyPulled() {
try {
// create a rev with an attachment, then update it keeping attachment
// TODO we need to somehow check the attachment wasn't re-downloaded
createRevisionAndBigTextAttachment();
pull();
DocumentRevision docRev1 = datastore.getDocument(id, rev);
Attachment a1 = datastore.getAttachment(docRev1, bigTextAttachmentName);
updateRevisionAndKeepAttachment();
updateRevisionAndKeepAttachment();
pull();
DocumentRevision docRev2 = datastore.getDocument(id, rev);
Attachment a2 = datastore.getAttachment(docRev2, bigTextAttachmentName);
Assert.assertNotNull(a2); | @Test
public void dontPullAttachmentAlreadyPulled() {
try {
// create a rev with an attachment, then update it keeping attachment
// TODO we need to somehow check the attachment wasn't re-downloaded
createRevisionAndBigTextAttachment();
pull();
DocumentRevision docRev1 = datastore.getDocument(id, rev);
Attachment a1 = datastore.getAttachment(docRev1, bigTextAttachmentName);
updateRevisionAndKeepAttachment();
updateRevisionAndKeepAttachment();
pull();
DocumentRevision docRev2 = datastore.getDocument(id, rev);
Attachment a2 = datastore.getAttachment(docRev2, bigTextAttachmentName);
Assert.assertNotNull(a2);
} catch (Exception e) {
Assert.fail("Create/pull error " + e);
}
} |
23,864 | 0 | /**
* A method to build an exp4j expression for a formula object,
* given that a valid formula equation was input by the configuration file.
* @throws An exception if _formulaEquation cannot be parsed.
* @return ?
*/
//TODO: Add exceptions for nulls, bad ins, w.e. | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | IMPLEMENTATION | true | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} |
23,864 | 1 | // Make base Exp4j ExpressionBuilder using _formulaEquation string as input | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | NONSATD | true | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) { | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} |
23,864 | 2 | // Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | NONSATD | true | // Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
} | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} |
23,864 | 3 | // Make a matcher to get the variables out of the formula equation string given, using above pattern | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | NONSATD | true | // ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression. | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} |
23,864 | 4 | // While regex matcher can find matching values, set them as variables in exp4j expressionbuilder | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | NONSATD | true | // Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0) | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression; | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} |
23,864 | 5 | // While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0) | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | NONSATD | true | // While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} |
23,864 | 6 | // Set ith match from regex as a variable in the formula expression builder | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | NONSATD | true | // While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
} | ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} |
23,864 | 7 | // Once regex stuff is done and variables are set, properly build the expression. | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | NONSATD | true | }
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression; | // Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} | private Expression _buildExpression() {
// Make base Exp4j ExpressionBuilder using _formulaEquation string as input
ExpressionBuilder _formulaExpressionBuilder = new ExpressionBuilder(this._formulaEquation);
// Setup regex pattern we want to use to isolate formula variables from _formulaEquation string
// ==In terms of modularity, should we keep the regex string we use as a field for formulas that can be changed by config? Dunno, probably not, would be interesting though
Pattern _formulaRegex = new Pattern.compile("\s?_[a-zA-z0-9_]*_\s?");
// Make a matcher to get the variables out of the formula equation string given, using above pattern
Matcher _formulaVarMatcher = new _formulaRegex.matcher(this._formulaEquation);
// While regex matcher can find matching values, set them as variables in exp4j expressionbuilder
while (_formulaVarMatcher.find()) {
// While index i, starting at 1, is less than matcher.groupCount(), which inherently does not include groupCount(0)
for (int i=1; i<=_formulaVarMatcher.groupCount(); i++) {
// Set ith match from regex as a variable in the formula expression builder
_formulaExpressionBuilder.variable(_formulaVarMatcher.group(i));
}
}
// Once regex stuff is done and variables are set, properly build the expression.
Expression _formulaExpression = _formulaExpressionBuilder.build();
return _formulaExpression;
} |
32,069 | 0 | /**
* internal method to load the other classes as requires by the user
*/ | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} |
32,069 | 1 | //deserialize the database | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) { | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) { | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse(); |
32,069 | 2 | //show options | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit"); | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
} | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it |
32,069 | 3 | //start the parser | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine(); | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break; | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu |
32,069 | 4 | //read the options in the parser configuration file | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
} | outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?) |
32,069 | 5 | //same as before | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser | System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input! |
32,069 | 6 | //initializing the database parser | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | }
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break; | System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances |
32,069 | 7 | //handing control to the parser | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor | switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it! | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
} |
32,069 | 8 | //start the editor | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse(); | BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?) | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} |
32,069 | 9 | //initializing the editor | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu | String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} |
32,069 | 10 | //the editor is capable of returning to the main menu | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it | ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?) | outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} |
32,069 | 11 | //configure everything again? | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway | s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting..."); | while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} |
32,069 | 12 | //configuration system is self-initialising, just hand over control to it | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel | }
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye | //show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} |
32,069 | 13 | //that's all, after configuration, the program needs to be restarted anyway | private void init() throws Exception {
loadDB();//deserialize the database
outer:
while (true) {
//show options
System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} | NONSATD | true | case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it! | Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input! | System.out.println("Main menu:");
System.out.println("1:Start Parsing\n2:Start Browsing\n3:Start Configuration System\n4:Export Current Database\n5:Import a database\n6:Exit");
switch (Integer.parseInt(br.readLine())) {
case 1://start the parser
BufferedReader br2 = new BufferedReader(new FileReader(FILES[2]));
String s = br2.readLine();
while (s != null) {
ar.add(s);//read the options in the parser configuration file
s = br2.readLine();
}
Codes.fixInput(ar);//same as before
Parser p = new Parser(db, ar.toArray(new String[ar.size()]), status);//initializing the database parser
p.parse();//handing control to the parser
break;
case 2://start the editor
Editor e = new Editor(db, auto_entry);//initializing the editor
e.browse();
break;//the editor is capable of returning to the main menu
case 3://configure everything again?
ConfigCLI.init();//configuration system is self-initialising, just hand over control to it
break outer;//that's all, after configuration, the program needs to be restarted anyway
case 4://export the current database to a Database_Exported.csv file,which opens in MS Excel
new ExportImport().exporter(db, auto_entry);//initializing the export system and handing over control to it!
break;//we can come back to the main menu
case 5://import an existing exported database(using this program on a different computer?)
new ExportImport().importer(db, auto_entry);//now it's the import system
break;//same as case 4
case 6://No!!! Don't leave me behind!(Can't do anything about it anyway, can I?)
System.out.println("Exiting...");
System.exit(0);//Bye-Bye
default://Stop making mistakes in input!
//I'm very considerate, I give everybody infinite chances
}
}
} |