About mybatis3.3 databaseId,the code is useless - mybatis

I study the mybatis3.3 sources code and now I have a question:in the XMLMapperBuilder.databaseIdMatchesCurrent()
private boolean databaseIdMatchesCurrent(String id, String databaseId, String requiredDatabaseId) {
if (requiredDatabaseId != null) {
if (!requiredDatabaseId.equals(databaseId)) {
return false;
}
} else {
if (databaseId != null) {
return false;
}
// skip this fragment if there is a previous one with a not null databaseId
if (this.sqlFragments.containsKey(id)) {
XNode context = this.sqlFragments.get(id);
if (context.getStringAttribute("databaseId") != null) {
return false;
}
}
}
return true;
}
if the (requiredDatabaseId == null && databaseId != null) ,then the function will return false.
So the code
if (this.sqlFragments.containsKey(id)) {
XNode context = this.sqlFragments.get(id);
if (context.getStringAttribute("databaseId") != null) {
return false;
}
}
certainly no way to return false and this code is useless.
I just want to questioning: I understand this, right?

Related

flutter search in search

This is the onsearch function that searches for all custnum addresses.
onSearch(String text) async {
print(text);
List<Item> itemII = items;
if (text.isNotEmpty) {
List<Item> itemList = [];
for (var item in itemII) {
if (item.custnum == text.toLowerCase().toUpperCase()) {
itemList.add(item);
}
}
setState(() {
searchText = text;
searchitems.clear();
searchitems.addAll(itemList);
MainPage.searchItemMainPage.addAll(itemList);
if (searchitems.isNotEmpty) {
print({MainPage.searchItemMainPage[0].address});
searchitems[0].address!.sort((a, b) {
if (a.for_bill == 'Y' && b.for_bill == 'N') {
return -1;
} else if (a.for_bill == 'N' && b.for_bill == 'Y') {
return 1;
} else if (a.for_ship == 'Y' && b.for_ship == 'N') {
return -1;
} else if (a.for_ship == 'N' && b.for_ship == 'Y') {
return 1;
} else if (a.for_contact == 'Y' && b.for_contact == 'N') {
return -1;
} else if (a.for_contact == 'N' && b.for_contact == 'Y') {
return 1;
} else {
return 0;
}
});
}
});
} else {
setState(() {
searchCus.clear();
searchitems.clear();
MainPage.searchItemMainPage.clear();
// searchitems.addAll(items);
print('searchitems : $searchitems');
});
}
}
This is the onsearchaddr function, it finds the address in searchitems after the search. By typing the name of the field addr, then the address will be displayed.
onSearchAddr(String text) {
List<Item> result = searchitems;
if (text.isNotEmpty) {
List<Item> itemList = [];
for (var item in result) {
item.address = item.address!
.where((element) =>
element.addr1!.toUpperCase().toLowerCase().contains(text))
.toList();
itemList.add(item);
}
setState(() {
searchitems.clear();
searchitems.addAll(itemList);
print('itemList : ${itemList}');
});
} else {
setState(() {
searchitems.clear();
searchitems.addAll(MainPage.searchItemMainPage);
print(
'SearchitemsMainPage : ${MainPage.searchItemMainPage[0].address}');
});
}
}
Could you please write some code to modify onsearchaddr, it can search as typed but when it clears text it doesn't show information of searchitems as before but it shows information of last typed message.
It's like the previous backup wasn't provided.

why the filter does not work as expected?

how can I make the logic so when I press vegan and lactose it will show me a meal that contains at least one of them or both?
in the current state it shows only meals that contains both.
Map<String, bool> _filters = {
'gluten': false,
'lactose': false,
'vegan': false,
'vegetarian': false,
};
//above is a switchTile so the values change
_availableMeals = DUMMY_MEALS.where((meal) {
if (_filters['gluten']! && !meal.isGlutenFree) {
return false;
}
if (_filters['lactose']! && !meal.isLactoseFree) {
return false;
}
if (_filters['vegan']! && !meal.isVegan) {
return false;
}
if (_filters['vegetarian']! && !meal.isVegetarian) {
return false;
}
return true;
}).toList();
Here you go. Part of the problem was that you were using ! to mean == false
_availableMeals = DUMMY_MEALS.where((meal) {
// actually i'm not sure about this part, try removing it if it doesn't make sense in your UI
if (_filters['gluten'] == false &&
_filters['lactose'] == false &&
_filters['vegan'] == false &&
_filters['vegatarian'] == false) {
return true;
}
if (_filters['gluten'] == true && meal.isGlutenFree) {
return true;
}
if (_filters['lactose'] == true && meal.isLactoseFree) {
return true;
}
if (_filters['vegan'] == true && meal.isVegan) {
return true;
}
if (_filters['vegetarian'] == true && meal.isVegetarian) {
return true;
}
return false;
}).toList();

List Null after mapping the data Flutter

This Is my coding for mapping data and filter it by subs class:
Hi i have a problem where is my list is null after it mapping the data so can you help me for this solution
void onUserJobListData(Event e) {
Map data = Map.from(e.snapshot.value);
data?.forEach((a, b) {
print("key " + a);
// int i = _jobs.indexWhere((j) => j.jobId == a);
int i = _jobs == null ? 0 : _jobs.indexWhere((j) => j.jobId == a);
if (i >= 0) {
if (b['notification_date'] != null) {
_jobs[i].matchDetail.notificationDate = b['notification_date'];
}
if (b['status_date'] != null) {
_jobs[i].matchDetail.statusDate = b['status_date'];
}
if (b['event_status'] != null) {
_jobs[i].matchDetail.eventStatus = b['event_status'];
}
if (b['notification_status'] != null) {
_jobs[i].matchDetail.notificationStatus = b['notification_status'];
}
if (b['status'] != null) {
_jobs[i].matchDetail.status = b['status'];
}
}
});
print("Apa apa jerr");
jobState.setJobList(_jobs, JobState.USER_JOB);
}`

How to check a group of text edit controllers to see if any of them are null?

I'd like to have a function that checks to see if any of the text edit controller fields are null.
I wrote this method below, but I wanted to see if there was a more elegant solution.
bool _nullfieldExists(){
//return a true if any of the textEditController fields are null
if (_textEditControllerNumberPlayers.text == null ){
return true;
}
else if (_textEditControllerSmallBlind.text == null ){
return true;
}
else if (_textEditControllerBigBlind.text == null ){
return true;
}
else if (_textEditControllerAnte.text == null ){
return true;
}
else if (_textEditControllerMyStack.text == null ){
return true;
}
else {
return false;
}
}

video overwriting using ffmpeg - I want to Add video rotation code and rewrite the existing file..How can i do that?

I want to rotate the .mov file which is in portrait mode by 90 degrees, for that i used the following code..
It works but, it results in loss of video frames...
My code is,
public void encode(File source, File target, EncodingAttributes attributes,
EncoderProgressListener listener, Integer i) throws IllegalArgumentException,
InputFormatException, EncoderException {
String formatAttribute = attributes.getFormat();
Float offsetAttribute = attributes.getOffset();
Float durationAttribute = attributes.getDuration();
QualityScale qualityScale = attributes.getQualityScale();
AudioAttributes audioAttributes = attributes.getAudioAttributes();
VideoAttributes videoAttributes = attributes.getVideoAttributes();
if (audioAttributes == null && videoAttributes == null) {
throw new IllegalArgumentException(
"Both audio and video attributes are null");
}
target = target.getAbsoluteFile();
target.getParentFile().mkdirs();
FFMPEGExecutor ffmpeg = locator.createExecutor();
if (offsetAttribute != null) {
ffmpeg.addArgument("-ss");
ffmpeg.addArgument(String.valueOf(offsetAttribute.floatValue()));
}
ffmpeg.addArgument("-i");
ffmpeg.addArgument(source.getAbsolutePath());
if (durationAttribute != null) {
ffmpeg.addArgument("-t");
ffmpeg.addArgument(String.valueOf(durationAttribute.floatValue()));
}
if (qualityScale != null) {
ffmpeg.addArgument("-qscale:"+qualityScale.getQualityStreamSpecifier());
ffmpeg.addArgument(String.valueOf(qualityScale.getQualityValue()));
}
if (videoAttributes == null) {
ffmpeg.addArgument("-vn");
} else {
String codec = videoAttributes.getCodec();
if (codec != null) {
ffmpeg.addArgument("-vcodec");
ffmpeg.addArgument(codec);
}
String tag = videoAttributes.getTag();
if (tag != null) {
ffmpeg.addArgument("-vtag");
ffmpeg.addArgument(tag);
}
Integer bitRate = videoAttributes.getBitRate();
if (bitRate != null) {
ffmpeg.addArgument("-b");
ffmpeg.addArgument(String.valueOf(bitRate.intValue()));
}
Integer frameRate = videoAttributes.getFrameRate();
if (frameRate != null) {
ffmpeg.addArgument("-r");
ffmpeg.addArgument(String.valueOf(frameRate.intValue()));
}
VideoSize size = videoAttributes.getSize();
if (size != null) {
ffmpeg.addArgument("-s");
ffmpeg.addArgument(String.valueOf(size.getWidth()) + "x"
+ String.valueOf(size.getHeight()));
}
FilterGraph filterGraph = videoAttributes.getFilterGraph();
if (filterGraph != null) {
ffmpeg.addArgument("-vf");
if(videoAttributes.getRotate() != null && videoAttributes.getRotate() == 90){
ffmpeg.addArgument("transpose=1");
}else if(videoAttributes.getRotate() != null && videoAttributes.getRotate() == 180){
ffmpeg.addArgument("vflip,hflip");
}
else {
if (filterGraph.isUseExpression()) {
ffmpeg.addArgument(filterGraph.getFilterGraphExpression());
}
}
}
}
if (audioAttributes == null) {
ffmpeg.addArgument("-an");
} else {
String codec = audioAttributes.getCodec();
if (codec != null) {
ffmpeg.addArgument("-acodec");
ffmpeg.addArgument(codec);
}
Integer bitRate = audioAttributes.getBitRate();
if (bitRate != null) {
ffmpeg.addArgument("-ab");
ffmpeg.addArgument(String.valueOf(bitRate.intValue()));
}
Integer channels = audioAttributes.getChannels();
if (channels != null) {
ffmpeg.addArgument("-ac");
ffmpeg.addArgument(String.valueOf(channels.intValue()));
}
Integer samplingRate = audioAttributes.getSamplingRate();
if (samplingRate != null) {
ffmpeg.addArgument("-ar");
ffmpeg.addArgument(String.valueOf(samplingRate.intValue()));
}
Integer volume = audioAttributes.getVolume();
if (volume != null) {
ffmpeg.addArgument("-vol");
ffmpeg.addArgument(String.valueOf(volume.intValue()));
}
}
ffmpeg.addArgument("-f");
ffmpeg.addArgument(formatAttribute);
ffmpeg.addArgument("-y");
ffmpeg.addArgument(target.getAbsolutePath());
try {
ffmpeg.execute();
} catch (IOException e) {
throw new EncoderException(e);
}
try {
String lastWarning = null;
long duration;
long progress = 0;
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getErrorStream()));
MultimediaInfo info = parseMultimediaInfo(source, reader);
if (durationAttribute != null) {
duration = (long) Math
.round((durationAttribute.floatValue() * 1000L));
} else {
duration = info.getDuration();
if (offsetAttribute != null) {
duration -= (long) Math
.round((offsetAttribute.floatValue() * 1000L));
}
}
if (listener != null) {
listener.sourceInfo(info);
}
int step = 0;
String line;
while ((line = reader.readLine()) != null) {
System.out.println("line::::"+line);
if (step == 0) {
if (line.startsWith("WARNING: ")) {
if (listener != null) {
listener.message(line);
}
} else if (!line.startsWith("Output #0")) {
//throw new EncoderException(line);
} else {
step++;
}
} else if (step == 1) {
if (!line.startsWith(" ")) {
step++;
} else {
System.out.println("line>>>>>>"+line);
Hashtable table1 = new Hashtable();
Matcher m = ROTATE_INFO_PATTERN.matcher(line);
while (m.find()) {
if (table1 == null) {
table1 = new Hashtable();
}
String key = m.group(1);
String value = m.group(2);
table1.put(key, value);
}
System.out.println("Table values"+table1.get("rotate"));
if(table1.get("rotate") != null){
Object videoRotateValue = table1.get("rotate");
int rotate = Integer.valueOf(videoRotateValue.toString());
switch(rotate){
case 90:
videoAttributes.setRotate(rotate);
if(i == 0){
i++;
encode(source, target, attributes, null, i);
}
break;
case 180:
videoAttributes.setRotate(rotate);
if(i == 0){
i++;
encode(source, target, attributes, null, i);
}
break;
case 270: System.out.println("case 3 :: "+videoRotateValue);
break;
}
}
}
}
if (step == 2) {
if (!line.startsWith("Stream mapping:")) {
throw new EncoderException(line);
} else {
step++;
}
} else if (step == 3) {
if (!line.startsWith(" ")) {
step++;
}
}
if (step == 4) {
line = line.trim();
if (line.length() > 0) {
Hashtable table = parseProgressInfoLine(line);
if (table == null) {
if (listener != null) {
listener.message(line);
}
lastWarning = line;
} else {
if (listener != null) {
String time = (String) table.get("time");
if (time != null) {
int dot = time.indexOf('.');
if (dot > 0 && dot == time.length() - 2
&& duration > 0) {
String p1 = time.substring(0, dot);
String p2 = time.substring(dot + 1);
try {
long i1 = Long.parseLong(p1);
long i2 = Long.parseLong(p2);
progress = (i1 * 1000L)
+ (i2 * 100L);
int perm = (int) Math
.round((double) (progress * 1000L)
/ (double) duration);
if (perm > 1000) {
perm = 1000;
}
listener.progress(perm);
} catch (NumberFormatException e) {
;
}
}
}
}
lastWarning = null;
}
}
}
}
if (lastWarning != null) {
if (!SUCCESS_PATTERN.matcher(lastWarning).matches()) {
throw new EncoderException(lastWarning);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
ffmpeg.destroy();
}
}
Please advise, how to achieve video rotation without any video Frame loss
Thanks In Advance
Lakshmi Priya . K
Worked for couple of days and finally tried to write the rotated video in different target file then i got the video output without any loss and video is also rotated....
Thanks
Lakshmi Priya. K