Guys i have a backend with a method that returns a finalList, which I wanted to test in my plugin "Advanced REST client", that can call different Methods combined with a request URL.
The method:
#GetMapping("/vokabelListe")
#ResponseStatus(HttpStatus.OK)
public Vokabel[] getVokabelListe() {
for (int i = 0; i < sehrWahrscheinlich.length; i++) {
if (finalList.length < 10) {
finalList[i].setVokabelENG(sehrWahrscheinlich[i].getVokabelENG());
finalList[i].setVokabelDE(sehrWahrscheinlich[i].getVokabelDE());
}
}
for (int i = 0; i < wahrscheinlich.length; i++) {
if (finalList.length < 13) {
finalList[i].setVokabelENG(sehrWahrscheinlich[i].getVokabelENG());
finalList[i].setVokabelDE(sehrWahrscheinlich[i].getVokabelDE());
}
}
for (int i = 0; i < nichtWahrscheinlich.length; i++) {
if (finalList.length < 15) {
finalList[i].setVokabelENG(sehrWahrscheinlich[i].getVokabelENG());
finalList[i].setVokabelDE(sehrWahrscheinlich[i].getVokabelDE());
}
}
while (finalList.length < 15) {
for (int i = 0; i < sehrWahrscheinlich.length; i++) {
finalList[i].setVokabelENG(sehrWahrscheinlich[i].getVokabelENG());
finalList[i].setVokabelDE(sehrWahrscheinlich[i].getVokabelDE());
}
for (int i = 0; i < wahrscheinlich.length; i++) {
finalList[i].setVokabelENG(sehrWahrscheinlich[i].getVokabelENG());
finalList[i].setVokabelDE(sehrWahrscheinlich[i].getVokabelDE());
}
for (int i = 0; i < nichtWahrscheinlich.length; i++) {
finalList[i].setVokabelENG(sehrWahrscheinlich[i].getVokabelENG());
finalList[i].setVokabelDE(sehrWahrscheinlich[i].getVokabelDE());
}
}
return finalList;
}
I just tested it, but it returns null for all indexes. I have to go through all indexes and get each VokabelDE, but i dont know how..
Related
void main() {
for(int i = 1; i < 6; i++){
for(int j=1; j<=i; j++){
var str = j.toString();
String result = str + '';
print(result);
}
print('');
}
}
Or just print j getting me the same result.
That's all print in multiple lines.
I tried toString(), but nothing changed.
Is this maybe what you want?
void main() {
for(int i = 1; i < 6; i++){
String result = '';
for(int j=1; j<=i; j++){
result = result + j.toString();
}
print(result);
}
}
Output:
1
12
123
1234
12345
Another way is to use a StringBuffer as mentioned by #pskink which is more efficient. For example like:
StringBuffer buffer = StringBuffer();
for(int i = 1; i < 6; i++){
for(int j=1; j<=i; j++){
buffer.write(j);
}
print(buffer);
buffer.clear();
}
Or another solution is like
for(int i = 1; i < 6; i++){
print(List.generate(i, (i) => i + 1).join());
}
or even the one-liner:
print(List.generate(6, (i) => List.generate(i, (i) => i + 1).join()).join('\n'));
How to parse form using PDFium, obtaining values of text fields, button statuses etc ?
I tried this code, but FPDFTextObj_GetText returns empty string.
ScopedFPDFTextPage pTextPage (FPDFText_LoadPage(Page));
for (int i = 0;i < FPDFPage_CountObjects(Page); i++)
{
FPDF_PAGEOBJECT pageObj = FPDFPage_GetObject(Page, i);
auto pageObjType = FPDFPageObj_GetType(pageObj);
if (pageObjType == FPDF_PAGEOBJ_TEXT)
{
auto size = FPDFTextObj_GetText(pageObj, pTextPage.get(), nullptr, 0);
std::vector<FPDF_WCHAR> buffer = GetFPDFWideStringBuffer(size);
size = FPDFTextObj_GetText(pageObj, pTextPage.get(), buffer.data(), size);
}
else if (pageObjType == FPDF_PAGEOBJ_FORM)
{
for (int j = 0; j < FPDFFormObj_CountObjects(pageObj); j++)
{
auto formObj = FPDFFormObj_GetObject(pageObj, j);
auto formObjType = FPDFPageObj_GetType(formObj);
if (formObjType == FPDF_PAGEOBJ_TEXT)
{
auto size = FPDFTextObj_GetText(pageObj, pTextPage.get(), nullptr, 0);
std::vector<FPDF_WCHAR> buffer = GetFPDFWideStringBuffer(size);
size = FPDFTextObj_GetText(pageObj, pTextPage.get(), buffer.data(), size);
}
}
}
}
I try to sort DocumentSnapshot from Firebase. I found the error when InsertAll to List shows List<DocumentSnapshot<Object?>>' is not a subtype of type 'Iterable<_JsonQueryDocumentSnapshot>' of 'iterable'
I don't know what I am doing wrong. I tried to search problem but didn't fix it. Please advise where I am doing wrong.
Thank you.
static List<DocumentSnapshot> sortDocumentsByComment(List<DocumentSnapshot> data){
List<DocumentSnapshot> _originalData = data;
Map<String,List<DocumentSnapshot>> commentDocuments = <String,List<DocumentSnapshot>>{};
List<int> replyCommentIndex = [];
for(int i = 0; i < _originalData.length; i++){
for(int j = 0; j < _originalData.length; j++){
if (_originalData[i]['commentID'] == _originalData[j]['toCommentID']){
List<DocumentSnapshot>? savedCommentData;
if (commentDocuments[_originalData[i]['commentID']] != null ){
savedCommentData = commentDocuments[_originalData[i]['commentID']];
}else {
savedCommentData = [];
}
savedCommentData?.add(_originalData[j]);
commentDocuments[_originalData[i]['commentID']] = savedCommentData!;
replyCommentIndex.add(j);
}
}
}
replyCommentIndex.sort((a,b){
return b.compareTo(a);
});
if(replyCommentIndex.length > 0){
for(int i = 0; i < replyCommentIndex.length; i++){
_originalData.removeAt(replyCommentIndex[i]);
}
}
for(int i = 0; i < _originalData.length; i++){
if (commentDocuments[_originalData[i]['commentID']] != null){
_originalData.insertAll(i+1,commentDocuments[_originalData[i]['commentID']]!);
}
}
return _originalData;
}
this.getPaginationsize = element.all(by.repeater('page in groupArray track by $index'));
summaryPage.getPaginationsize.count().then(function (pagination) {
if (pagination > 0) {
for (var i = 0; i < pagination; i++) {
summaryPage.getPaginationsize.get(i).click();
}
} else {
console.log('Pagination not exists');
}
});
this.getPaginationsize = element.all(by.repeater('page in groupArray track by $index'));
this.getPaginationsize.count().then(function (pagination) {
if (pagination > 0) {
for (var i = 0; i < pagination; i++) {
summaryPage.getPaginationsize.get(i).click();
}
} else {
console.log('Pagination not exists');
}
you should change it to this as you are referring to the same module you are present in
I'm creating a Gmail script that includes 5 variables, one of which is a due date. I just want it to populate as MM/DD/YYYY, however, it is currently populating as Thu Sep 13 2018 00:00:00 GMT-0400 (EDT).
Is there a way I can do that? I've pasted my code below for your reference. Any assistance is much appreciated.
function getRowsData(sheet, range, columnHeadersRowIndex) {
columnHeadersRowIndex = columnHeadersRowIndex || range.getRowIndex() - 1;
var numColumns = range.getEndColumn() - range.getColumn() + 1;
var headersRange = sheet.getRange(columnHeadersRowIndex, range.getColumn(), 1, numColumns);
var headers = headersRange.getValues()[0];
return getObjects(range.getValues(), normalizeHeaders(headers));
}
function getObjects(data, keys) {
var objects = [];
for (var i = 0; i < data.length; ++i) {
var object = {};
var hasData = false;
for (var j = 0; j < data[i].length; ++j) {
var cellData = data[i][j];
if (isCellEmpty(cellData)) {
continue;
}
object[keys[j]] = cellData;
hasData = true;
}
if (hasData) {
objects.push(object);
}
}
return objects;
}
function normalizeHeaders(headers) {
var keys = [];
for (var i = 0; i < headers.length; ++i) {
var key = normalizeHeader(headers[i]);
if (key.length > 0) {
keys.push(key);
}
}
return keys;
}
function normalizeHeader(header) {
var key = "";
var upperCase = false;
for (var i = 0; i < header.length; ++i) {
var letter = header[i];
if (letter == " " && key.length > 0) {
upperCase = true;
continue;
}
if (!isAlnum(letter)) {
continue;
}
if (key.length == 0 && isDigit(letter)) {
continue;
}
if (upperCase) {
upperCase = false;
key += letter.toUpperCase();
} else {
key += letter.toLowerCase();
}
}
return key;
}
function isCellEmpty(cellData) {
return typeof(cellData) == "string" && cellData == "";
}
function isAlnum(char) {
return char >= 'A' && char <= 'Z' ||
char >= 'a' && char <= 'z' ||
isDigit(char);
}
function isDigit(char) {
return char >= '0' && char <= '9';